summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--var/spack/repos/builtin/packages/llvm-amdgpu/llvm-version-suffix-macro.patch14
-rw-r--r--var/spack/repos/builtin/packages/llvm-amdgpu/package.py20
-rw-r--r--var/spack/repos/builtin/packages/llvm/llvm-version-suffix-macro.patch14
-rw-r--r--var/spack/repos/builtin/packages/llvm/package.py4
-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.py11
-rw-r--r--var/spack/repos/builtin/packages/mesa18/package.py6
7 files changed, 81 insertions, 11 deletions
diff --git a/var/spack/repos/builtin/packages/llvm-amdgpu/llvm-version-suffix-macro.patch b/var/spack/repos/builtin/packages/llvm-amdgpu/llvm-version-suffix-macro.patch
new file mode 100644
index 0000000000..62e9684386
--- /dev/null
+++ b/var/spack/repos/builtin/packages/llvm-amdgpu/llvm-version-suffix-macro.patch
@@ -0,0 +1,14 @@
+diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake
+index 4493bb65d444..e2b3c61b3c33 100644
+--- a/llvm/include/llvm/Config/llvm-config.h.cmake
++++ b/llvm/include/llvm/Config/llvm-config.h.cmake
+@@ -74,6 +74,9 @@
+ /* Patch version of the LLVM API */
+ #define LLVM_VERSION_PATCH ${LLVM_VERSION_PATCH}
+
++/* LLVM version suffix */
++#cmakedefine LLVM_VERSION_SUFFIX "${LLVM_VERSION_SUFFIX}"
++
+ /* LLVM version string */
+ #define LLVM_VERSION_STRING "${PACKAGE_VERSION}"
+
diff --git a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py
index 06abe900e1..10893376ad 100644
--- a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py
+++ b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py
@@ -38,10 +38,15 @@ class LlvmAmdgpu(CMakePackage):
variant('rocm-device-libs', default=True, description='Build ROCm device libs as external LLVM project instead of a standalone spack package.')
variant('openmp', default=True, description='Enable OpenMP')
variant(
- "llvm_dylib",
+ 'llvm_dylib',
default=False,
- description="Build LLVM shared library, containing all "
- "components in a single shared library",
+ description='Build LLVM shared library, containing all '
+ 'components in a single shared library',
+ )
+ variant(
+ 'link_llvm_dylib',
+ default=False,
+ description='Link LLVM tools against the LLVM shared library',
)
provides('libllvm@11', when='@3.5:3.8')
@@ -67,6 +72,10 @@ class LlvmAmdgpu(CMakePackage):
# This is already fixed in upstream but not in 4.2.0 rocm release
patch('fix-spack-detection-4.2.0.patch', when='@4.2.0:')
+ # Add LLVM_VERSION_SUFFIX
+ # https://reviews.llvm.org/D115818
+ patch('llvm-version-suffix-macro.patch', when='@:4.3.2')
+
conflicts('^cmake@3.19.0')
root_cmakelists_dir = 'llvm'
@@ -145,7 +154,10 @@ class LlvmAmdgpu(CMakePackage):
])
if '+llvm_dylib' in self.spec:
- cmake_args.append("-DLLVM_BUILD_LLVM_DYLIB:Bool=ON")
+ args.append("-DLLVM_BUILD_LLVM_DYLIB:Bool=ON")
+
+ if '+link_llvm_dylib' in self.spec:
+ args.append("-DLLVM_LINK_LLVM_DYLIB:Bool=ON")
# Get the GCC prefix for LLVM.
if self.compiler.name == "gcc":
diff --git a/var/spack/repos/builtin/packages/llvm/llvm-version-suffix-macro.patch b/var/spack/repos/builtin/packages/llvm/llvm-version-suffix-macro.patch
new file mode 100644
index 0000000000..62e9684386
--- /dev/null
+++ b/var/spack/repos/builtin/packages/llvm/llvm-version-suffix-macro.patch
@@ -0,0 +1,14 @@
+diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake
+index 4493bb65d444..e2b3c61b3c33 100644
+--- a/llvm/include/llvm/Config/llvm-config.h.cmake
++++ b/llvm/include/llvm/Config/llvm-config.h.cmake
+@@ -74,6 +74,9 @@
+ /* Patch version of the LLVM API */
+ #define LLVM_VERSION_PATCH ${LLVM_VERSION_PATCH}
+
++/* LLVM version suffix */
++#cmakedefine LLVM_VERSION_SUFFIX "${LLVM_VERSION_SUFFIX}"
++
+ /* LLVM version string */
+ #define LLVM_VERSION_STRING "${PACKAGE_VERSION}"
+
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
index 74bc3addcc..78b732519f 100644
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -342,6 +342,10 @@ class Llvm(CMakePackage, CudaPackage):
patch('no_cyclades.patch', when='@10:12.0.0')
patch('no_cyclades9.patch', when='@6:9')
+ # Add LLVM_VERSION_SUFFIX
+ # https://reviews.llvm.org/D115818
+ patch('llvm-version-suffix-macro.patch', when='@:13.0.0')
+
# The functions and attributes below implement external package
# detection for LLVM. See:
#
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
new file mode 100644
index 0000000000..585ea6e1b3
--- /dev/null
+++ b/var/spack/repos/builtin/packages/mesa/mesa_check_llvm_version_suffix.patch
@@ -0,0 +1,23 @@
+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 31068fc5ce..f935543f2f 100644
--- a/var/spack/repos/builtin/packages/mesa/package.py
+++ b/var/spack/repos/builtin/packages/mesa/package.py
@@ -80,7 +80,7 @@ class Mesa(MesonPackage):
provides('osmesa', when='+osmesa')
# Variant dependencies
- depends_on('llvm@6:12', when='+llvm')
+ depends_on('libllvm@6:', when='+llvm')
depends_on('libx11', when='+glx')
depends_on('libxcb', when='+glx')
depends_on('libxext', when='+glx')
@@ -106,6 +106,8 @@ class Mesa(MesonPackage):
# requires native to be added to llvm_modules when using gallium swrast
patch('https://cgit.freedesktop.org/mesa/mesa/patch/meson.build?id=054dd668a69acc70d47c73abe4646e96a1f23577', sha256='36096a178070e40217945e12d542dfe80016cb897284a01114d616656c577d73', when='@21.0.0:21.0.3')
+ patch('mesa_check_llvm_version_suffix.patch', when='@21.2.3:')
+
# 'auto' needed when shared llvm is built
@when('^llvm~shared_libs')
def patch(self):
@@ -175,18 +177,19 @@ class Mesa(MesonPackage):
if '+llvm' in spec:
# Fix builds on hosts where /usr/bin/llvm-config-* is found and provides an
- # incompatible version. Ensure that the llvm-config of spec['llvm'] is used.
+ # incompatible version. Ensure that the llvm-config of spec['libllvm'] is
+ # used.
args.append('--native-file')
args.append('meson-native-config.ini')
mkdirp(self.build_directory)
with working_dir(self.build_directory):
with open('meson-native-config.ini', 'w') as native_config:
- llvm_config = spec['llvm'].prefix.bin + '/llvm-config'
+ llvm_config = spec['libllvm'].prefix.bin + '/llvm-config'
native_config.write('[binaries]\n')
native_config.write("llvm-config = '{0}'\n".format(llvm_config))
args.append('-Dllvm=enabled')
args.append(opt_enable(
- '+llvm_dylib' in spec['llvm'], 'shared-llvm'))
+ '+llvm_dylib' in spec['libllvm'], 'shared-llvm'))
else:
args.append('-Dllvm=disabled')
diff --git a/var/spack/repos/builtin/packages/mesa18/package.py b/var/spack/repos/builtin/packages/mesa18/package.py
index 248e780536..78f99b252d 100644
--- a/var/spack/repos/builtin/packages/mesa18/package.py
+++ b/var/spack/repos/builtin/packages/mesa18/package.py
@@ -61,7 +61,7 @@ class Mesa18(AutotoolsPackage):
provides('osmesa', when='+osmesa')
# Variant dependencies
- depends_on('llvm@6:10', when='+llvm')
+ depends_on('libllvm@6:10', when='+llvm')
depends_on('libx11', when='+glx')
depends_on('libxcb', when='+glx')
depends_on('libxext', when='+glx')
@@ -138,8 +138,8 @@ class Mesa18(AutotoolsPackage):
if '+llvm' in spec:
args.append('--enable-llvm')
- args.append('--with-llvm-prefix=%s' % spec['llvm'].prefix)
- if '+llvm_dylib' in spec['llvm']:
+ args.append('--with-llvm-prefix=%s' % spec['libllvm'].prefix)
+ if '+llvm_dylib' in spec['libllvm']:
args.append('--enable-llvm-shared-libs')
else:
args.append('--disable-llvm-shared-libs')