[PATCH] D96070: [clang] [driver] Enable static linking to libc++
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 4 14:07:22 PST 2021
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.
It is difficult for clang driver to make the decision because libc++ has multiple C++ ABI implementations as @mstorsjo said.
Persoanlly I use:
`clang++ -stdlib=libc++ -static-libstdc++ -nostdlib++ a.cc -Wl,--push-state,-Bstatic -lc++ -lc++abi -Wl,--pop-state -pthread`
This is still a bit inferior because there is a duplicate -lc++ passed by the driver.
Dynamically link against libc++.so (which depends on libc++abi.so) (additionally specify -pthread if threads are used):
`clang++ -stdlib=libc++ -nostdlib++ a.cc -lc++ -lc++abi` (clang -stdlib=libc++ a.cc -lc++ -lc++abi does not pass -lm to the linker.)
Omitting `-lc++abi` most works, but can fail if your program reference some definitions in `<exception> <stdexcept>` directly and you are using gold or LLD.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D96070/new/
https://reviews.llvm.org/D96070
More information about the cfe-commits
mailing list