See attached sources and build+test script. The bug occurs only when compiling to bytecode and then linking the bytecode into a single executable. When I use llvm-g++ to compile each C++ source to native object files and link those, the executable runs fine. Running the bytecode of the executable in lli also produces a segfault. The std::map, although unused in the code, is essential for the segfault to occur. Also, the segfault only occurs when I use two source files: when I put this same code in a single C++ source file, it runs fine. The std::map being part of the problem looks similar to bug 1491, but not exactly the same: - this bug occurs when running the native executable, no errors while linking - this bug also occurs without -O2 I'm using LLVM 2.0 and its g++ front-end, compiled from source with GCC 4.1.3.
Created attachment 995 [details] Build and test script
Created attachment 996 [details] C++ source with the std::map definition
Created attachment 997 [details] C++ source with the main() function
Created attachment 998 [details] Build and test script
Maarten, llvm-ld also runs optimizations. It seems, that static ctors/dtors were deleted by llvm-ld (this can be due to PR1491). Please use llvm-link as a temporary workaround.
I just retested after applying the fix for bug 1491 to LLVM and llvm-g++. The resulting binary still segfaults, so it seems this is a separate bug. Using llvm-link as a workaround indeed avoids the problem.
taking a look
Fixed, patch here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070604/050302.html This was due to some legacy code that was used to support llvm-gcc3. The easiest thing to do is to zap it entirely. Thanks for the report and the nice reduced testcase! -Chris