summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLone_Wolf2023-03-21 13:49:58 +0100
committerLone_Wolf2023-03-21 13:49:58 +0100
commitb9d401948dca25c70070a057e0046556bb56d9ac (patch)
tree71ddfd9dd2ce5eebef8129c1c72c55284a96419d
parent939fe0083fd25693988d0017f1cd76eb05e48477 (diff)
downloadaur-b9d401948dca25c70070a057e0046556bb56d9ac.tar.gz
apply patches from https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22021 to allow building against llvm17
-rw-r--r--.SRCINFO10
-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, 222 insertions, 5 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 5333f94e0eb3..8f4ea8f379ab 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,6 +1,6 @@
pkgbase = mesa-minimal-git
pkgdesc = an open-source implementation of the OpenGL specification, stripped down git version
- pkgver = 23.1.0_devel.167082.22c1f4be8c1
+ pkgver = 23.1.0_devel.168501.957186102f9
pkgrel = 1
url = https://www.mesa3d.org
arch = x86_64
@@ -47,10 +47,16 @@ pkgbase = mesa-minimal-git
options = !emptydirs
source = mesa::git+https://gitlab.freedesktop.org/mesa/mesa.git
source = LICENSE
+ source = 0001-ac-llvm-fix-build-with-LLVM-17.patch
+ source = 0002-gallivm-llvm17-deleted-includefiles.patch
md5sums = SKIP
md5sums = 5c65a0fe315dd347e09b1f2826a1df5a
+ md5sums = 26f7e45bb2beec9cddcc1584473cd5f9
+ md5sums = 942f95c6f7e795abd9df755b43cf0239
sha512sums = SKIP
sha512sums = 25da77914dded10c1f432ebcbf29941124138824ceecaf1367b3deedafaecabc082d463abcfa3d15abff59f177491472b505bcb5ba0c4a51bb6b93b4721a23c2
+ sha512sums = 71ff8ac66810f010468eb1410eaadb2524da105dc0bf7c36e4c0572dbe758a2c962631c03a4849825cd0456873266096b6de39fb5ffc41c979c43b9c44c16ea5
+ sha512sums = ee81e9a1d23ff7265310da3231b7eebe1f6d49dd4c568781e2da0ac494e04ff074901cedc66e04c727eb120fad563db9693da509d69f738e3e2f108afc383c0a
pkgname = mesa-minimal-git
depends = libdrm
@@ -72,7 +78,7 @@ pkgname = rusticl-mesa-minimal-git
depends = libdrm
depends = spirv-tools-git
depends = libclc-minimal-git
- depends = mesa-minimal-git=23.1.0_devel.167082.22c1f4be8c1-1
+ depends = mesa-minimal-git=23.1.0_devel.168501.957186102f9-1
provides = opencl-mesa
provides = opencl-driver
conflicts = opencl-mesa
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 47be8c254302..fe6fd40c90c2 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -13,7 +13,7 @@
pkgbase=mesa-minimal-git
pkgname=('mesa-minimal-git' 'rusticl-mesa-minimal-git')
pkgdesc="an open-source implementation of the OpenGL specification, stripped down git version"
-pkgver=23.1.0_devel.167082.22c1f4be8c1
+pkgver=23.1.0_devel.168501.957186102f9
pkgrel=1
arch=('x86_64')
makedepends=('git' 'meson' 'ninja' 'libglvnd' 'python-mako' 'xorgproto' 'libxml2' 'libx11' 'libva' 'elfutils' 'libxrandr'
@@ -27,11 +27,17 @@ url="https://www.mesa3d.org"
license=('custom')
source=('mesa::git+https://gitlab.freedesktop.org/mesa/mesa.git'
'LICENSE'
+ '0001-ac-llvm-fix-build-with-LLVM-17.patch'
+ '0002-gallivm-llvm17-deleted-includefiles.patch'
)
md5sums=('SKIP'
- '5c65a0fe315dd347e09b1f2826a1df5a')
+ '5c65a0fe315dd347e09b1f2826a1df5a'
+ '26f7e45bb2beec9cddcc1584473cd5f9'
+ '942f95c6f7e795abd9df755b43cf0239')
sha512sums=('SKIP'
- '25da77914dded10c1f432ebcbf29941124138824ceecaf1367b3deedafaecabc082d463abcfa3d15abff59f177491472b505bcb5ba0c4a51bb6b93b4721a23c2')
+ '25da77914dded10c1f432ebcbf29941124138824ceecaf1367b3deedafaecabc082d463abcfa3d15abff59f177491472b505bcb5ba0c4a51bb6b93b4721a23c2'
+ '71ff8ac66810f010468eb1410eaadb2524da105dc0bf7c36e4c0572dbe758a2c962631c03a4849825cd0456873266096b6de39fb5ffc41c979c43b9c44c16ea5'
+ 'ee81e9a1d23ff7265310da3231b7eebe1f6d49dd4c568781e2da0ac494e04ff074901cedc66e04c727eb120fad563db9693da509d69f738e3e2f108afc383c0a')
options=(!emptydirs)
# ninja grabs all available cores and leaves almost nothing for other processes.
@@ -45,6 +51,13 @@ pkgver() {
echo ${_ver/-/_}.$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}
+prepare() {
+
+ 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 () {
meson setup mesa _build \