Jack,
I looks like the code is calling dlopen() on LLVMPolly.so and it or something it links against has an initializer. The initialer is run before dlopen() returns and the crash is in the initializer. The message:
dyld: fast lazy bind offset out of range (53437, max=7640) in image /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1
means the initializer called something which made its way into the cc1 binary, probably it called some weak symbol which resolved in the main executable cc1.
In gdb you can set:
(gdb) set env DYLD_PRINT_INITIALIZERS
and dyld will print out the address of each initializer before calling it. You can then run again and set a break point at that address and step through it.
Also, the lazy bind info for LLVMPolly.so was a little odd in that all symbols were marked "flat-namespace". On MacOSX we normally record in which dylib each symbol should be found. The use of flat-namespace tells dyld to look everywhere for those symbols. This can cause the wrong symbol to be used at runtime. Was LLVMPolly.so build with -flat_namespace or -undefined dynamic_lookup?
-Nick
Nick,
I have uploaded the full walk with 'set env DYLD_PRINT_INITIALIZERS'. It didn't seem very informative
as the dyld error occurs right after...
(gdb)
llvm::sys::DynamicLibrary::getPermanentLibrary (filename=0x142903da8 "/sw/opt/llvm-3.2/lib/LLVMPolly.so", errMsg=0x7fff5fbfe6e0) at /sw/src/fink.build/llvm32-3.2-0/llvm-3.2/lib/Support/DynamicLibrary.cpp:77
77 void *handle = dlopen(filename, RTLD_LAZY|RTLD_GLOBAL);
(gdb)
Reading symbols for shared libraries ... done
dyld: calling initializer function 0x100eea5b0 in /sw/opt/llvm-3.2/lib/LLVMPolly.so
dyld: lazy symbol binding failed: fast lazy bind offset out of range (53437, max=7640) in image /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1
dyld: fast lazy bind offset out of range (53437, max=7640) in image /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1
Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007fff5fc0109d in __dyld_dyld_fatal_error ()
The linkage is...
% otool -L /sw/opt/llvm-3.2/lib/LLVMPolly.so
/sw/opt/llvm-3.2/lib/LLVMPolly.so:
/sw/lib/libisl.10.dylib (compatibility version 11.0.0, current version 11.0.0)
/sw/lib/gmp5/libgmp.10.dylib (compatibility version 11.0.0, current version 11.5.0)
/sw/lib/libcloog-isl.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
and done with...
/sw/var/lib/fink/path-prefix-clang/c++ -fPIC -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -g -bundle -Wl,-headerpad_max_install_names -Wl,-flat_namespace -Wl,-undefined -Wl,suppress -L/sw/lib -o ../../../lib/LLVMPolly.so CMakeFiles/LLVMPolly.dir/CodePreparation.cpp.o CMakeFiles/LLVMPolly.dir/DeadCodeElimination.cpp.o CMakeFiles/LLVMPolly.dir/IndependentBlocks.cpp.o CMakeFiles/LLVMPolly.dir/IndVarSimplify.cpp.o CMakeFiles/LLVMPolly.dir/MayAliasSet.cpp.o CMakeFiles/LLVMPolly.dir/Pocc.cpp.o CMakeFiles/LLVMPolly.dir/RegionSimplify.cpp.o CMakeFiles/LLVMPolly.dir/RegisterPasses.cpp.o CMakeFiles/LLVMPolly.dir/ScheduleOptimizer.cpp.o ../../../lib/libPollyAnalysis.a ../../../lib/libPollyCodeGen.a ../../../lib/libPollyExchange.a ../../../lib/libPollySupport.a ../../../lib/libPollyJSON.a /sw/lib/libisl.dylib /sw/lib/libgmp.dylib /sw/lib/libcloog-isl.dylib -lpthread
whereas the dragonegg.so is...
% otool -L /sw/lib/gcc4.7/lib/dragonegg.so
/sw/lib/gcc4.7/lib/dragonegg.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
using
clang++ -o dragonegg.so -bundle -undefined dynamic_lookup -Wall -Wextra -DENABLE_LLVM_PLUGINS -I/sw/opt/llvm-3.2/include -fPIC -fvisibility-inlines-hidden -g -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -Wcovered-switch-default -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
Aliasing.o Backend.o Cache.o ConstantConversion.o Convert.o Debug.o DefaultABI.o Trees.o TypeConversion.o bits_and_bobs.o Target.o \
-lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMMCParser -lLLVMCodeGen -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMInstrumentation -lLLVMAsmParser -lLLVMBitWriter -lLLVMBitReader -lLLVMipo -lLLVMVectorize -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore -lLLVMSupport \
-L/sw/opt/llvm-3.2/lib -L/sw/lib -lpthread -L/sw/lib
and cc1 is...
% otool -L /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1
/sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1:
/sw/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
/sw/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/sw/lib/libcloog-isl.1.dylib (compatibility version 2.0.0, current version 2.2.0)
/sw/lib/libisl.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/sw/lib/libppl_c.4.dylib (compatibility version 5.0.0, current version 5.0.0)
/sw/lib/libppl.9.dylib (compatibility version 10.0.0, current version 10.0.0)
/sw/lib/libpwl.5.dylib (compatibility version 6.0.0, current version 6.0.0)
/sw/lib/gmp5/libgmpxx.4.dylib (compatibility version 7.0.0, current version 7.5.0)
/sw/lib/libmpc.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/sw/lib/libmpfr.4.dylib (compatibility version 6.0.0, current version 6.1.0)
/sw/lib/gmp5/libgmp.10.dylib (compatibility version 11.0.0, current version 11.5.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
I tried relinking /sw/opt/llvm-3.2/lib/LLVMPolly.so to have more of the linkages from
/sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1
# otool -L /sw/opt/llvm-3.2/lib/LLVMPolly.so
/sw/opt/llvm-3.2/lib/LLVMPolly.so:
/sw/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.1.0)
/sw/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/sw/lib/libcloog-isl.1.dylib (compatibility version 2.0.0, current version 2.2.0)
/sw/lib/libisl.6.dylib (compatibility version 7.0.0, current version 7.0.0)
/sw/lib/gmp5/libgmpxx.4.dylib (compatibility version 7.0.0, current version 7.5.0)
/sw/lib/libmpc.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/sw/lib/libmpfr.4.dylib (compatibility version 6.0.0, current version 6.1.0)
/sw/lib/libisl.10.dylib (compatibility version 11.0.0, current version 11.0.0)
/sw/lib/gmp5/libgmp.10.dylib (compatibility version 11.0.0, current version 11.5.0)
/sw/lib/libcloog-isl.3.dylib (compatibility version 4.0.0, current version 4.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
and this didn't eliminate the error...
dyld: lazy symbol binding failed: fast lazy bind offset out of range (53437, max=7640) in image /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1
dyld: fast lazy bind offset out of range (53437, max=7640) in image /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin12.2.0/4.7.2/cc1
Are there any tricks for identifying the order that the symbols are being resolved?
Jack