summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorCory Bloor <Cordell.Bloor@amd.com>2022-08-22 04:39:09 -0600
committerGitHub <noreply@github.com>2022-08-22 12:39:09 +0200
commitdde6d00ab94040cd93c8c818368ecc0f67452022 (patch)
tree6d18896f01ef91accd26715534b739cb78d88c47 /var
parent4c64a0fab2946564e524abfb700998e1e203b215 (diff)
downloadspack-dde6d00ab94040cd93c8c818368ecc0f67452022.tar.gz
spack-dde6d00ab94040cd93c8c818368ecc0f67452022.tar.bz2
spack-dde6d00ab94040cd93c8c818368ecc0f67452022.tar.xz
spack-dde6d00ab94040cd93c8c818368ecc0f67452022.zip
hip@4.5.2: fix installation (#31416)
In a fast-moving project with as many forks as LLVM, it's difficult to accurately determine if a function exists just by checking the version number. The existing version check fails, for example, with llvm-amdgpu from ROCm 4.5. It is more robust to directly check if the function exists.
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/mesa/handle_missing_set_override_stack_alignment.patch32
-rw-r--r--var/spack/repos/builtin/packages/mesa/mesa_check_llvm_version_suffix.patch23
-rw-r--r--var/spack/repos/builtin/packages/mesa/package.py5
3 files changed, 36 insertions, 24 deletions
diff --git a/var/spack/repos/builtin/packages/mesa/handle_missing_set_override_stack_alignment.patch b/var/spack/repos/builtin/packages/mesa/handle_missing_set_override_stack_alignment.patch
new file mode 100644
index 0000000000..9e90f120bc
--- /dev/null
+++ b/var/spack/repos/builtin/packages/mesa/handle_missing_set_override_stack_alignment.patch
@@ -0,0 +1,32 @@
+diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+index be288ab02e2..378381b16ff 100644
+--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
++++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+@@ -616,11 +616,23 @@
+ return LLVMGetValueKind(v) == LLVMFunctionValueKind;
+ }
+
++// setOverrideStackAlignment if it exists, but SFINAE
++template <typename T>
++static auto try_set_override_stack_alignment(T* M, unsigned align)
++ -> decltype(M->setOverrideStackAlignment(align))
++{
++ M->setOverrideStackAlignment(align);
++}
++
++template <typename T>
++static void try_set_override_stack_alignment(T M, unsigned align)
++{
++// fallback for when setOverrideStackAlignment does not exist
++}
++
+ 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
++ try_set_override_stack_alignment(M, align);
+ }
+
diff --git a/var/spack/repos/builtin/packages/mesa/mesa_check_llvm_version_suffix.patch b/var/spack/repos/builtin/packages/mesa/mesa_check_llvm_version_suffix.patch
deleted file mode 100644
index 585ea6e1b3..0000000000
--- a/var/spack/repos/builtin/packages/mesa/mesa_check_llvm_version_suffix.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
-index be288ab02e2..378381b16ff 100644
---- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
-+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
-@@ -619,8 +619,15 @@ lp_is_function(LLVMValueRef v)
- 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);
-+// Check that the LLVM version is >= 13.0.0 "release"
-+// llvm::Module::setOverrideStackAlignment was added during the LLVM 13.0.0 development cycle and
-+// cannot be guarenteed to exist until the official release.
-+#if ( \
-+ LLVM_VERSION_MAJOR > 13 || \
-+ (LLVM_VERSION_MAJOR == 13 && \
-+ (LLVM_VERSION_MINOR > 0 || \
-+ (LLVM_VERSION_MINOR == 0 && (LLVM_VERSION_PATCH > 0 || !defined(LLVM_VERSION_SUFFIX))))))
-+ llvm::Module* M = llvm::unwrap(MRef);
-+ M->setOverrideStackAlignment(align);
- #endif
- }
diff --git a/var/spack/repos/builtin/packages/mesa/package.py b/var/spack/repos/builtin/packages/mesa/package.py
index 900478f6a7..e82bdc3764 100644
--- a/var/spack/repos/builtin/packages/mesa/package.py
+++ b/var/spack/repos/builtin/packages/mesa/package.py
@@ -143,7 +143,10 @@ class Mesa(MesonPackage):
when="@21.0.0:21.0.3",
)
- patch("mesa_check_llvm_version_suffix.patch", when="@21.2.3:")
+ # llvm::Module::setOverrideStackAlignment was added in LLVM 13.0.0, but forks based
+ # on development versions of LLVM 13 may or may not have it. Use SFINAE to detect
+ # the existence of the function and call it only if it is available.
+ patch("handle_missing_set_override_stack_alignment.patch", when="@21.2.3:")
# Explicitly use the llvm-config tool
def patch(self):