void
September 10, 2007, 9:42pm
#1
Hi all,
When I compile the following program with llvm-gcc on Mac x86, it segfaults:
int main(int argc, char **argv) {
try {
throw argc;
} catch(int i) {
return i;
}
return 0;
}
$ llvm-g++ -o t t.cpp
$ ./t
Segmentation fault
However, if I compile it to a .s file and then compile it with gcc, it
works fine:
$ llvm-g++ -S t.cpp -o zz.s
$ g++ -o zz zz.s
$ ./zz 1 2 3
$ echo $?
4
This is weird. Anyone have an idea of what's going on?
-bw
They are probably linking against different libstdc++ versions. Passing -v to the compiler should print the command line passed to the linker.
Note that libstdc++ in the llvm-gcc repo isn't ABI compatible with the mac OS X system libstdc++.
-Chris
void
September 10, 2007, 10:12pm
#3
Ah! Okay. That would seem to be the problem then. GCC's getting the
libstdc++ from another directory.
-bw
Make sure to remove your llvm-gcc/libstdc++ directory as mentioned by the README.LLVM file for darwin platforms. If you already built it, you probably should nuke your entire objdir and recreate it.
-Chris