Skip to contentSkip to conversation

mesa-pvr_23.2.1: Fix build issues with llvm 18+

PATCH New Ryan Eatmon 1 participant 2 messages Nov 4, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 mesa-pvr_23.2.1: Fix build issues with llvm 18+

Backport two fixes from the latest mesa project to fix two builds issues related to newer llvm versions.

---
v2: Rework commit message since we need to add patches for mesa-pvr_22.3.5 too.

 ...allium-Fix-build-with-llvm-18-and-19.patch | 53 +++++++++++++++++++
 .../recipes-graphics/mesa/mesa-pvr_23.2.1.bb  |  1 +
 2 files changed, 54 insertions(+)
 create mode 100644 meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-23.2.1/0001-gallium-Fix-build-with-llvm-18-and-19.patch
meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-23.2.1/0001-gallium-Fix-build-with-llvm-18-and-19.patch new file +53 -0
new file mode 100644
index 00000000..ad5059f1
@@ -0,0 +1,53 @@
+From 6c5033bb01a3a1341d4db5007586a5f2e2727b0a Mon Sep 17 00:00:00 2001
+From: Ryan Eatmon <[email protected]>
+Date: Mon, 4 Nov 2024 13:37:29 -0600
+Subject: [PATCH] gallium: Fix build with llvm 18 and 19
+
+- CodeGenOpt::Level changed to CodeGenOoptLevel. [1]
+- llvm::sys::getHostCPUFeatures() now returns the features instead of
+modifying the passed in argument. [2]
+
+Upstream-Status: Backport [1][https://gitlab.freedesktop.org/mesa/mesa/-/commit/f79617fe804ea6524651ff1bc3a91098d3199179]
+Upstream-Status: Backport [2][https://gitlab.freedesktop.org/mesa/mesa/-/commit/fa9cd89a85b904615ebc11da609445b5b751e68d]
+
+Signed-off-by: Ryan Eatmon <[email protected]>
+---
+ src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 14 ++++++++++++--
+ 1 file changed, 12 insertions(+), 2 deletions(-)
+
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+index 5e7a30a6cc2..dbc777e3096 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+@@ -366,7 +366,11 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
+    builder.setEngineKind(EngineKind::JIT)
+           .setErrorStr(&Error)
+           .setTargetOptions(options)
++#if LLVM_VERSION_MAJOR >= 18
++          .setOptLevel((CodeGenOptLevel)OptLevel);
++#else
+           .setOptLevel((CodeGenOpt::Level)OptLevel);
++#endif
+ 
+ #if DETECT_OS_WINDOWS
+     /*
+@@ -394,8 +398,14 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
+     * which allows us to enable/disable code generation based
+     * on the results of cpuid on these architectures.
+     */
+-   llvm::StringMap<bool> features;
+-   llvm::sys::getHostCPUFeatures(features);
++   #if LLVM_VERSION_MAJOR >= 19
++      /* llvm-19+ returns StringMap from getHostCPUFeatures.
++      */
++      auto features = llvm::sys::getHostCPUFeatures();
++   #else
++      llvm::StringMap<bool> features;
++      llvm::sys::getHostCPUFeatures(features);
++   #endif
+ 
+    for (StringMapIterator<bool> f = features.begin();
+         f != features.end();
+-- 
+2.17.1
+
meta-ti-bsp/recipes-graphics/mesa/mesa-pvr_23.2.1.bb +1 -0
index 21134bc7..33af456d 100644
@@ -16,6 +16,7 @@ SRC_URI = " \
     file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
     file://0001-gallium-Fix-build-with-llvm-17.patch \
     file://0001-meson-Disable-cmake-dependency-detector-for-llvm.patch \
+    file://0001-gallium-Fix-build-with-llvm-18-and-19.patch \
 "
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.17.1
#1 lore raw

PATCH v2 2/2 mesa-pvr-22.3.5: Fix build issues with llvm 18+

Backport two fixes from the latest mesa project to fix two builds issues related to newer llvm versions.

---
 ...lude-of-Host-h-moved-to-TargetParser.patch | 65 +++++++++++++++++++
 ...allium-Fix-build-with-llvm-18-and-19.patch |  6 +-
 .../recipes-graphics/mesa/mesa-pvr_22.3.5.bb  |  2 +
 3 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100644 meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-22.3.5/0001-fix-gallivm-fix-LLVM-include-of-Host-h-moved-to-TargetParser.patch
 copy meta-ti-bsp/recipes-graphics/mesa/{mesa-pvr-23.2.1 => mesa-pvr-22.3.5}/0001-gallium-Fix-build-with-llvm-18-and-19.patch (92%)
meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-22.3.5/0001-fix-gallivm-fix-LLVM-include-of-Host-h-moved-to-TargetParser.patch new file +65 -0
new file mode 100644
index 00000000..7d4fe078
@@ -0,0 +1,65 @@
+From bb2db56ffec6e527d88751f75117ae690227cd6c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Kai=20Wasserb=C3=A4ch?= <[email protected]>
+Date: Sat, 11 Feb 2023 18:38:01 +0100
+Subject: [PATCH] fix: gallivm: fix LLVM #include of Host.h, moved to
+ TargetParser
+
+Upstream moved Host.h from Support to TargetParser in LLVM 17.
+
+This shouldn't lead to a FTBFS, since there is a forwarding include left
+behind. Sadly the added deprecation warning #pragma is invalid and thus
+causes a build failure right away. But since we would have to follow the
+move anyway in the future, just do it right away.
+
+Reference: https://github.com/llvm/llvm-project/commit/d768bf994f508d7eaf9541a568be3d71096febf5
+Reviewed-by: Bas Nieuwenhuizen <[email protected]>
+Closes: #8275
+Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21263>
+
+Upstream-Status: Backport [https://gitlab.freedesktop.org/mesa/mesa/-/commit/bb2db56ffec6e527d88751f75117ae690227cd6c]
+
+---
+ src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 7 ++++++-
+ src/gallium/auxiliary/gallivm/lp_bld_misc.cpp  | 4 +++-
+ 2 files changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+index 54bc5d5ada36c..f78f04f042be8 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
+@@ -35,9 +35,14 @@
+ #include <llvm-c/Disassembler.h>
+ #include <llvm/Support/raw_ostream.h>
+ #include <llvm/Support/Format.h>
+-#include <llvm/Support/Host.h>
+ #include <llvm/IR/Module.h>
+ 
++#if LLVM_VERSION_MAJOR >= 17
++#include <llvm/TargetParser/Host.h>
++#else
++#include <llvm/Support/Host.h>
++#endif
++
+ #include "util/u_math.h"
+ #include "util/u_debug.h"
+ 
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+index 334c13530394b..5e7a30a6cc2e3 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+@@ -60,7 +60,11 @@
+ #include <llvm/Analysis/TargetLibraryInfo.h>
+ #include <llvm/ExecutionEngine/SectionMemoryManager.h>
+ #include <llvm/Support/CommandLine.h>
++#if LLVM_VERSION_MAJOR >= 17
++#include <llvm/TargetParser/Host.h>
++#else
+ #include <llvm/Support/Host.h>
++#endif
+ #include <llvm/Support/PrettyStackTrace.h>
+ #include <llvm/ExecutionEngine/ObjectCache.h>
+ #include <llvm/Support/TargetSelect.h>
+ 
+-- 
+GitLab
+
meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-22.3.5/0001-gallium-Fix-build-with-llvm-18-and-19.patch renamed from meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-23.2.1/0001-gallium-Fix-build-with-llvm-18-and-19.patch +3 -3
similarity index 92%
copy from meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-23.2.1/0001-gallium-Fix-build-with-llvm-18-and-19.patch
copy to meta-ti-bsp/recipes-graphics/mesa/mesa-pvr-22.3.5/0001-gallium-Fix-build-with-llvm-18-and-19.patch
index ad5059f1..37888c34 100644
@@ -19,7 +19,7 @@ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxilia
 index 5e7a30a6cc2..dbc777e3096 100644
 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
 +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
-@@ -366,7 +366,11 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
+@@ -368,7 +368,11 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
     builder.setEngineKind(EngineKind::JIT)
            .setErrorStr(&Error)
            .setTargetOptions(options)
@@ -29,9 +29,9 @@ index 5e7a30a6cc2..dbc777e3096 100644
            .setOptLevel((CodeGenOpt::Level)OptLevel);
 +#endif
  
- #if DETECT_OS_WINDOWS
+ #ifdef _WIN32
      /*
-@@ -394,8 +398,14 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
+@@ -392,8 +396,14 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT,
      * which allows us to enable/disable code generation based
      * on the results of cpuid on these architectures.
      */
meta-ti-bsp/recipes-graphics/mesa/mesa-pvr_22.3.5.bb +2 -0
index c93d01f9..bdc9ce16 100644
@@ -19,6 +19,8 @@ SRC_URI = " \
     file://0001-freedreno-pm4-Use-unsigned-instead-of-uint-to-fix-mu.patch \
     file://0001-gallium-Fix-build-with-llvm-17.patch \
     file://0001-fix-gallivm-limit-usage-of-LLVMContextSetOpaquePoint.patch \
+    file://0001-fix-gallivm-fix-LLVM-include-of-Host-h-moved-to-TargetParser.patch \
+    file://0001-gallium-Fix-build-with-llvm-18-and-19.patch \
 "
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.17.1