Skip to content

Commit

Permalink
mesa: fix dependencies and always prefer LLVM subproject
Browse files Browse the repository at this point in the history
Make sure build dependency to mesa/host is set for x86 and x86/64 builds
and make sure to always prefer LLVM subproject to avoid picking up LLVM
from the build host (which may not match SPIR-V converter tool version).

Signed-off-by: Daniel Golle <[email protected]>
  • Loading branch information
dangowrt committed Dec 7, 2024
1 parent a3eafcf commit f243fea
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 12 deletions.
17 changes: 6 additions & 11 deletions libs/mesa/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ PKG_MAINTAINER:=Daniel Golle <[email protected]>
PKG_LICENSE:=BSD-3-Clause

PKG_INSTALL:=1
PKG_BUILD_DEPENDS:=glslang/host python3/host libva
HOST_BUILD_DEPENDS:=python3/host spirv-tools/host

# arc, powerpc and powerpc64 LLVM builds are currently broken, but powerpc{,64} would support JIT in theory
LLVM_SUPPORTED:=(aarch64||arm||i386||i686||loongarch64||mips||mipsel||mips64||mips64el||riscv64||x86_64)

PKG_BUILD_DEPENDS:=glslang/host python3/host libva (x86_64||i386||i686):mesa/host $(LLVM_SUPPORTED):llvm
HOST_BUILD_DEPENDS:=python3/host spirv-tools/host llvm

PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_libosmesa \
Expand All @@ -30,21 +34,12 @@ PYTHON3_PKG_BUILD:=0
MESON_USE_STAGING_PYTHON:=1
HOST_PYTHON3_PACKAGE_BUILD_DEPENDS:=./host-pip-requirements.txt

LLVM_SUPPORTED:=(aarch64||arm||i386||i686||loongarch64||mips||mipsel||mips64||mips64el||riscv64||x86_64)
# arc, powerpc and powerpc64 LLVM builds are currently broken, but powerpc{,64} would support JIT in theory

ifneq ($(CONFIG_aarch64)$(CONFIG_arm)$(CONFIG_i386)$(CONFIG_i686)$(CONFIG_loongarch64)$(CONFIG_mips)$(CONFIG_mipsel)$(CONFIG_mips64)$(CONFIG_mips64el)$(CONFIG_riscv64)$(CONFIG_x86_64),)
PKG_BUILD_DEPENDS+=llvm
HOST_BUILD_DEPENDS+=llvm
MESA_USE_LLVM:=1
else
MESA_USE_LLVM:=
endif

ifneq ($(CONFIG_x86_64)$(CONFIG_i386)$(CONFIG_i686),)
PKG_BUILD_DEPENDS+=mesa/host
endif

include $(TOPDIR)/feeds/packages/lang/rust/rust-values.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/host-build.mk
Expand Down
44 changes: 43 additions & 1 deletion libs/mesa/patches/100-use-llvm-subproject-vars.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
--- a/meson.build
+++ b/meson.build
@@ -1856,7 +1856,11 @@ endif
@@ -1743,21 +1743,26 @@ _llvm = get_option('llvm')
dep_llvm = null_dep
with_llvm = false
if _llvm.allowed()
- dep_llvm = dependency(
- 'llvm',
- method : host_machine.system() == 'windows' ? 'auto' : 'config-tool',
- version : _llvm_version,
- modules : llvm_modules,
- optional_modules : llvm_optional_modules,
- required : (
- with_amd_vk or with_gallium_radeonsi or with_gallium_clover or with_clc
- or _llvm.enabled()
- ),
- static : not _shared_llvm,
- fallback : ['llvm', 'dep_llvm'],
- include_type : 'system',
- )
- with_llvm = dep_llvm.found()
+ llvm_proj = subproject('llvm')
+ if llvm_proj
+ dep_llvm = llvm_proj.get_variable('dep_llvm')
+ with_llvm = true
+ else
+ dep_llvm = dependency(
+ 'llvm',
+ method : host_machine.system() == 'windows' ? 'auto' : 'config-tool',
+ version : _llvm_version,
+ modules : llvm_modules,
+ optional_modules : llvm_optional_modules,
+ required : (
+ with_amd_vk or with_gallium_radeonsi or with_gallium_clover or with_clc
+ or _llvm.enabled()
+ ),
+ static : not _shared_llvm,
+ fallback : ['llvm', 'dep_llvm'],
+ include_type : 'system',
+ )
+ endif
endif
if with_llvm
pre_args += '-DMESA_LLVM_VERSION_STRING="@0@"'.format(dep_llvm.version())
@@ -1856,7 +1861,11 @@ endif

dep_clang = null_dep
if with_clc or with_gallium_clover
Expand Down

0 comments on commit f243fea

Please sign in to comment.