Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 722978 - sys-devel/llvm fails to build with Clang with -rtlib=compiler-rt (default with sys-devel/clang[default-compiler-rt]) (except with -stdlib=libc++ and sys-libs/llvm-libunwind transitively used through sys-libs/libcxx{,abi}[libunwind])
Summary: sys-devel/llvm fails to build with Clang with -rtlib=compiler-rt (default wit...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: compiler-rt-tracker
  Show dependency tree
 
Reported: 2020-05-14 09:40 UTC by Arfrever Frehtes Taifersar Arahesis
Modified: 2021-03-08 11:40 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Log for -stdlib=libstdc++ -rtlib=compiler-rt (llvm-11.0.0.9999:20200512-071558.log.xz,11.77 KB, application/x-xz)
2020-05-14 09:48 UTC, Arfrever Frehtes Taifersar Arahesis
Details
Log for -stdlib=libc++ -rtlib=compiler-rt + sys-libs/libcxx{,abi}[libunwind] + sys-libs/libunwind (llvm-11.0.0.9999:20200512-075739.log.xz,80.04 KB, application/x-xz)
2020-05-14 09:52 UTC, Arfrever Frehtes Taifersar Arahesis
Details
Log for -stdlib=libc++ -rtlib=compiler-rt + sys-libs/libcxx{,abi}[libunwind] + sys-libs/llvm-libunwind (llvm-11.0.0.9999:20200513-005652.log.xz,101.86 KB, application/x-xz)
2020-05-14 09:56 UTC, Arfrever Frehtes Taifersar Arahesis
Details
Patch (llvm.patch,5.99 KB, patch)
2020-05-14 10:09 UTC, Arfrever Frehtes Taifersar Arahesis
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arfrever Frehtes Taifersar Arahesis 2020-05-14 09:40:43 UTC
sys-devel/llvm fails to build with Clang with -rtlib=compiler-rt (default with sys-devel/clang[default-compiler-rt]) in most possible combinations:

CXXFLAGS="... -stdlib=libstdc++" + LDFLAGS="... -rtlib=compiler-rt"
  FAILURE
    Many files: undefined reference to `_Unwind_Resume'

CXXFLAGS="... -stdlib=libc++" + LDFLAGS="... -rtlib=compiler-rt" + sys-libs/libcxx{,abi}[-libunwind]
  FAILURE
    Many files: undefined reference to `_Unwind_Resume'
    RTDyldMemoryManager.cpp: undefined reference to `__register_frame'
    RTDyldMemoryManager.cpp: undefined reference to `__deregister_frame'

CXXFLAGS="... -stdlib=libc++" + LDFLAGS="... -rtlib=compiler-rt" + sys-libs/libcxx{,abi}[libunwind] + sys-libs/libunwind
  FAILURE
    RTDyldMemoryManager.cpp: undefined reference to `__register_frame'
    RTDyldMemoryManager.cpp: undefined reference to `__deregister_frame'

CXXFLAGS="... -stdlib=libc++" + LDFLAGS="... -rtlib=compiler-rt" + sys-libs/libcxx{,abi}[libunwind] + sys-libs/llvm-libunwind
  NO FAILURE


Failures are caused by not linking against any library defining required symbols.

_Unwind_Resume is defined in:
  libgcc_s.so from sys-devel/gcc
  libunwind.so from sys-libs/libunwind
  libunwind.so from sys-libs/llvm-libunwind

__register_frame and __deregister_frame are defined in:
  libgcc_s.so from sys-devel/gcc
  libunwind.so from sys-libs/llvm-libunwind


"undefined reference to `_Unwind_Resume'" errors probably occur since this commit, which made -unwindlib= (with empty value) default:
https://github.com/llvm/llvm-project/commit/6271606969e276f48c6965f31a46acf54e476e65
https://github.com/llvm/llvm-project/commit/6271606969e276f48c6965f31a46acf54e476e65#diff-099203948b69b8f6547254ea9599f840R703-R706


I suggest to add linking against libunwind.so from sys-libs/llvm-libunwind when available, and otherwise to add linking against libgcc_s.so from sys-devel/gcc.
Comment 1 Arfrever Frehtes Taifersar Arahesis 2020-05-14 09:48:22 UTC
Created attachment 638840 [details]
Log for -stdlib=libstdc++ -rtlib=compiler-rt

: && /usr/lib/llvm/11/bin/x86_64-pc-linux-gnu-clang++  -march=native -O2 -frecord-command-line -fstack-clash-protection -fstack-protector-all -mretpoline -pipe -Qn -Wall -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,--gc-sections -Wl,--sort-common -Wl,-z,now -rtlib=compiler-rt -Wl,-allow-shlib-undefined    -Wl,-rpath-link,/var/tmp/portage/sys-devel/llvm-11.0.0.9999/work/llvm-abi_x86_64.amd64/./lib64  -Wl,-O3 -Wl,--gc-sections utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmWriterEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmWriterInst.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/Attributes.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CallingConvEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeEmitterGen.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenDAGPatterns.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenHwModes.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenInstruction.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenMapTable.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenRegisters.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenSchedule.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenTarget.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherGen.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcherOpt.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DAGISelMatcher.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DFAEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DFAPacketizerEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/DisassemblerEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/ExegesisEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/FastISelEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/FixedLenDecoderEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/GICombinerEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/GlobalISelEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/InfoByHwMode.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/InstrInfoEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/InstrDocsEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/IntrinsicEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptParserEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptRSTEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/PredicateExpander.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/PseudoLoweringEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/RISCVCompressInstEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/RegisterBankEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/RegisterInfoEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/SDNodeProperties.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/SearchableTableEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/SubtargetEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/SubtargetFeatureInfo.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/TableGen.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/Types.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86DisassemblerTables.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86EVEX2VEXTablesEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86FoldTablesEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86ModRMFilters.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/X86RecognizableInstr.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/WebAssemblyDisassemblerEmitter.cpp.o utils/TableGen/CMakeFiles/llvm-tblgen.dir/CTagsEmitter.cpp.o  -o bin/llvm-tblgen  -Wl,-rpath,"\$ORIGIN/../lib64"  lib64/libLLVMSupport.a  lib64/libLLVMTableGen.a  -lpthread  lib64/libLLVMTableGenGlobalISel.a  lib64/libLLVMTableGen.a  lib64/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  lib64/libLLVMDemangle.a && :
clang-11: warning: argument unused during compilation: '-Qn' [-Wunused-command-line-argument]
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o: in function `llvm::cl::opt<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::opt<char [13], llvm::cl::initializer<char [1]>, llvm::cl::desc, llvm::cl::cat>(char const (&) [13], llvm::cl::initializer<char [1]> const&, llvm::cl::desc const&, llvm::cl::cat const&)':
AsmMatcherEmitter.cpp:(.text._ZN4llvm2cl3optINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEELb0ENS0_6parserIS7_EEEC2IJA13_cNS0_11initializerIA1_cEENS0_4descENS0_3catEEEEDpRKT_[_ZN4llvm2cl3optINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEELb0ENS0_6parserIS7_EEEC2IJA13_cNS0_11initializerIA1_cEENS0_4descENS0_3catEEEEDpRKT_]+0x21a): undefined reference to `_Unwind_Resume'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o: in function `(anonymous namespace)::AsmMatcherEmitter::run(llvm::raw_ostream&)':
AsmMatcherEmitter.cpp:(.text._ZN12_GLOBAL__N_117AsmMatcherEmitter3runERN4llvm11raw_ostreamE+0x158b4): undefined reference to `_Unwind_Resume'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o: in function `(anonymous namespace)::AsmMatcherInfo::buildInfo()':
AsmMatcherEmitter.cpp:(.text._ZN12_GLOBAL__N_114AsmMatcherInfo9buildInfoEv+0x75fb): undefined reference to `_Unwind_Resume'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o: in function `emitConvertFuncs(llvm::CodeGenTarget&, llvm::StringRef, std::vector<std::unique_ptr<(anonymous namespace)::MatchableInfo, std::default_delete<(anonymous namespace)::MatchableInfo> >, std::allocator<std::unique_ptr<(anonymous namespace)::MatchableInfo, std::default_delete<(anonymous namespace)::MatchableInfo> > > >&, bool, bool, llvm::raw_ostream&)':
AsmMatcherEmitter.cpp:(.text._ZL16emitConvertFuncsRN4llvm13CodeGenTargetENS_9StringRefERSt6vectorISt10unique_ptrIN12_GLOBAL__N_113MatchableInfoESt14default_deleteIS6_EESaIS9_EEbbRNS_11raw_ostreamE+0x714e): undefined reference to `_Unwind_Resume'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o: in function `llvm::StringToOffsetTable::EmitString(llvm::raw_ostream&)':
AsmMatcherEmitter.cpp:(.text._ZN4llvm19StringToOffsetTable10EmitStringERNS_11raw_ostreamE[_ZN4llvm19StringToOffsetTable10EmitStringERNS_11raw_ostreamE]+0x41b): undefined reference to `_Unwind_Resume'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/TableGen/CMakeFiles/llvm-tblgen.dir/AsmMatcherEmitter.cpp.o:AsmMatcherEmitter.cpp:(.text._ZNK4llvm20SubtargetFeatureInfo14getEnumBitNameB5cxx11Ev[_ZNK4llvm20SubtargetFeatureInfo14getEnumBitNameB5cxx11Ev]+0x1fa): more undefined references to `_Unwind_Resume' follow
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 2 Arfrever Frehtes Taifersar Arahesis 2020-05-14 09:52:08 UTC
Created attachment 638842 [details]
Log for -stdlib=libc++ -rtlib=compiler-rt + sys-libs/libcxx{,abi}[libunwind] + sys-libs/libunwind

: && /usr/lib/llvm/11/bin/x86_64-pc-linux-gnu-clang++  -march=native -O2 -frecord-command-line -fstack-clash-protection -fstack-protector-all -mretpoline -pipe -Qn -Wall -stdlib=libc++ -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-comment -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections  -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,--gc-sections -Wl,--sort-common -Wl,-z,now -rtlib=compiler-rt -Wl,-allow-shlib-undefined    -Wl,-rpath-link,/var/tmp/portage/sys-devel/llvm-11.0.0.9999/work/llvm-abi_x86_64.amd64/./lib64  -Wl,-O3 -Wl,--gc-sections tools/lli/ChildTarget/CMakeFiles/lli-child-target.dir/ChildTarget.cpp.o  -o bin/lli-child-target  -Wl,-rpath,"\$ORIGIN/../lib64"  lib64/libLLVMOrcError.a  lib64/libLLVMOrcJIT.a  lib64/libLLVMRuntimeDyld.a  lib64/libLLVMSupport.a  -lpthread  lib64/libLLVMOrcError.a  lib64/libLLVMExecutionEngine.a  lib64/libLLVMRuntimeDyld.a  lib64/libLLVMJITLink.a  lib64/libLLVMPasses.a  lib64/libLLVMCodeGen.a  lib64/libLLVMCoroutines.a  lib64/libLLVMipo.a  lib64/libLLVMInstrumentation.a  lib64/libLLVMScalarOpts.a  lib64/libLLVMAggressiveInstCombine.a  lib64/libLLVMInstCombine.a  lib64/libLLVMVectorize.a  lib64/libLLVMFrontendOpenMP.a  lib64/libLLVMIRReader.a  lib64/libLLVMAsmParser.a  lib64/libLLVMLinker.a  lib64/libLLVMTarget.a  lib64/libLLVMTransformUtils.a  lib64/libLLVMBitWriter.a  lib64/libLLVMAnalysis.a  lib64/libLLVMObject.a  lib64/libLLVMBitReader.a  lib64/libLLVMMCParser.a  lib64/libLLVMMC.a  lib64/libLLVMDebugInfoCodeView.a  lib64/libLLVMDebugInfoMSF.a  lib64/libLLVMTextAPI.a  lib64/libLLVMProfileData.a  lib64/libLLVMCore.a  lib64/libLLVMBinaryFormat.a  lib64/libLLVMRemarks.a  lib64/libLLVMBitstreamReader.a  lib64/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  lib64/libLLVMDemangle.a && :
clang-11: warning: argument unused during compilation: '-Qn' [-Wunused-command-line-argument]
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: lib64/libLLVMRuntimeDyld.a(RTDyldMemoryManager.cpp.o): in function `llvm::RTDyldMemoryManager::registerEHFramesInProcess(unsigned char*, unsigned long)':
RTDyldMemoryManager.cpp:(.text._ZN4llvm19RTDyldMemoryManager25registerEHFramesInProcessEPhm+0x12): undefined reference to `__register_frame'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: lib64/libLLVMRuntimeDyld.a(RTDyldMemoryManager.cpp.o): in function `llvm::RTDyldMemoryManager::deregisterEHFramesInProcess(unsigned char*, unsigned long)':
RTDyldMemoryManager.cpp:(.text._ZN4llvm19RTDyldMemoryManager27deregisterEHFramesInProcessEPhm+0x12): undefined reference to `__deregister_frame'
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 3 Arfrever Frehtes Taifersar Arahesis 2020-05-14 09:56:17 UTC
Created attachment 638844 [details]
Log for -stdlib=libc++ -rtlib=compiler-rt + sys-libs/libcxx{,abi}[libunwind] + sys-libs/llvm-libunwind
Comment 4 Arfrever Frehtes Taifersar Arahesis 2020-05-14 10:09:31 UTC
Created attachment 638846 [details, diff]
Patch
Comment 5 Theo Anderson 2021-03-07 00:43:40 UTC
Sounds like this is the same as https://bugs.gentoo.org/702344

Should be fixed with: https://github.com/gentoo/gentoo/pull/19793