[M3devel] time to introduce C mode to builder?

Daniel Alejandro Benavides D. dabenavidesd at yahoo.es
Wed Jan 9 17:30:47 CET 2013


Hi all:
Jay, besides writing another backend why not ask ex-DEC-SRC about their internal C- generating backend:
http://computer-programming-forum.com/27-modula2/4637e2c4a0349465.htm

Thanks in advance

--- El mié, 9/1/13, Jay K <jay.krell at cornell.edu> escribió:

De: Jay K <jay.krell at cornell.edu>
Asunto: [M3devel] time to introduce C mode to builder?
Para: "m3devel" <m3devel at elegosoft.com>
Fecha: miércoles, 9 de enero, 2013 01:53



So..in our config files..I have this fairly reasonable autoconf-ish logic:

  if not equal(try_exec("@" & SYSTEM_CC & m & " -c -x c /dev/null -o /dev/null 2>&1 | fgrep \"cc1: error: invalid option \\\`32'\" >/dev/null"), 0)    SYSTEM_CC = SYSTEM_CC & m    SYSTEM_CC_ASM = SYSTEM_CC_ASM & m  end  if not equal(try_exec("@" & SYSTEM_CC & arch & " -c -x c /dev/null -o /dev/null 2>&1 | fgrep \"cc1: error: unrecognized command line option \\\\\"-arch\\\\\"\" >/dev/null"), 0)    SYSTEM_CC = SYSTEM_CC & arch    SYSTEM_CC_ASM = SYSTEM_CC_ASM & arch  end

It is detecting if gcc understands switches like -m32, -m64, -arch ppc, etc.By fgreping error messages.If gcc is localized, it might be wrong.

This is fairly reasonable without a C backend, as the C compiler is used relatively few times.It is used as the linker, and if the directory has any C code.It is used a maximum of once per cm3 invocation.

Now, currently I'm using m3cgcat, per file, and it reuses this code (good!)So instead of doing the autoconf-ish logic zero or one times per directory, I'm doing it n times per directory, for fairly large n. (i.e. per source file)

I could, you know, hardcode the switches, or introduce a "setup" phase for users..
However, to "kill two birds with one stone", can I go ahead and introduce a "C" mode to the "builder"?You know, we have 4 modes: integrated backend generates assembly  integrated backend generates object files   external backend generates assembly  external backend generates object files 

(We only use two of them.)

I'd like to introduce: integrated backend generates C files (with no clear distinction currently between C and C++; the code tries to be valid for either, but eventually we'll probably want to generate C++ for exception handling).

I implemented this months ago and showed the diffs here.

This is one of the steps necessary before rolling out the C mode broadly (along with making sure it works with many existing targets, and adding new targets that use it, i.e. AMD64_NT).

Thanks, - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20130109/c36e2cab/attachment-0002.html>


More information about the M3devel mailing list