[21.0-rc4] libMesaOpenCL fails to link: undefined references to calls to LLVMInitialize*Target/LLVMInitialize*TargetInfo for irrelevant targets
System information
OpenMandriva Lx 4.2:
- glibc 2.33
- LLVM/Clang 11.0.1
Describe the issue
libMesaOpenCL fails to link because calls to LLVMInitializeTarget and LLVMInitializeTargetInfo are introduced by Targets.def (with * being all targets LLVM supports -- in the case of OpenMandriva's system LLVM, just about every CPU in existance because we like crosscompilers), but the corresponding libraries aren't being linked to.
Regression
Works in 20.3.4
Log files as attachment
[2517/2536] Linking target src/gallium/targets/opencl/libMesaOpenCL.so.1.0.0
FAILED: src/gallium/targets/opencl/libMesaOpenCL.so.1.0.0
/usr/bin/clang++ -o src/gallium/targets/opencl/libMesaOpenCL.so.1.0.0 -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libMesaOpenCL.so.1 -Wl,--whole-archive src/gallium/frontends/clover/libclover.a -Wl,--no-whole-archive -Os -fomit-frame-pointer -g1 -Wstrict-aliasing=2 -pipe -fstack-protector-all --param=ssp-buffer-size=4 -O3 -m64 -march=znver1 -mtune=znver1 -mmmx -msse -msse2 -mssse3 -msse4a -msse4.1 -msse4.2 -mavx -mavx2 -msha -maes -mclflushopt -mfsgsbase -mrdrnd -mfma -mrdseed -mpopcnt -madx -mbmi -mbmi2 -mfxsr -mxsave -mxsaveopt -mxsavec -mxsaves -mmwaitx -mclzero -mfpmath=sse -flto -O3 -fno-strict-aliasing -Os -fomit-frame-pointer -g1 -Wstrict-aliasing=2 -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -O3 -m64 -march=znver1 -mtune=znver1 -mmmx -msse -msse2 -mssse3 -msse4a -msse4.1 -msse4.2 -mavx -mavx2 -msha -maes -mclflushopt -mfsgsbase -mrdrnd -mfma -mrdseed -mpopcnt -madx -mbmi -mbmi2 -mfxsr -mxsave -mxsaveopt -mxsavec -mxsaves -mmwaitx -mclzero -mfpmath=sse -flto -O3 -fno-strict-aliasing -Wl,-O2 -flto src/gallium/auxiliary/pipe-loader/libpipe_loader_dynamic.a src/loader/libloader.a src/util/libxmlconfig.a src/util/libmesa_util.a src/util/format/libmesa_format.a src/gallium/auxiliary/libgallium.a src/compiler/nir/libnir.a src/compiler/libcompiler.a src/gallium/frontends/clover/libclllvm.a src/gallium/frontends/clover/libclspirv.a src/gallium/frontends/clover/libclnir.a -Wl,--gc-sections -Wl,--version-script /home/bero/abf/mesa/BUILD/mesa-21.0.0-rc4/src/gallium/targets/opencl/opencl.sym /usr/lib64/libz.so -pthread -lm -ldl /usr/lib64/libunwind/libunwind.so /usr/lib64/libelf.so /usr/lib64/libclang-cpp.so /usr/lib64/libdrm.so /usr/lib64/libexpat.so -lzstd -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMMIRParser -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMOption -lLLVMLTO -lLLVMObjCARCOpts -lLLVMExtensions -lPolly -lPollyPPCG -lPollyISL -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMPasses -lLLVMCoroutines -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMFrontendOpenMP -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMCFGuard -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMX86Desc -lLLVMX86Info -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMCoverage -lLLVMProfileData -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMBitReader -lLLVMMCDisassembler -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lsensors -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMMIRParser -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMOption -lLLVMLTO -lLLVMObjCARCOpts -lLLVMExtensions -lPolly -lPollyPPCG -lPollyISL -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMPasses -lLLVMCoroutines -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMFrontendOpenMP -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMCFGuard -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMX86Desc -lLLVMX86Info -lLLVMMCJIT -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMCoverage -lLLVMProfileData -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMBitReader -lLLVMMCDisassembler -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -Wl,--end-group -Wl,-rpath,/usr/lib64/libunwind -Wl,-rpath-link,/usr/lib64/libunwind
ld: error: undefined symbol: LLVMInitializeAArch64Target
>>> referenced by Targets.def:26 (/usr/include/llvm/Config/Targets.def:26)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeARMTarget
>>> referenced by Targets.def:28 (/usr/include/llvm/Config/Targets.def:28)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeAVRTarget
>>> referenced by Targets.def:29 (/usr/include/llvm/Config/Targets.def:29)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeBPFTarget
>>> referenced by Targets.def:30 (/usr/include/llvm/Config/Targets.def:30)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeHexagonTarget
>>> referenced by Targets.def:31 (/usr/include/llvm/Config/Targets.def:31)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeLanaiTarget
>>> referenced by Targets.def:32 (/usr/include/llvm/Config/Targets.def:32)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeMipsTarget
>>> referenced by Targets.def:33 (/usr/include/llvm/Config/Targets.def:33)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeMSP430Target
>>> referenced by Targets.def:34 (/usr/include/llvm/Config/Targets.def:34)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializePowerPCTarget
>>> referenced by Targets.def:36 (/usr/include/llvm/Config/Targets.def:36)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeRISCVTarget
>>> referenced by Targets.def:37 (/usr/include/llvm/Config/Targets.def:37)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeSparcTarget
>>> referenced by Targets.def:38 (/usr/include/llvm/Config/Targets.def:38)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeSystemZTarget
>>> referenced by Targets.def:39 (/usr/include/llvm/Config/Targets.def:39)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeWebAssemblyTarget
>>> referenced by Targets.def:40 (/usr/include/llvm/Config/Targets.def:40)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeXCoreTarget
>>> referenced by Targets.def:42 (/usr/include/llvm/Config/Targets.def:42)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeAArch64TargetInfo
>>> referenced by Targets.def:26 (/usr/include/llvm/Config/Targets.def:26)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeARMTargetInfo
>>> referenced by Targets.def:28 (/usr/include/llvm/Config/Targets.def:28)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeAVRTargetInfo
>>> referenced by Targets.def:29 (/usr/include/llvm/Config/Targets.def:29)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeBPFTargetInfo
>>> referenced by Targets.def:30 (/usr/include/llvm/Config/Targets.def:30)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeHexagonTargetInfo
>>> referenced by Targets.def:31 (/usr/include/llvm/Config/Targets.def:31)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: undefined symbol: LLVMInitializeLanaiTargetInfo
>>> referenced by Targets.def:32 (/usr/include/llvm/Config/Targets.def:32)
>>> lto.tmp:((anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&))
ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)