From 1c6ea067731ed158d54904a17dd467d22f83eb95 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Thu, 19 Aug 2021 10:42:10 -0400 Subject: [PATCH] Fixes for building against LLVM 13 Signed-off-by: Stephen Gallagher --- gallium-llvm13.patch | 113 +++++++++++++++++++++++++++++++++++++++++++ mesa.spec | 10 +++- 2 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 gallium-llvm13.patch diff --git a/gallium-llvm13.patch b/gallium-llvm13.patch new file mode 100644 index 0000000..6d168a2 --- /dev/null +++ b/gallium-llvm13.patch @@ -0,0 +1,113 @@ +From c1b4c64a28d9fc093229eab91a3a7fc4cb4fe29a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Kai=20Wasserb=C3=A4ch?= +Date: Thu, 22 Jul 2021 07:34:09 +0200 +Subject: [PATCH 1/2] gallivm: add new wrapper around + Module::setOverrideStackAlignment() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +We need it in the next commit to replace setting the stack alignment on +i386 with LLVM >= 13 through the TargetOption::StackAlignmentOverride, +which was removed in the upstream commit +. + +Unfortunately Module::setOverrideStackAlignment() is not available +through the C API and we need to wrap it ourselves. + +Signed-off-by: Kai Wasserbäch +Reference: mesa/mesa#4906 +Reviewed-by: Roland Scheidegger +Part-of: +--- + src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 9 +++++++++ + src/gallium/auxiliary/gallivm/lp_bld_misc.h | 3 +++ + 2 files changed, 12 insertions(+) + +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +index 44d07fe69c6..5f52ed08fae 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp ++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +@@ -615,3 +615,12 @@ lp_is_function(LLVMValueRef v) + { + return LLVMGetValueKind(v) == LLVMFunctionValueKind; + } ++ ++extern "C" void ++lp_set_module_stack_alignment_override(LLVMModuleRef MRef, unsigned align) ++{ ++#if LLVM_VERSION_MAJOR >= 13 ++ llvm::Module *M = llvm::unwrap(MRef); ++ M->setOverrideStackAlignment(align); ++#endif ++} +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h +index f2a15f19e47..fa0ce90162e 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h ++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.h +@@ -91,6 +91,9 @@ lp_is_function(LLVMValueRef v); + + void + lp_free_objcache(void *objcache); ++ ++void ++lp_set_module_stack_alignment_override(LLVMModuleRef M, unsigned align); + #ifdef __cplusplus + } + #endif +-- +GitLab + + +From 3a2d317b996f57647da23de7876142be4b9b71f3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Kai=20Wasserb=C3=A4ch?= +Date: Thu, 22 Jul 2021 07:42:12 +0200 +Subject: [PATCH 2/2] gallivm: fix FTBFS on i386 with LLVM >= 13, + StackAlignmentOverride is gone +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Use the newly added wrapper lp_set_module_stack_alignment_override() to +achieve the same end result. + +Signed-off-by: Kai Wasserbäch +Closes: mesa/mesa#4906 +Reviewed-by: Roland Scheidegger +Part-of: +--- + src/gallium/auxiliary/gallivm/lp_bld_init.c | 4 ++++ + src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 2 +- + 2 files changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c +index 8e5fe6f24dc..d2d049ace5e 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_init.c ++++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c +@@ -347,6 +347,10 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name, + if (!gallivm->module) + goto fail; + ++#if defined(PIPE_ARCH_X86) ++ lp_set_module_stack_alignment_override(gallivm->module, 4); ++#endif ++ + gallivm->builder = LLVMCreateBuilderInContext(gallivm->context); + if (!gallivm->builder) + goto fail; +diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +index 5f52ed08fae..be288ab02e2 100644 +--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp ++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +@@ -350,7 +350,7 @@ lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, + * friends for configuring code generation options, like stack alignment. + */ + TargetOptions options; +-#if defined(PIPE_ARCH_X86) ++#if defined(PIPE_ARCH_X86) && LLVM_VERSION_MAJOR < 13 + options.StackAlignmentOverride = 4; + #endif + +-- +GitLab + diff --git a/mesa.spec b/mesa.spec index 0246935..910f6a4 100644 --- a/mesa.spec +++ b/mesa.spec @@ -59,7 +59,7 @@ Name: mesa Summary: Mesa graphics libraries %global ver 21.2.0 Version: %{lua:ver = string.gsub(rpm.expand("%{ver}"), "-", "~"); print(ver)} -Release: 2%{?dist} +Release: 3%{?dist} License: MIT URL: http://www.mesa3d.org @@ -69,6 +69,11 @@ Source0: https://mesa.freedesktop.org/archive/%{name}-%{ver}.tar.xz # Fedora opts to ignore the optional part of clause 2 and treat that code as 2 clause BSD. Source1: Mesa-MLAA-License-Clarification-Email.txt + +# Backport of upstream patches from +# https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11940 +Patch0001: gallium-llvm13.patch + BuildRequires: meson >= 0.45 BuildRequires: gcc BuildRequires: gcc-c++ @@ -606,6 +611,9 @@ popd %files vulkan-devel %changelog +* Thu Aug 19 2021 Stephen Gallagher - 21.2.0-3 +- Fixes for building against LLVM 13 + * Thu Aug 05 2021 ValdikSS - 21.2.0-2 - Enable Crocus driver