[llvm-dev] Failed to replace stdlibc++ with libc++, linker phase error

AiChi via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 12 16:28:32 PDT 2019


I'm currently working on one of my team's project to build LLVM full clang
toolchain (Clang, libcxx, libcxxabi) on a CentOS machine.

Previously we compiled our codebase with llvm-toolset-7/clang++, which by
default takes stdlibc++ to compile and link. And now we'd like to switch to
use LLVM clang with libc++. I have built libc++ and libc++abi from source
(5.0.1 release) and set up related flags to compile our code base, but it
turned out having some issue in the "linker" phase:

Flags set for complier:
-stdlib=libc++ -std=c++14

Flags set for linker:

product.o: undefined reference to symbol '__cxa_free_exception@@CXXABI_1.3'
//lib64/libstdc++.so.6: error adding symbols: DSO missing from command line
clang-5.0: error: linker command failed with exit code 1 (use -v to see

My question is:
1. We plan to replace stdlibc++ with libc++, and we've set up compiler and
linker to run with "-stdlib=libc++', why is it complaining about libstdc++?
2. How can we resolve this error? (any ideas would be appreciated!)
3. Is there anything missing if we'd like to replace stdlibc++ with libc++?
4. I also noticed when it's in linker phase, these flags were set in the ld
command (-lc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc ), which we didn't have
them setup anywhere in our project, just out of curiosity, are they added
automatically? Why are they needed?

A little bit more details:
Environment: CentOS Linux release 7.6.1810 (Core)
Clang version:

clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Thanks for any ideas,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190412/a5b57f09/attachment.html>

More information about the llvm-dev mailing list