From 38021502fb30d171b7863decb3063e819f10099c Mon Sep 17 00:00:00 2001 From: Thomas Devoogdt Date: Wed, 4 Feb 2026 13:36:09 +0100 Subject: [PATCH] package/mesa3d: fix host-mesa3d compilation with latest llvm installed on the host On Buildroot 2025.05.3, Meson's custom LLVM parser uses llvm-config with a default search path of /usr/bin, causing it to detect the host system's llvm-config (version 18.1.3) instead of the buildroot-compiled one. This forces all LLVM-related packages to match version 18.1.3, but since the host system lacks llvmspirvlib, the build fails. This patch forces Meson to use the buildroot-compiled llvm-config. On the master branch, the meson is somehow able to find the right llvm-config, so reproduction only seems to be possible if the host machine ships with a newer version as the one buildroot is using. llvm-config found: YES ([...]/output/host/bin/llvm-config) 21.1.8 Run-time dependency LLVM (modules: bitwriter, core, coverage, engine, executionengine, instcombine, irreader, libdriver, linker, lto, mcdisassembler, mcjit, native, option, scalaropts, target, transformutils, all-targets, coroutines, frontenddriver, frontendhlsl, lto, windowsdriver) found: YES 21.1.8 Note that LLVM_CONFIG is a CMake option, not a Meson one. This is because Meson has custom dependency resolution logic for LLVM (see https://mesonbuild.com/Dependencies.html#llvm). The EXTRA_BINARIES mechanism cannot be used here, as it only applies to cross-compilation scenarios, which does not apply to host-mesa3d builds. Reproduction (On BR2 tag: 2025.05.3): BR2_x86_64=y BR2_x86_atom=y BR2_TOOLCHAIN_EXTERNAL=y BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_X86_64_GLIBC_STABLE=y BR2_LINUX_KERNEL=y BR2_LINUX_KERNEL_CUSTOM_VERSION=y BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.1.24" BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/pc/linux.config" BR2_LINUX_KERNEL_INSTALL_TARGET=y BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y BR2_PACKAGE_MESA3D=y BR2_PACKAGE_MESA3D_LLVM=y BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_I915=y BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_IRIS=y BR2_PACKAGE_MESA3D_OPENGL_EGL=y BR2_PACKAGE_MESA3D_OPENGL_ES=y Fixes: llvm-config found: YES (/usr/bin/llvm-config-18) 18.1.3 Run-time dependency LLVM (modules: bitwriter, core, coverage, engine, executionengine, instcombine, irreader, libdriver, linker, lto, mcdisassembler, mcjit, native, option, scalaropts, target, transformutils, all-targets, coroutines, frontenddriver, frontendhlsl, lto, windowsdriver) found: YES 18.1.3 Dependency LLVMSPIRVLib found: NO. Found 15.0.0.0 but need: '>= 18.1' ; matched: '>= 15.0.0.0', '< 18.2' Run-time dependency llvmspirvlib found: NO (tried cmake) output/build/host-mesa3d-25.0.6/meson.build:1882:21: ERROR: Dependency lookup for LLVMSPIRVLib with method 'pkgconfig' failed: Invalid version, need 'LLVMSPIRVLib' ['>= 18.1'] found '15.0.0.0'. Signed-off-by: Thomas Devoogdt [Romain: - Update the commit title - Update commit log about this issue on master branch https://lore.kernel.org/buildroot/CACXRmJh1-5Cy92kF9TM5nDs_uB90WAe5iOGmNNL2E-cMhJE7GA@mail.gmail.com/ ] Signed-off-by: Romain Naour (cherry picked from commit eb0e63888bae4b79b20b9cfcfdf44cc256c532ff) Signed-off-by: Thomas Perale --- package/mesa3d/mesa3d.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/mesa3d/mesa3d.mk b/package/mesa3d/mesa3d.mk index b3fae9c0cf..d79b8609c5 100644 --- a/package/mesa3d/mesa3d.mk +++ b/package/mesa3d/mesa3d.mk @@ -292,6 +292,9 @@ ifeq ($(BR2_PACKAGE_MESA3D_VULKAN_DRIVER_IMAGINATION),y) HOST_MESA3D_TOOLS += imagination endif +HOST_MESA3D_CONF_ENV = \ + LLVM_CONFIG="$(HOST_DIR)/bin/llvm-config" + HOST_MESA3D_CONF_OPTS = \ -Dglvnd=disabled \ -Dgallium-drivers=$(subst $(space),$(comma),$(HOST_MESA3D_GALLIUM_DRIVERS-y)) \