[M3devel] time to introduce C mode to builder?
jay.krell at cornell.edu
Wed Jan 9 07:53:49 CET 2013
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...
More information about the M3devel