Regression with -Dshared-llvm=disabled: clover has undefined references to LLVMInitializeAArch64Target, etc.
System information
- OS: Debian testing/unstable derivative
- Mesa version: 21.2.4 (based on Debian package 21.2.4-1)
Describe the issue
While building a modified version of Debian's Mesa packaging with -Dshared-llvm=disabled
, I encountered a build failure:
[ 162s] cd build && LC_ALL=C.UTF-8 meson .. --wrap-mode=nodownload --buildtype=plain --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=lib/x86_64-linux-gnu -Ddri-drivers=\['r100','r200','nouveau','i915','i965'\] -Ddri-drivers-path=/usr/lib/x86_64-linux-gnu/dri -Ddri-search-path=/usr/lib/x86_64-linux-gnu/dri:\\\$\${ORIGIN}/dri:/usr/lib/dri -Dvulkan-drivers=\['amd','swrast','intel'\] -Dglvnd=true -Dshared-glapi=enabled -Dgallium-xvmc=disabled -Dgallium-omx=disabled -Db_ndebug=true -Dbuild-tests=true -Dshared-llvm=disabled -Dglx-direct=true -Dgbm=enabled -Ddri3=enabled "-Dplatforms=x11 ,wayland" -Dgallium-extra-hud=true -Dgallium-vdpau=enabled -Dlmsensors=enabled -Dgallium-xa=enabled -Dllvm=enabled -Dgallium-opencl=icd -Dgallium-nine=true -Dgallium-va=enabled -Dgallium-drivers=\['swrast','r300','r600','nouveau','virgl','svga','d3d12','iris','radeonsi','zink'\] -Dgles1=disabled -Dgles2=enabled -Dosmesa=true -Dvalgrind=enabled "-Dvulkan-layers=device-select, overlay"
...
[ 166s] Did not find CMake 'cmake'
[ 166s] Found CMake: NO
...
[ 166s] llvm-config found: YES (/usr/lib/llvm-12/bin/llvm-config) 12.0.1
[ 166s] Run-time dependency LLVM (modules: amdgpu, asmparser, bitreader, bitwriter, core, coverage, engine, executionengine, instcombine, instrumentation, ipo, irreader, linker, lto, mcdisassembler, mcjit, native, objcarcopts, option, profiledata, scalaropts, transformutils, coroutines, frontendopenmp) found: YES 12.0.1
...
[ 2298s] c++ -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 -Wl,-z,relro -g -O2 -ffile-prefix-map=/usr/src/packages/BUILD=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-rpath,/usr/lib/llvm-12/lib -Wl,-rpath-link,/usr/lib/llvm-12/lib 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 /usr/src/packages/BUILD/src/gallium/targets/opencl/opencl.sym /usr/lib/x86_64-linux-gnu/libz.so -pthread -lm -ldl /usr/lib/x86_64-linux-gnu/libelf.so /usr/lib/llvm-12/lib/libclang-cpp.so /usr/lib/x86_64-linux-gnu/libdrm.so /usr/lib/x86_64-linux-gnu/libexpat.so /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/libzstd.so -lrt -lpthread /usr/lib/x86_64-linux-gnu/libz3.so -L/usr/lib/llvm-12/lib -lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMCFGuard -lLLVMX86Desc -lLLVMX86Info -lLLVMMCJIT -lLLVMLTO -lLLVMExtensions -lPolly -lPollyISL -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCoverage -lLLVMAMDGPUDisassembler -lLLVMMCDisassembler -lLLVMAMDGPUAsmParser -lLLVMAMDGPUCodeGen -lLLVMMIRParser -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMPasses -lLLVMObjCARCOpts -lLLVMHelloNew -lLLVMCoroutines -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMFrontendOpenMP -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lz -ltinfo -lxml2 -lsensors -L/usr/lib/llvm-12/lib -lLLVMOption -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMCFGuard -lLLVMX86Desc -lLLVMX86Info -lLLVMMCJIT -lLLVMLTO -lLLVMExtensions -lPolly -lPollyISL -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCoverage -lLLVMAMDGPUDisassembler -lLLVMMCDisassembler -lLLVMAMDGPUAsmParser -lLLVMAMDGPUCodeGen -lLLVMMIRParser -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAMDGPUDesc -lLLVMAMDGPUUtils -lLLVMAMDGPUInfo -lLLVMPasses -lLLVMObjCARCOpts -lLLVMHelloNew -lLLVMCoroutines -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMFrontendOpenMP -lLLVMAsmPrinter -lLLVMDebugInfoDWARF -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMTextAPI -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMCore -lLLVMRemarks -lLLVMBitstreamReader -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lz -ltinfo -lxml2 -Wl,--end-group
[ 2298s] /usr/bin/ld: src/gallium/frontends/clover/libclllvm.a(llvm_invocation.cpp.o): in function `(anonymous namespace)::create_context(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)':
[ 2298s] /usr/include/llvm-12/llvm/Config/Targets.def:26: undefined reference to `LLVMInitializeAArch64Target'
[ 2298s] /usr/bin/ld: src/gallium/frontends/clover/libclllvm.a(llvm_invocation.cpp.o): in function `LLVMInitializeAllTargets':
[ 2298s] /usr/include/llvm-12/llvm/Config/Targets.def:28: undefined reference to `LLVMInitializeARMTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:29: undefined reference to `LLVMInitializeAVRTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:30: undefined reference to `LLVMInitializeBPFTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:31: undefined reference to `LLVMInitializeHexagonTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:32: undefined reference to `LLVMInitializeLanaiTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:33: undefined reference to `LLVMInitializeMipsTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:34: undefined reference to `LLVMInitializeMSP430Target'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:35: undefined reference to `LLVMInitializeNVPTXTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:36: undefined reference to `LLVMInitializePowerPCTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:37: undefined reference to `LLVMInitializeRISCVTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:38: undefined reference to `LLVMInitializeSparcTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:39: undefined reference to `LLVMInitializeSystemZTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:40: undefined reference to `LLVMInitializeWebAssemblyTarget'
[ 2298s] /usr/bin/ld: /usr/include/llvm-12/llvm/Config/Targets.def:42: undefined reference to `LLVMInitializeXCoreTarget'
Regression
This seems to be a regression since 20.3.5, where a similar change worked as I had expected.
As far as I can tell, this might have been triggered by commit 80817b6e "meson: Adjust Clover's required LLVM modules" removing all-targets
from the list of modules that Mesa checks for. src/gallium/frontends/clover/llvm/invocation.cpp
calls LLVMInitializeAllTargets()
which wants to be able to find LLVMInitializeARMTarget
, LLVMInitializeAVRTarget
and so on.
Additional information
In my build chroot, Meson is locating LLVM libraries via llvm-config-12
. I tried adding a build-dependency on cmake
so that Meson would locate LLVM libraries via CMake metadata, but that failed in the same way.
/cc @xexaxo