Skip to contentSkip to conversation

mesa: Fix native build on hosts with llvm-dev installed

PATCH Superseded Khem Raj 2 participants 3 messages Sep 28, 2023 – Sep 29, 2023 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 mesa: Fix native build on hosts with llvm-dev installed

This issue is always there, it just shows up with newer LLVM since symbol mismatches are being found otherwise it was happily linking with host libLLVM.so silently.

---
 ...e-cmake-dependency-detector-for-llvm.patch | 47 +++++++++++++++++++
 meta/recipes-graphics/mesa/mesa.inc           |  1 +
 2 files changed, 48 insertions(+)
 create mode 100644 meta/recipes-graphics/mesa/files/0001-meson-Disable-cmake-dependency-detector-for-llvm.patch
meta/recipes-graphics/mesa/files/0001-meson-Disable-cmake-dependency-detector-for-llvm.patch new file +47 -0
new file mode 100644
index 00000000000..3a836ab4821
@@ -0,0 +1,47 @@
+From 00d41cd5aa3f4b494dc276c9b4ccdc096310c91f Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Thu, 28 Sep 2023 15:34:22 -0700
+Subject: [PATCH] meson: Disable cmake dependency detector for llvm
+
+meson dependency auto dependency detection uses cmake and then
+config-tool to process dependencies, in mesa the logic to detect llvm is
+using auto detection which means if it finds cmake then it will try to
+use cmake method. Cmake method works ok except a case when llvm-dev
+package is installed on the build host then it generates its own
+native.meson file and ignores OE supplied meson.native file which has
+correct llvm-config tool specified which is pointing to llvm-config from
+native sysroot. The generated meson.native file points to one found in
+/usr/bin and there onwards detector finds native install of llvm and
+configures that into building native mesa package.
+
+Since cmake detector does not always work, disable it by default and use
+config-tool which works in all cases. This is suggested in below issues
+too
+
+A similar issue is open in meson upstream [1] and mesa [2]
+
+[1] https://github.com/mesonbuild/meson/issues/10483
+[2] https://gitlab.freedesktop.org/mesa/mesa/-/issues/6738
+
+Upstream-Status: Inappropriate [Cross-compile specific]
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ meson.build | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/meson.build b/meson.build
+index 00a6953..05815ec 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1659,6 +1659,7 @@ with_llvm = false
+ if _llvm.allowed()
+   dep_llvm = dependency(
+     'llvm',
++    method : 'config-tool',
+     version : _llvm_version,
+     modules : llvm_modules,
+     optional_modules : llvm_optional_modules,
+-- 
+2.42.0
+
meta/recipes-graphics/mesa/mesa.inc +1 -0
index 559d445ae5e..4e824500dd0 100644
@@ -19,6 +19,7 @@ SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \
            file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
            file://0001-gallium-Fix-build-with-llvm-17.patch \
            file://0001-intel-Allow-using-intel_clc-from-the-system.patch \
+           file://0001-meson-Disable-cmake-dependency-detector-for-llvm.patch \
            "
 
 SRC_URI[sha256sum] = "45434ff91a709844130a3174d9c0ef39c6b50725b2bb0c13e736f36134db14ad"
Signature · 1 line
2.42.0
author
#1 lore raw

PATCH 2/2 mesa: Simplify llvm-17 patch

llvm-17 support patch had redundant checks for llvm-17, Simplify them as submitted in v3 upstream

---
 .../mesa/files/0001-gallium-Fix-build-with-llvm-17.patch   | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
meta/recipes-graphics/mesa/files/0001-gallium-Fix-build-with-llvm-17.patch +2 -5
index 0ca7a22b45b..165708145a7 100644
@@ -15,7 +15,7 @@ Signed-off-by: Khem Raj <[email protected]>
 
 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
-@@ -42,19 +42,23 @@
+@@ -42,8 +42,10 @@
  
  #include <llvm/Config/llvm-config.h>
  #include <llvm-c/Analysis.h>
@@ -27,10 +27,7 @@ Signed-off-by: Khem Raj <[email protected]>
  #include <llvm-c/Transforms/Utils.h>
  #endif
  #include <llvm-c/BitWriter.h>
- #if GALLIVM_USE_NEW_PASS == 1
- #include <llvm-c/Transforms/PassBuilder.h>
--#elif GALLIVM_HAVE_CORO == 1
-+#elif GALLIVM_HAVE_CORO == 1 && LLVM_VERSION_MAJOR < 17
+@@ -53,8 +55,10 @@
  #if LLVM_VERSION_MAJOR <= 8 && (DETECT_ARCH_AARCH64 || DETECT_ARCH_ARM || DETECT_ARCH_S390 || DETECT_ARCH_MIPS64)
  #include <llvm-c/Transforms/IPO.h>
  #endif
Signature · 1 line
2.42.0
#2 lore raw
In reply to Khem Raj

2023. 09. 29. 1:01 keltezéssel, Khem Raj írta:

Quoted 31 lines

This issue is always there, it just shows up with newer LLVM since symbol mismatches are being found otherwise it was happily linking with host libLLVM.so silently.

---
  ...e-cmake-dependency-detector-for-llvm.patch | 47 +++++++++++++++++++
  meta/recipes-graphics/mesa/mesa.inc           |  1 +
  2 files changed, 48 insertions(+)

create mode 100644 meta/recipes-graphics/mesa/files/0001-meson-Disable-cmake-dependency-detector-for-llvm.patch

meta/recipes-graphics/mesa/files/0001-meson-Disable-cmake-dependency-detector-for-llvm.patch new file +14 -0
new file mode 100644
index 00000000000..3a836ab4821
@@ -0,0 +1,47 @@
+From 00d41cd5aa3f4b494dc276c9b4ccdc096310c91f Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Thu, 28 Sep 2023 15:34:22 -0700
+Subject: [PATCH] meson: Disable cmake dependency detector for llvm
+
+meson dependency auto dependency detection uses cmake and then
+config-tool to process dependencies, in mesa the logic to detect llvm is
+using auto detection which means if it finds cmake then it will try to
+use cmake method. Cmake method works ok except a case when llvm-dev
+package is installed on the build host then it generates its own
+native.meson file and ignores OE supplied meson.native file which has
+correct llvm-config tool specified which is pointing to llvm-config from
+native sysroot. The generated meson.native file points to one found in
+/usr/bin and there onwards detector finds native install of llvm and

meta/recipes-graphics/mesa/files/0001-meson-Disable-cmake-dependency-detector-for-llvm.patch line 24

Quoted 10 lines
meta/recipes-graphics/mesa/files/0001-meson-Disable-cmake-dependency-detector-for-llvm.patch new file +10 -0
+configures that into building native mesa package.
+
+Since cmake detector does not always work, disable it by default and use
+config-tool which works in all cases. This is suggested in below issues
+too
+
+A similar issue is open in meson upstream [1] and mesa [2]
+
+[1] https://github.com/mesonbuild/meson/issues/10483
+[2] https://gitlab.freedesktop.org/mesa/mesa/-/issues/6738

https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25438

Quoted 44 lines
meta/recipes-graphics/mesa/files/0001-meson-Disable-cmake-dependency-detector-for-llvm.patch new file +23 -0
+
+Upstream-Status: Inappropriate [Cross-compile specific]
+
+Signed-off-by: Khem Raj <[email protected]>
+---
+ meson.build | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/meson.build b/meson.build
+index 00a6953..05815ec 100644
+--- a/meson.build
++++ b/meson.build
+@@ -1659,6 +1659,7 @@ with_llvm = false
+ if _llvm.allowed()
+   dep_llvm = dependency(
+     'llvm',
++    method : 'config-tool',
+     version : _llvm_version,
+     modules : llvm_modules,
+     optional_modules : llvm_optional_modules,
+--
+2.42.0
+
meta/recipes-graphics/mesa/mesa.inc +1 -1
index 559d445ae5e..4e824500dd0 100644
@@ -19,6 +19,7 @@ SRC_URI = "https://mesa.freedesktop.org/archive/mesa-${PV}.tar.xz \
             file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
             file://0001-gallium-Fix-build-with-llvm-17.patch \
             file://0001-intel-Allow-using-intel_clc-from-the-system.patch \
+           file://0001-meson-Disable-cmake-dependency-detector-for-llvm.patch \
             "
 
  SRC_URI[sha256sum] = "45434ff91a709844130a3174d9c0ef39c6b50725b2bb0c13e736f36134db14ad"
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#188386): https://lists.openembedded.org/g/openembedded-core/message/188386
Mute This Topic: https://lists.openembedded.org/mt/101648329/3617728
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-