<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi all:<br>Jay, besides writing another backend why not ask ex-DEC-SRC about their internal C- generating backend:<br>http://computer-programming-forum.com/27-modula2/4637e2c4a0349465.htm<br><br>Thanks in advance<br><br>--- El <b>mié, 9/1/13, Jay K <i><jay.krell@cornell.edu></i></b> escribió:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>De: Jay K <jay.krell@cornell.edu><br>Asunto: [M3devel] time to introduce C mode to builder?<br>Para: "m3devel" <m3devel@elegosoft.com><br>Fecha: miércoles, 9 de enero, 2013 01:53<br><br><div id="yiv1217839597">
<style><!--
#yiv1217839597 .yiv1217839597hmmessage P
{
margin:0px;padding:0px;}
#yiv1217839597 body.yiv1217839597hmmessage
{
font-size:12pt;font-family:Calibri;}
--></style><div><div dir="ltr">So..in our config files..I have this fairly reasonable autoconf-ish logic:<div><br></div><div><br></div><div><div> 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)</div><div> SYSTEM_CC = SYSTEM_CC & m</div><div> SYSTEM_CC_ASM = SYSTEM_CC_ASM & m</div><div> end</div><div> 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)</div><div> SYSTEM_CC = SYSTEM_CC & arch</div><div> SYSTEM_CC_ASM = SYSTEM_CC_ASM & arch</div><div> end</div><div><br></div><br>It is detecting if gcc understands switches like -m32, -m64, -arch ppc, etc.</div><div>By fgreping error messages.</div><div>If
gcc is localized, it might be wrong.</div><div><br></div><div><br></div><div>This is fairly reasonable without a C backend, as the C compiler is used relatively few times.</div><div>It is used as the linker, and if the directory has any C code.</div><div>It is used a maximum of once per cm3 invocation.</div><div><br></div><div><br></div><div>Now, currently I'm using m3cgcat, per file, and it reuses this code (good!)</div><div>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)</div><div><br></div><div><br></div><div>I could, you know, hardcode the switches, or introduce a "setup" phase for users.</div><div>.</div><div><br></div><div>However, to "kill two birds with one stone", can I go ahead and introduce a "C" mode to the "builder"?</div><div>You know, we have 4 modes:</div><div> integrated backend generates
assembly </div><div><div> integrated backend generates object files </div></div><div><div> external backend generates assembly </div><div><span style="font-size: 12pt;"> external</span> backend generates object files </div></div><div><br></div><div><br></div><div>(We only use two of them.)</div><div><br></div><div><br></div><div>I'd like to introduce:</div><div> 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).</div><div><br></div><div><br></div><div>I implemented this months ago and showed the diffs here.</div><div><br></div><div><br></div><div>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).</div><div><br></div><div><br></div><div>Thanks,</div><div> - Jay</div><div><br></div> </div></div>
</div></blockquote></td></tr></table>