- Install llvm-ld with GCC, use clang+llvm-ld however that works. Maybe that linker will understand? [edit I decided this would never work as per my edit below; I htink I really need a single-ABI system.]
- Downgrade GCC to 4.9, build llvm, clang, etc and retry building clang with clang
- Upgrade GCC to something modern. 6.4? 7.1?
- Some USE flag tweaks?
What I did
First, I have gcc 5.4.0. My libc is musl, but that should be irrelevant. I installed llvm with the following USE flags (which I'm copying manually
Code: Select all
sys-devel/llvm-common-5.0.0::gentoo
sys-libs/liboomp-5.0.0::musl USE="-hwloc -ompt {-test}"
sys-devel/llvm-5.0.0:5::gentoo USE="gold libedit libffi ncurses -debug -doc {-test}" LLVM_TARGETS="AMDGPU (X86) -AArch64 -ARM -BPF -Hexagon -Lanai -MSP430 -Mips -NVPTX -PowerPC -Sparc -SystemZ -XCore"
sys-devel/llvm-gold-5::gentoo
sys-libs/compiler-rt-sanitizers-5.0.0:5.0.0::musl USE="{-test}"
sys-libs/llvm-unwind-5.0.0::gentoo USE="libunwind static-libs {-test}"
sys-libs/libcxxabi-5.0.0::gentoo USE="libunwind static-libs {-test}"
sys-libs/libcxx-5.0.0::gentoo USE="libcxxabi libunwind static-libs -libcxxrt {-test}"
sys-devel/clang-5.0.0:5::gentoo USE="default-compiler-rt default-libcxx static-analyzer -debug -doc {-test} -xml (-z3)" LLVM_TARGETS="AMDGPU (X86) -AArch64 -ARM -BPF -Hexagon -Lanai -MSP430 -Mips -NVPTX -PowerPC -Sparc -SystemZ -XCore" PYTHON_TARGETS="python2_7"
sys-libs/compiler-rt-5.0.0:5.0.0::gentoo USE="clang {-test}"
sys-devel/clang-runtime-5.0.0:5.0.0::gentoo USE="compiler-rt libcxx openmp sanitize"
What happens
When clang tries to link against the gcc-built libLLVMSupport.so (using ld.bfd ... maybe I should try installing llvm-ld), I get a 12 undefined symbol errors. One of them:
Code: Select all
utils/TableGen/CMakeFiles/obj.clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o: In function `clang::EmitClangDiagsDefs(llvm::RecordKeeper&, llvm::raw_ostream&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)':
/var/tmp/portage/sys-devel/clang-5.0.0/work/x/y/cfe-5.0.0.src/utils/TableGen/ClangDiagnosticsEmitter.cpp:(.text._Zn5clang18EmitClangDiagsDefsERN4llvm12RecordKeeperERNS0_11raw_ostreamERKNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEE+0x65): undefined reference to `llvm::StringRef::upper() const`
Code: Select all
% nm -D /usr/lib/llvm/5/lib/libLLVMSupport.so | grep 'StringRef.*upper'
00000000000af2f0 T _ZNK4llvm9StringRef5upperB5cxx11Ev
% nm -DC /usr/lib/llvm/5/lib/libLLVMSupport.so | grep 'StringRef.*upper'
00000000000af2f0 T llvm::StringRef::upper[abi:cxx11]() const
% llvm-nm -dynamic /usr/lib/llvm/5/lib/libLLVMSupport.so | grep 'StringRef.*upper'
00000000000af2f0 T _ZNK4llvm9StringRef5upperB5cxx11Ev
% llvm-nm -dynamic -demangle /usr/lib/llvm/5/lib/libLLVMSupport.so | grep 'StringRef.*upper'
00000000000af2f0 T _ZNK4llvm9StringRef5upperB5cxx11Ev
Code: Select all
% nm -g ClangDiagnosticsEmitter.cpp.o grep 'StringRef.*upper'
U _ZNK4llvm9StringRef5upperEv
% nm -gC ClangDiagnosticsEmitter.cpp.o grep 'StringRef.*upper'
U llvm::StringRef::upper() const
% llvm-nm -extern-only ClangDiagnosticsEmitter.cpp.o grep 'StringRef.*upper'
U _ZNK4llvm9StringRef5upperEv
% llvm-nm -extern-only -demangle ClangDiagnosticsEmitter.cpp.o grep 'StringRef.*upper'
U llvm::StringRef::upper() constedit Just some more thoughts. It seems my first thought was oh, duh, clang should see the cxx11 symbol and use that but that means either that the compiler needs to notice or the linker needs to notice and rewrite the object file to use the different ABI. Both of which are wrong because the two-ABI thing GCC decided was a good idea was actually a dumb idea. I want a single ABI on my system. So it seems that the only solution may be to use a single-ABI GCC to compile LLVM.
P.S. I'm super sad this forum still uses BBCode and not Markdown.




