summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLone_Wolf2023-03-21 14:48:24 +0100
committerLone_Wolf2023-03-21 14:48:24 +0100
commitd90aba69ee8439ad8719fb0c6d0b212be7c04bd4 (patch)
treef1e650bdab379cb2fe743c17b947df84ae01b364
parent68d65df8b7799881a75ed09345c1692075506b97 (diff)
downloadaur-d90aba69ee8439ad8719fb0c6d0b212be7c04bd4.tar.gz
apply patches to build with llvm17
-rw-r--r--.SRCINFO8
-rw-r--r--0001-ac-llvm-fix-build-with-LLVM-17.patch185
-rw-r--r--0002-gallivm-llvm17-deleted-includefiles.patch13
-rw-r--r--PKGBUILD19
4 files changed, 216 insertions, 9 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 015bbdcfb73f..04f0489513c1 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = lib32-mesa-minimal-git
pkgdesc = an open-source implementation of the OpenGL specification, git version
- pkgver = 23.1.0_devel.165928.3131c2fc7ad
+ pkgver = 23.1.0_devel.168504.c10a9372d6e
pkgrel = 1
url = https://www.mesa3d.org
arch = x86_64
@@ -55,11 +55,17 @@ pkgbase = lib32-mesa-minimal-git
source = mesa::git+https://gitlab.freedesktop.org/mesa/mesa.git
source = LICENSE
source = llvm32.native
+ source = 0001-ac-llvm-fix-build-with-LLVM-17.patch
+ source = 0002-gallivm-llvm17-deleted-includefiles.patch
md5sums = SKIP
md5sums = 5c65a0fe315dd347e09b1f2826a1df5a
md5sums = 6b4a19068a323d7f90a3d3cd315ed1f9
+ md5sums = 26f7e45bb2beec9cddcc1584473cd5f9
+ md5sums = 942f95c6f7e795abd9df755b43cf0239
sha512sums = SKIP
sha512sums = 25da77914dded10c1f432ebcbf29941124138824ceecaf1367b3deedafaecabc082d463abcfa3d15abff59f177491472b505bcb5ba0c4a51bb6b93b4721a23c2
sha512sums = c7dbb390ebde291c517a854fcbe5166c24e95206f768cc9458ca896b2253aabd6df12a7becf831998721b2d622d0c02afdd8d519e77dea8e1d6807b35f0166fe
+ sha512sums = 71ff8ac66810f010468eb1410eaadb2524da105dc0bf7c36e4c0572dbe758a2c962631c03a4849825cd0456873266096b6de39fb5ffc41c979c43b9c44c16ea5
+ sha512sums = ee81e9a1d23ff7265310da3231b7eebe1f6d49dd4c568781e2da0ac494e04ff074901cedc66e04c727eb120fad563db9693da509d69f738e3e2f108afc383c0a
pkgname = lib32-mesa-minimal-git
diff --git a/0001-ac-llvm-fix-build-with-LLVM-17.patch b/0001-ac-llvm-fix-build-with-LLVM-17.patch
new file mode 100644
index 000000000000..96a26d666f29
--- /dev/null
+++ b/0001-ac-llvm-fix-build-with-LLVM-17.patch
@@ -0,0 +1,185 @@
+From aeea383a0b1c4a812d38ae963134dc07a5165cff Mon Sep 17 00:00:00 2001
+From: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
+Date: Mon, 20 Mar 2023 10:26:11 +0100
+Subject: [PATCH] ac/llvm: fix build with LLVM 17
+
+This builds with LLVM 12 -> 17 and a running a simple app seems to work.
+
+I couldn't test LLVM 11 because meson fails with:
+
+ Looking for a fallback subproject for the dependency llvm (modules:
+ bitwriter, engine, mcdisassembler, mcjit, core, executionengine,
+ scalaropts, transformutils, instcombine, amdgpu, bitreader, ipo, native)
+
+Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/8297
+Cc: mesa-stable
+---
+ src/amd/llvm/ac_llvm_build.h | 2 --
+ src/amd/llvm/ac_llvm_helper.cpp | 50 ++++++++++++++++++++++++++++-----
+ src/amd/llvm/ac_llvm_util.c | 41 ---------------------------
+ src/amd/llvm/ac_llvm_util.h | 3 +-
+ 4 files changed, 45 insertions(+), 51 deletions(-)
+
+diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h
+index 197a30bb154..8a7f079912a 100644
+--- a/src/amd/llvm/ac_llvm_build.h
++++ b/src/amd/llvm/ac_llvm_build.h
+@@ -586,8 +586,6 @@ LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp
+ LLVMValueRef ac_build_atomic_cmp_xchg(struct ac_llvm_context *ctx, LLVMValueRef ptr,
+ LLVMValueRef cmp, LLVMValueRef val, const char *sync_scope);
+
+-void ac_add_sinking_pass(LLVMPassManagerRef PM);
+-
+ void ac_export_mrt_z(struct ac_llvm_context *ctx, LLVMValueRef depth, LLVMValueRef stencil,
+ LLVMValueRef samplemask, LLVMValueRef mrt0_alpha, bool is_last,
+ struct ac_export_args *args);
+diff --git a/src/amd/llvm/ac_llvm_helper.cpp b/src/amd/llvm/ac_llvm_helper.cpp
+index 7b0e7049486..9d831f37a65 100644
+--- a/src/amd/llvm/ac_llvm_helper.cpp
++++ b/src/amd/llvm/ac_llvm_helper.cpp
+@@ -32,7 +32,11 @@
+ #include <llvm/Support/CommandLine.h>
+ #include <llvm/Transforms/IPO.h>
+ #include <llvm/Transforms/Scalar.h>
+-
++#include <llvm/Transforms/Utils.h>
++#include <llvm/CodeGen/Passes.h>
++#include <llvm/Transforms/IPO/AlwaysInliner.h>
++#include <llvm/Transforms/InstCombine/InstCombine.h>
++#include <llvm/Transforms/IPO/SCCP.h>
+ #if LLVM_VERSION_MAJOR >= 15
+ #include "llvm/CodeGen/SelectionDAGNodes.h"
+ #endif
+@@ -292,9 +296,46 @@ bool ac_compile_module_to_elf(struct ac_compiler_passes *p, LLVMModuleRef module
+ return true;
+ }
+
+-void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr)
++LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_library_info,
++ bool check_ir)
+ {
++ LLVMPassManagerRef passmgr = LLVMCreatePassManager();
++ if (!passmgr)
++ return NULL;
++
++ if (target_library_info)
++ LLVMAddTargetLibraryInfo(target_library_info, passmgr);
++
++ if (check_ir)
++ unwrap(passmgr)->add(createMachineVerifierPass("mesa ir"));
++
++ unwrap(passmgr)->add(createAlwaysInlinerLegacyPass());
++
++ /* Normally, the pass manager runs all passes on one function before
++ * moving onto another. Adding a barrier no-op pass forces the pass
++ * manager to run the inliner on all functions first, which makes sure
++ * that the following passes are only run on the remaining non-inline
++ * function, so it removes useless work done on dead inline functions.
++ */
+ unwrap(passmgr)->add(createBarrierNoopPass());
++
++ /* This pass eliminates all loads and stores on alloca'd pointers. */
++ unwrap(passmgr)->add(createPromoteMemoryToRegisterPass());
++ #if LLVM_VERSION_MAJOR >= 16
++ unwrap(passmgr)->add(createSROAPass(true));
++ #else
++ unwrap(passmgr)->add(createSROAPass());
++ #endif
++ /* TODO: restore IPSCCP */
++ if (LLVM_VERSION_MAJOR >= 16)
++ unwrap(passmgr)->add(createLoopSinkPass());
++ /* TODO: restore IPSCCP */
++ unwrap(passmgr)->add(createLICMPass());
++ unwrap(passmgr)->add(createCFGSimplificationPass());
++ /* This is recommended by the instruction combining pass. */
++ unwrap(passmgr)->add(createEarlyCSEPass(true));
++ unwrap(passmgr)->add(createInstructionCombiningPass());
++ return passmgr;
+ }
+
+ LLVMValueRef ac_build_atomic_rmw(struct ac_llvm_context *ctx, LLVMAtomicRMWBinOp op,
+@@ -364,8 +405,3 @@ LLVMValueRef ac_build_atomic_cmp_xchg(struct ac_llvm_context *ctx, LLVMValueRef
+ AtomicOrdering::SequentiallyConsistent,
+ AtomicOrdering::SequentiallyConsistent, SSID));
+ }
+-
+-void ac_add_sinking_pass(LLVMPassManagerRef PM)
+-{
+- unwrap(PM)->add(createLoopSinkPass());
+-}
+diff --git a/src/amd/llvm/ac_llvm_util.c b/src/amd/llvm/ac_llvm_util.c
+index 8af0ef15b13..d1dec4d2853 100644
+--- a/src/amd/llvm/ac_llvm_util.c
++++ b/src/amd/llvm/ac_llvm_util.c
+@@ -31,9 +31,6 @@
+ #include "util/u_math.h"
+ #include <llvm-c/Core.h>
+ #include <llvm-c/Support.h>
+-#include <llvm-c/Transforms/IPO.h>
+-#include <llvm-c/Transforms/Scalar.h>
+-#include <llvm-c/Transforms/Utils.h>
+
+ #include <assert.h>
+ #include <stdio.h>
+@@ -219,44 +216,6 @@ static LLVMTargetMachineRef ac_create_target_machine(enum radeon_family family,
+ return tm;
+ }
+
+-static LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_library_info,
+- bool check_ir)
+-{
+- LLVMPassManagerRef passmgr = LLVMCreatePassManager();
+- if (!passmgr)
+- return NULL;
+-
+- if (target_library_info)
+- LLVMAddTargetLibraryInfo(target_library_info, passmgr);
+-
+- if (check_ir)
+- LLVMAddVerifierPass(passmgr);
+-
+- LLVMAddAlwaysInlinerPass(passmgr);
+-
+- /* Normally, the pass manager runs all passes on one function before
+- * moving onto another. Adding a barrier no-op pass forces the pass
+- * manager to run the inliner on all functions first, which makes sure
+- * that the following passes are only run on the remaining non-inline
+- * function, so it removes useless work done on dead inline functions.
+- */
+- ac_llvm_add_barrier_noop_pass(passmgr);
+-
+- /* This pass eliminates all loads and stores on alloca'd pointers. */
+- LLVMAddPromoteMemoryToRegisterPass(passmgr);
+- LLVMAddScalarReplAggregatesPass(passmgr);
+- LLVMAddIPSCCPPass(passmgr);
+- if (LLVM_VERSION_MAJOR >= 16)
+- ac_add_sinking_pass(passmgr);
+- LLVMAddLICMPass(passmgr);
+- LLVMAddAggressiveDCEPass(passmgr);
+- LLVMAddCFGSimplificationPass(passmgr);
+- /* This is recommended by the instruction combining pass. */
+- LLVMAddEarlyCSEMemSSAPass(passmgr);
+- LLVMAddInstructionCombiningPass(passmgr);
+- return passmgr;
+-}
+-
+ LLVMAttributeRef ac_get_llvm_attribute(LLVMContextRef ctx, const char *str)
+ {
+ return LLVMCreateEnumAttribute(ctx, LLVMGetEnumAttributeKindForName(str, strlen(str)), 0);
+diff --git a/src/amd/llvm/ac_llvm_util.h b/src/amd/llvm/ac_llvm_util.h
+index a22c3fabca6..6ff98c8a370 100644
+--- a/src/amd/llvm/ac_llvm_util.h
++++ b/src/amd/llvm/ac_llvm_util.h
+@@ -110,7 +110,8 @@ struct ac_compiler_passes *ac_create_llvm_passes(LLVMTargetMachineRef tm);
+ void ac_destroy_llvm_passes(struct ac_compiler_passes *p);
+ bool ac_compile_module_to_elf(struct ac_compiler_passes *p, LLVMModuleRef module,
+ char **pelf_buffer, size_t *pelf_size);
+-void ac_llvm_add_barrier_noop_pass(LLVMPassManagerRef passmgr);
++LLVMPassManagerRef ac_create_passmgr(LLVMTargetLibraryInfoRef target_library_info,
++ bool check_ir);
+
+ static inline bool ac_has_vec3_support(enum amd_gfx_level chip, bool use_format)
+ {
+--
+2.40.0
+
diff --git a/0002-gallivm-llvm17-deleted-includefiles.patch b/0002-gallivm-llvm17-deleted-includefiles.patch
new file mode 100644
index 000000000000..03d3856e5d8e
--- /dev/null
+++ b/0002-gallivm-llvm17-deleted-includefiles.patch
@@ -0,0 +1,13 @@
+diff --unified --recursive --text mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c mesa-new/src/gallium/auxiliary/gallivm/lp_bld_init.c
+--- mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c 2023-03-20 12:22:03.861856125 +0100
++++ mesa-new/src/gallium/auxiliary/gallivm/lp_bld_init.c 2023-03-20 13:07:34.218833163 +0100
+@@ -42,8 +42,7 @@
+
+ #include <llvm/Config/llvm-config.h>
+ #include <llvm-c/Analysis.h>
+-#include <llvm-c/Transforms/Scalar.h>
+-#if LLVM_VERSION_MAJOR >= 7
++#if LLVM_VERSION_MAJOR >= 7 && LLVM_VERSION_MAJOR <17
+ #include <llvm-c/Transforms/Utils.h>
+ #endif
+ #include <llvm-c/BitWriter.h>
diff --git a/PKGBUILD b/PKGBUILD
index 1e8948dfce27..96b3c3c8da4d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -12,7 +12,7 @@
pkgname=lib32-mesa-minimal-git
pkgdesc="an open-source implementation of the OpenGL specification, git version"
-pkgver=23.1.0_devel.165928.3131c2fc7ad
+pkgver=23.1.0_devel.168504.c10a9372d6e
pkgrel=1
arch=('x86_64')
makedepends=('python-mako' 'lib32-libxml2' 'lib32-libx11' 'xorgproto'
@@ -28,16 +28,20 @@ license=('custom')
source=('mesa::git+https://gitlab.freedesktop.org/mesa/mesa.git'
'LICENSE'
'llvm32.native'
+ '0001-ac-llvm-fix-build-with-LLVM-17.patch'
+ '0002-gallivm-llvm17-deleted-includefiles.patch'
)
md5sums=('SKIP'
'5c65a0fe315dd347e09b1f2826a1df5a'
'6b4a19068a323d7f90a3d3cd315ed1f9'
-)
+ '26f7e45bb2beec9cddcc1584473cd5f9'
+ '942f95c6f7e795abd9df755b43cf0239')
sha512sums=('SKIP'
'25da77914dded10c1f432ebcbf29941124138824ceecaf1367b3deedafaecabc082d463abcfa3d15abff59f177491472b505bcb5ba0c4a51bb6b93b4721a23c2'
'c7dbb390ebde291c517a854fcbe5166c24e95206f768cc9458ca896b2253aabd6df12a7becf831998721b2d622d0c02afdd8d519e77dea8e1d6807b35f0166fe'
-)
+ '71ff8ac66810f010468eb1410eaadb2524da105dc0bf7c36e4c0572dbe758a2c962631c03a4849825cd0456873266096b6de39fb5ffc41c979c43b9c44c16ea5'
+ 'ee81e9a1d23ff7265310da3231b7eebe1f6d49dd4c568781e2da0ac494e04ff074901cedc66e04c727eb120fad563db9693da509d69f738e3e2f108afc383c0a')
# NINJAFLAGS is an env var used to pass commandline options to ninja
# NOTE: It's your responbility to validate the value of $NINJAFLAGS. If unsure, don't set it.
@@ -49,11 +53,10 @@ pkgver() {
}
prepare() {
- # although removing _build folder in build() function feels more natural,
- # that interferes with the spirit of makepkg --noextract
- if [ -d _build ]; then
- rm -rf _build
- fi
+
+ patch --directory="mesa" --forward --strip=1 --input="${srcdir}"/0001-ac-llvm-fix-build-with-LLVM-17.patch
+ patch --directory="mesa" --forward --strip=1 --input="${srcdir}"/0002-gallivm-llvm17-deleted-includefiles.patch
+
}
build () {