[Vm-dev] Adding -DNoDbgRegParms= to mvm solves my
compile problem on linux
gettimothy
gettimothy at zoho.com
Fri Nov 21 19:19:19 UTC 2014
>>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.
I am posting this in hopes the answer is obvious to somebody.
Short answer: after creating a radically stripped down version of the Cog/src/vm source code,
gcc -E gcc3x-cointerp.c correctly replaces the NoDbgRegParms,
alternativelly, cpp gcc3x-cointerp.c correctly replaces the NoDbgRegParms as well.
ditto on cogit.c and cointerp.c as well.
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
#if !defined(NoDbgRegParms)
# define NoDbgRegParms /*empty*/
#endif
test is never entered in cogit.h (c) (the test is duplicated in both headers and c files)
I added the CFLAG -no-integrated-cpp to force a distinct cpp pass before compiling.
I added the 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."
examining the LOG file, this warning was not triggered in cogit.c (which tells me NoDbgRegParms is defined.
#if !defined(NoDbgRegParms)
# define NoDbgRegParms /*empty*/
#endif
test.
I did some experimenting using #ifndef NoDbgRegParms instead of if !defined(NoDbgRegParms) to no avail.
I Put include gaurds around cogit.h and cointerp.h (#ifndef COGIT_H #define COGIT_H (all the original header file here) #ENDIF
DUPLICATING THIS AT HOME (I am at Cog revision 3143):
In Cog/src/vm replace the following files (cogit.* cointerp.* gcc3x-cointerp.c) with what I have pasted here:
cogit.h
/* Automatically generated by
CCodeGenerator VMMaker.oscog-eem.933 uuid: 5a37067c-b76b-4ada-9399-1de11632acd8
*/
/*** Function Prototypes ***/
#if !PRODUCTION && defined(__GNUC__) && !defined(NoDbgRegParms)
# define NoDbgRegParms __attribute__ ((regparm (0)))
#endif
#if !defined(NoDbgRegParms)
# define NoDbgRegParms /*empty*/
#endif
#if defined(__GNUC__) && !defined(NeverInline)
# define NeverInline __attribute__ ((noinline))
#endif
#if !defined(NeverInline)
# define NeverInline /*empty*/
#endif
cogit.c
#include <stddef.h>
#if COGMTVM
#include "cointerpmt.h"
#error "exclude possiblity of cointerpmt.h causing the bug"
#else
#include "cointerp.h"
#endif
#include "cogit.h"
/*** Function Prototypes ***/
static void dispatchConcretize(int dude) NoDbgRegParms;
static void dispatchConcretize(int dude){ ;}
cointerp.h
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca
*/
/*** Function Prototypes ***/
#if !PRODUCTION && defined(__GNUC__) && !defined(NoDbgRegParms)
# define NoDbgRegParms __attribute__ ((regparm (0)))
#endif
#if !defined(NoDbgRegParms)
# define NoDbgRegParms /*empty*/
#endif
#if defined(__GNUC__) && !defined(NeverInline)
# define NeverInline __attribute__ ((noinline))
#endif
#if !defined(NeverInline)
# define NeverInline /*empty*/
#endif
cointerp.c (not used, but done for sanity sake)
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca
from
CoInterpreter VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca
*/
#if USE_GLOBAL_STRUCT
# define SQ_USE_GLOBAL_STRUCT 1
#else
# define SQ_USE_GLOBAL_STRUCT 0
#endif
#if USE_GLOBAL_STRUCT_REG
# define SQ_USE_GLOBAL_STRUCT_REG 1
#else
# define SQ_USE_GLOBAL_STRUCT_REG 0
#endif
#include <stddef.h> /* for e.g. alloca */
#include <setjmp.h>
#include <wchar.h> /* for wint_t */
#include "cointerp.h"
#include "cogit.h"
/*** Function Prototypes ***/
static void activateCoggedNewMethod(int inInterpreter) NoDbgRegParms;
static void activateCoggedNewMethod(int inInterpreter){;}
gcc3x-cointerp.c
/* This file has been post-processed for GNU C */
/* Automatically generated by
CCodeGeneratorGlobalStructure VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca
from
CoInterpreter VMMaker.oscog-eem.948 uuid: 9323b2ad-f5cf-4aca-8f31-67eb5616ccca
*/
#if USE_GLOBAL_STRUCT
# define SQ_USE_GLOBAL_STRUCT 1
#else
# define SQ_USE_GLOBAL_STRUCT 0
#endif
#if USE_GLOBAL_STRUCT_REG
# define SQ_USE_GLOBAL_STRUCT_REG 1
#else
# define SQ_USE_GLOBAL_STRUCT_REG 0
#endif
#include <stddef.h> /* for e.g. alloca */
#include <setjmp.h>
#include <wchar.h> /* for wint_t */
#include "cointerp.h"
#include "cogit.h"
static void activateCoggedNewMethod(int inInterpreter) NoDbgRegParms;
static void activateCoggedNewMethod(int inInterpreter){ ; }
In the Cog/src/vm directory try cpp and gcc -E driectly on the .c files and you will see the preprocessor do its job correctly.
In my mvm looks like this (note the CFLAGS -no-integrated-cpp and -Wundef per https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html)
#!/bin/bash
# VM with VM profiler and threaded heartbeat
INSTALLDIR=coglinuxht
# Some gcc versions create a broken VM using -O2
case `gcc -v 2>&1 | grep version | sed 's/gcc version *//'` in
3.4.*) OPT="-g -O1 -DNDEBUG -DDEBUGVM=0";;
*) OPT="-g -O2 -DNDEBUG -DDEBUGVM=0";;
esac
if [ $# -ge 1 ]; then
INSTALLDIR="$1"; shift
fi
echo -n "clean? "
read a
case $a in
n|no|N|NO) echo "ok but this isn't safe!!";;
*) test -f Makefile && make reallyclean
esac
test -f config.h || ../../../platforms/unix/config/configure --without-npsqueak --without-vm-display-fbdev --without-gl --x-libraries=/usr/lib \
CC="gcc -m32" \
CXX="g++ -m32" \
CFLAGS="$OPT -no-integrated-cpp -Wundef -msse2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DCOGMTVM=0 " \
LIBS="-lpthread -luuid" \
LDFLAGS=-Wl,-z,now
rm -f vm/sqUnixMain.o # nuke version info
rm -rf ../../../products/$INSTALLDIR
# prefer make install prefix=`readlink -f \`pwd\`/../../../products/$INSTALLDIR`
# but older linux readlinks lack the -f flag
make install prefix=`(cd ../../../;pwd)`/products/$INSTALLDIR 2>&1 | tee LOG
Then look at the LOG output .
Ideas much appreciated. thx.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20141121/3ec855e0/attachment-0001.htm
More information about the Vm-dev
mailing list