https://llvm.org/bugs/show_bug.cgi?id=25496
Bug ID: 25496 Summary: clang++ -pg links with -lc++ instead of -lc++_p Product: clang Version: 3.7 Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Driver Assignee: unassignedclangb...@nondot.org Reporter: yelli...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified I'm seeing a link failure when using "clang++ -pg" to link a program. I first saw the problem on FreeBSD 10.1: $ clang -v FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512 Target: x86_64-unknown-freebsd10.1 I was able to reproduce the problem on FreeBSD 11.0-CURRENT: $ clang -v FreeBSD clang version 3.7.0 (tags/RELEASE_370/final 246257) 20150906 Target: x86_64-unknown-freebsd11.0 Here is a small test script to reproduce the problem: #!/bin/sh -x clang++ -pg -o foo -x c++ - -pthread <<\!EOF! #include <pthread.h> static pthread_mutex_t mutex; int main(int argc, char **argv) { pthread_mutex_lock(&mutex); return 0; } !EOF! The failure looks like this: + clang++ -pg -o foo -x c++ - -pthread /usr/bin/ld: //lib/libgcc_s.so.1: invalid DSO for symbol `_Unwind_ForcedUnwind@@GCC_3.0' definition //lib/libgcc_s.so.1: could not read symbols: Bad value clang++: error: linker command failed with exit code 1 (use -v to see invocation) On success, the program compiles and links without any warnings. If you add -v to the clang++ command line, you can see that it's linking with -lc++, whereas all the other "system" type libraries that it's linking with have "_p" tacked onto their names. When I adjusted the driver to use -lc++_p in this case, the link proceeded without errors. The diff (in the FreeBSD HEAD tree) looked like this: Index: contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp =================================================================== --- contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp (revision 290623) +++ contrib/llvm/tools/clang/lib/Driver/ToolChain.cpp (working copy) @@ -451,7 +451,11 @@ switch (Type) { case ToolChain::CST_Libcxx: - CmdArgs.push_back("-lc++"); + if (Args.hasArg(options::OPT_pg)) { + CmdArgs.push_back("-lc++_p"); + } else { + CmdArgs.push_back("-lc++"); + } break; case ToolChain::CST_Libstdcxx: I don't claim that this is a comprehensive solution -- there seem to be quite a few places in the driver that know about "-lc++" -- but it was enough to solve the problem that I was seeing on FreeBSD. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs