<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;'><div>&gt;&gt;Instead of working at a high level dive down to try and localise the problem.  You can use /lib/cpp directly with a simple test case to try and identify the bug.<br></div><div><br></div><div>I am posting this in hopes the answer is obvious to somebody.</div><div class="zmail_extra"><div id="1"><br><strong>Short answer: </strong>after creating a radically stripped down version of the Cog/src/vm source code, </div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;gcc -E gcc3x-cointerp.c correctly replaces the NoDbgRegParms,&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alternativelly, cpp gcc3x-cointerp.c&nbsp;correctly replaces the NoDbgRegParms as well.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ditto on cogit.c and cointerp.c as well.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;but when invoking mvm on the same it is not replaced. The reason is that at compile time for cogit.c NoDbgRegParms is defined and the&nbsp;<br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>#if !defined(NoDbgRegParms)<br># define NoDbgRegParms /*empty*/<br>#endif&nbsp;</div></blockquote>test is never entered in cogit.h (c) (the test is duplicated in both headers and c files)</div><div><br></div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I added the &nbsp;CFLAG -no-integrated-cpp to force a distinct cpp pass before compiling.</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I added the &nbsp;CFLAG -Wundef. which "-Wundef Warn whenever an identifier which is not a macro is encountered in an ‘#if’ directive, outside of ‘defined’. Such identifiers are replaced with zero."</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; examining the LOG file, this warning was not triggered in cogit.c (which tells me NoDbgRegParms is defined.</div><div><br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>#if !defined(NoDbgRegParms)<br># define NoDbgRegParms /*empty*/<br>#endif&nbsp;</div></blockquote>test.&nbsp;<br></div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I did some experimenting using #ifndef NoDbgRegParms instead of if !defined(NoDbgRegParms) to no avail.</div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I &nbsp;Put include gaurds around cogit.h and cointerp.h (#ifndef COGIT_H #define COGIT_H (all the original header file here) #ENDIF</div><div><br></div></div><div><strong>DUPLICATING THIS AT HOME (</strong><strong>I am at Cog revision 3143)</strong><strong>:</strong></div><div><br></div><div>In Cog/src/vm replace the following files (cogit.* cointerp.* gcc3x-cointerp.c) with what I have pasted here:</div><div><br></div><div>cogit.h</div><div><br></div><div><br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>/* Automatically generated by<br>        CCodeGenerator VMMaker.oscog-eem.933 uuid: 5a37067c-b76b-4ada-9399-1de11632acd8<br> */<br>/*** Function Prototypes ***/<br>#if !PRODUCTION &amp;&amp; defined(__GNUC__) &amp;&amp; !defined(NoDbgRegParms)<br># define NoDbgRegParms __attribute__ ((regparm (0)))<br>#endif<br><br>#if !defined(NoDbgRegParms)<br># define NoDbgRegParms /*empty*/<br>#endif<br><br>#if defined(__GNUC__) &amp;&amp; !defined(NeverInline)<br># define NeverInline __attribute__ ((noinline))<br>#endif<br><br>#if !defined(NeverInline)<br># define NeverInline /*empty*/<br>#endif<br>&nbsp;</div></blockquote></div><div>cogit.c</div><div><br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>#include &lt;stddef.h&gt;<br>#if COGMTVM<br>#include "cointerpmt.h"<br>#error "exclude possiblity of cointerpmt.h causing the bug"<br>#else<br>#include "cointerp.h"<br>#endif<br>#include "cogit.h"<br><br>/*** Function Prototypes ***/<br><br><br>static void dispatchConcretize(int  dude) NoDbgRegParms;<br><br>static void dispatchConcretize(int  dude){  ;}<br>&nbsp;</div></blockquote></div><div><br></div><div>cointerp.h</div><div><br></div><div><br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>/* Automatically generated by<br>        CCodeGeneratorGlobalStructure VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca<br> */<br><br>/*** Function Prototypes ***/<br><br>#if !PRODUCTION &amp;&amp; defined(__GNUC__) &amp;&amp; !defined(NoDbgRegParms)<br># define NoDbgRegParms __attribute__ ((regparm (0)))<br>#endif<br><br>#if !defined(NoDbgRegParms)<br># define NoDbgRegParms /*empty*/<br>#endif<br><br><br><br>#if defined(__GNUC__) &amp;&amp; !defined(NeverInline)<br># define NeverInline __attribute__ ((noinline))<br>#endif<br><br>#if !defined(NeverInline)<br># define NeverInline /*empty*/<br>#endif<br><br>&nbsp;</div></blockquote><br></div><div>cointerp.c (not used, but done for sanity sake)</div><div><br></div><div><br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>/* Automatically generated by<br>        CCodeGeneratorGlobalStructure VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca<br>   from<br>        CoInterpreter VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca<br> */<br><br>#if USE_GLOBAL_STRUCT<br># define SQ_USE_GLOBAL_STRUCT 1<br>#else<br># define SQ_USE_GLOBAL_STRUCT 0<br>#endif<br>#if USE_GLOBAL_STRUCT_REG <br># define SQ_USE_GLOBAL_STRUCT_REG 1<br>#else<br># define SQ_USE_GLOBAL_STRUCT_REG 0<br>#endif<br><br>#include &lt;stddef.h&gt; /* for e.g. alloca */<br>#include &lt;setjmp.h&gt;<br>#include &lt;wchar.h&gt; /* for wint_t */<br>#include "cointerp.h"<br>#include "cogit.h"<br><br>/*** Function Prototypes ***/<br><br>static void activateCoggedNewMethod(int inInterpreter) NoDbgRegParms;<br><br>static void activateCoggedNewMethod(int inInterpreter){;}<br>&nbsp;</div></blockquote><br></div><div>gcc3x-cointerp.c</div><div><br></div><div><br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>/* This file has been post-processed for GNU C */<br><br>/* Automatically generated by<br>        CCodeGeneratorGlobalStructure VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca<br>   from<br>        CoInterpreter VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca<br> */<br><br>#if USE_GLOBAL_STRUCT<br># define SQ_USE_GLOBAL_STRUCT 1<br>#else<br># define SQ_USE_GLOBAL_STRUCT 0<br>#endif<br>#if USE_GLOBAL_STRUCT_REG <br># define SQ_USE_GLOBAL_STRUCT_REG 1<br>#else<br># define SQ_USE_GLOBAL_STRUCT_REG 0<br>#endif<br><br>#include &lt;stddef.h&gt; /* for e.g. alloca */<br>#include &lt;setjmp.h&gt;<br>#include &lt;wchar.h&gt; /* for wint_t */<br>#include "cointerp.h"<br>#include "cogit.h"<br><br><br>static void activateCoggedNewMethod(int inInterpreter) NoDbgRegParms;<br>static void activateCoggedNewMethod(int inInterpreter){ ; }<br>&nbsp;</div></blockquote><br></div><div><br></div><div>In the Cog/src/vm &nbsp;directory try cpp and gcc -E driectly on the .c files and you will see the preprocessor do its job correctly.</div><div><br></div><div><br></div><div><br></div><div>In &nbsp;my mvm looks like this (note the CFLAGS -no-integrated-cpp and -Wundef &nbsp; &nbsp;per &nbsp; https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html)</div><div><br></div><div><br><blockquote style="border-top-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-top-width: 1px; border-left-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-left-style: solid; border-right-style: solid; border-bottom-style: solid; padding-top: 7px; padding-right: 7px; padding-bottom: 7px; padding-left: 7px; background-color: rgb(245, 245, 245);"><div>&nbsp;#!/bin/bash<br># VM with VM profiler and threaded heartbeat<br>INSTALLDIR=coglinuxht<br># Some gcc versions create a broken VM using -O2<br>case `gcc -v 2&gt;&amp;1 | grep version | sed 's/gcc version *//'` in<br>3.4.*)  OPT="-g -O1 -DNDEBUG -DDEBUGVM=0";;<br>*)              OPT="-g -O2 -DNDEBUG -DDEBUGVM=0";;<br>esac<br><br>if [ $# -ge 1 ]; then<br>        INSTALLDIR="$1"; shift<br>fi<br><br>echo -n "clean? "<br>read a<br>case $a in<br>n|no|N|NO)      echo "ok but this isn't safe!!";;<br>*)                      test -f Makefile &amp;&amp; make reallyclean<br>esac<br>test -f config.h || ../../../platforms/unix/config/configure  --without-npsqueak --without-vm-display-fbdev --without-gl --x-libraries=/usr/lib \<br>        CC="gcc -m32" \<br>        CXX="g++ -m32" \<br>        CFLAGS="$OPT -no-integrated-cpp -Wundef -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DCOGMTVM=0 " \<br>        LIBS="-lpthread -luuid" \<br>        LDFLAGS=-Wl,-z,now<br>rm -f vm/sqUnixMain.o # nuke version info<br>rm -rf ../../../products/$INSTALLDIR<br># prefer make install prefix=`readlink -f \`pwd\`/../../../products/$INSTALLDIR`<br># but older linux readlinks lack the -f flag<br>make install prefix=`(cd ../../../;pwd)`/products/$INSTALLDIR 2&gt;&amp;1 | tee LOG<br></div></blockquote><br></div><div><br></div><div>Then look at the LOG output .</div><div><br></div><div>Ideas much appreciated. thx.</div><div><br></div><div><br></div><div><br></div></div></div></body></html>