[gambit-list] Compilation problem; only one of two object files can be loaded

Marc Feeley feeley at iro.umontreal.ca
Thu Jul 8 09:26:39 EDT 2010


The name of the initialization function in a .oN file is derived from the name of the file.  For example, the file test.o2 will contain the initialization function _____20_test_2e_o2 .  The function name is derived from the file name to give it a unique name (i.e. dynamically loaded .oN files will not have conflicting names for the initialization function).  Many OSes don't like dynamically loading files which define the same function, which is why the N in .oN is incremented with each new compilation of a file, giving .oN files and function names that are unique.

Solution: make sure the .oN file name is coherent with the initialization function name (look for #define ___LINKER_ID ...).

... and ... never copy or rename a .oN file (i.e. don't "mv test.o2 test.o1").

Marc

On 2010-07-07, at 12:22 PM, Per Eckerdal wrote:

> I'm compiling scheme to C, then C to .o then linking, in separate steps. The goal is to create a dynamically loadable object file (one that can be loaded by Gambit's load procedure).
> 
> I have this really odd problem: I have two dynamically loadable object files that are identical except for their names (so they are not byte-to-byte identical because the file names are embedded in the files). When I load one of them, it works, but when the other one is loaded, I get "Unknown error". This happens regardless of in which order I load them:
> 
> $ gsc 
> Gambit v4.6.0
>> (load "test.o1")
> "/Users/per/prog/gambit/blackhole/test.o1"
>> (load "test.o2")
> *** ERROR IN (console)@2.1 -- Unknown error
> (load "test.o2")
> 1> 
> *** EOF again to exit
> 
> $ gsc 
> Gambit v4.6.0
>> (load "test.o2")
> "/Users/per/prog/gambit/blackhole/test.o2"
>> (load "test.o1")
> *** ERROR IN (console)@2.1 -- Unknown error
> (load "test.o1")
> 1> 
> 
> My guess is that I use incorrect compiler and/or linker flags somewhere. I had a similar issue where an object file was only loadable by the same gsc process that created it, which was because I didn't send "-D___DYNAMIC" to the C preprocessor.
> 
> The files are compiled using the exact same process, I copy-paste the commands that are used to invoke GCC at the end of the mail. Any pointers?
> 
> thanks,
> /Per
> 
> 
> The compilation and linking commands, for the two modules: (this is on OSX)
> 
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-rt.o" -D___DYNAMIC  test-rt.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-ct.o" -D___DYNAMIC  test-ct.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-vt.o" -D___DYNAMIC  test-vt.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-mi.o" -D___DYNAMIC  test-mi.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test.o1.o" -D___DYNAMIC  test.o1.c
> gcc    -bundle  -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp   -flat_namespace -undefined suppress  -D___DYNAMIC -I"/usr/local/Gambit-C/include" -o "/Users/per/prog/gambit/blackhole/src/test.o1"     ../../github-modules/work/compile-tmp/1/test.o1.o ../../github-modules/work/compile-tmp/1/test-rt.o ../../github-modules/work/compile-tmp/1/test-ct.o ../../github-modules/work/compile-tmp/1/test-vt.o ../../github-modules/work/compile-tmp/1/test-mi.o   
> 
> 
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-rt.o" -D___DYNAMIC  test-rt.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-ct.o" -D___DYNAMIC  test-ct.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-vt.o" -D___DYNAMIC  test-vt.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test-mi.o" -D___DYNAMIC  test-mi.c
> gcc    -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp    -I"/usr/local/Gambit-C/include" -c -o "/Users/per/prog/gambit/github-modules/work/compile-tmp/1/test.o2.o" -D___DYNAMIC  test.o2.c
> gcc    -bundle  -no-cpp-precomp -Wno-unused -O1 -fno-math-errno -fschedule-insns2 -fno-trapping-math -fno-strict-aliasing -fwrapv -fomit-frame-pointer -fPIC -fno-common -mieee-fp   -flat_namespace -undefined suppress  -D___DYNAMIC -I"/usr/local/Gambit-C/include" -o "/Users/per/prog/gambit/blackhole/src/test.o2"     ../../github-modules/work/compile-tmp/1/test.o2.o ../../github-modules/work/compile-tmp/1/test-rt.o ../../github-modules/work/compile-tmp/1/test-ct.o ../../github-modules/work/compile-tmp/1/test-vt.o ../../github-modules/work/compile-tmp/1/test-mi.o   
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list




More information about the Gambit-list mailing list