summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/test/data/unparse/llvm.txt280
-rw-r--r--lib/spack/spack/test/util/package_hash.py2
2 files changed, 171 insertions, 111 deletions
diff --git a/lib/spack/spack/test/data/unparse/llvm.txt b/lib/spack/spack/test/data/unparse/llvm.txt
index 67557328d9..4a402fb58a 100644
--- a/lib/spack/spack/test/data/unparse/llvm.txt
+++ b/lib/spack/spack/test/data/unparse/llvm.txt
@@ -1,14 +1,7 @@
-# -*- python -*-
-# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-"""This is an unparser test package.
-
-``llvm`` was chosen because it is one of the most complex packages in Spack and it
-exercises nearly all directives.
-
-"""
import os
import os.path
import re
@@ -18,6 +11,7 @@ import llnl.util.tty as tty
import spack.build_environment
import spack.util.executable
+from spack.package import *
class Llvm(CMakePackage, CudaPackage):
@@ -42,6 +36,14 @@ class Llvm(CMakePackage, CudaPackage):
# fmt: off
version('main', branch='main')
+ version('14.0.6', sha256='98f15f842700bdb7220a166c8d2739a03a72e775b67031205078f39dd756a055')
+ version('14.0.5', sha256='a4a57f029cb81f04618e05853f05fc2d21b64353c760977d8e7799bf7218a23a')
+ version('14.0.4', sha256='1333236f9bee38658762076be4236cb5ebf15ae9b7f2bfce6946b96ae962dc73')
+ version('14.0.3', sha256='0e1d049b050127ecf6286107e9a4400b0550f841d5d2288b9d31fd32ed0683d5')
+ version('14.0.2', sha256='ca52232b3451c8e017f00eb882277707c13e30fac1271ec97015f6d0eeb383d1')
+ version('14.0.1', sha256='c8be00406e872c8a24f8571cf6f5517b73ae707104724b1fd1db2f0af9544019')
+ version('14.0.0', sha256='87b1a068b370df5b79a892fdb2935922a8efb1fddec4cc506e30fe57b6a1d9c4')
+ version('13.0.1', sha256='09c50d558bd975c41157364421820228df66632802a4a6a7c9c17f86a7340802')
version('13.0.0', sha256='a1131358f1f9f819df73fa6bff505f2c49d176e9eef0a3aedd1fdbce3b4630e8')
version('12.0.1', sha256='66b64aa301244975a4aea489f402f205cde2f53dd722dad9e7b77a0459b4c8df')
version('12.0.0', sha256='8e6c99e482bb16a450165176c2d881804976a2d770e0445af4375e78a1fbf19c')
@@ -84,7 +86,7 @@ class Llvm(CMakePackage, CudaPackage):
)
variant(
"flang",
- default=False,
+ default=False, when='@11: +clang',
description="Build the LLVM Fortran compiler frontend "
"(experimental - parser only, needs GCC)",
)
@@ -93,12 +95,12 @@ class Llvm(CMakePackage, CudaPackage):
default=False,
description="Include debugging code in OpenMP runtime libraries",
)
- variant("lldb", default=True, description="Build the LLVM debugger")
+ variant("lldb", default=True, when='+clang', description="Build the LLVM debugger")
variant("lld", default=True, description="Build the LLVM linker")
- variant("mlir", default=False, description="Build with MLIR support")
+ variant("mlir", default=False, when='@10:', description="Build with MLIR support")
variant(
"internal_unwind",
- default=True,
+ default=True, when='+clang',
description="Build the libcxxabi libunwind",
)
variant(
@@ -109,11 +111,11 @@ class Llvm(CMakePackage, CudaPackage):
)
variant(
"libcxx",
- default=True,
+ default=True, when='+clang',
description="Build the LLVM C++ standard library",
)
variant(
- "compiler-rt",
+ "compiler-rt", when='+clang',
default=True,
description="Build LLVM compiler runtime, including sanitizers",
)
@@ -128,27 +130,24 @@ class Llvm(CMakePackage, CudaPackage):
description="Build with split dwarf information",
)
variant(
- "shared_libs",
- default=False,
- description="Build all components as shared libraries, faster, "
- "less memory to build, less stable",
- )
- variant(
"llvm_dylib",
- default=False,
- description="Build LLVM shared library, containing all "
- "components in a single shared library",
+ default=True,
+ description="Build a combined LLVM shared library with all components",
)
variant(
"link_llvm_dylib",
- default=False,
+ default=False, when='+llvm_dylib',
description="Link LLVM tools against the LLVM shared library",
)
variant(
- "all_targets",
- default=False,
- description="Build all supported targets, default targets "
- "<current arch>,NVPTX,AMDGPU,CppBackend",
+ "targets",
+ default="none",
+ description=("What targets to build. Spack's target family is always added "
+ "(e.g. X86 is automatically enabled when targeting znver2)."),
+ values=("all", "none", "aarch64", "amdgpu", "arm", "avr", "bpf", "cppbackend",
+ "hexagon", "lanai", "mips", "msp430", "nvptx", "powerpc", "riscv",
+ "sparc", "systemz", "webassembly", "x86", "xcore"),
+ multi=True
)
variant(
"build_type",
@@ -158,20 +157,45 @@ class Llvm(CMakePackage, CudaPackage):
)
variant(
"omp_tsan",
- default=False,
+ default=False, when='@6:',
description="Build with OpenMP capable thread sanitizer",
)
variant(
"omp_as_runtime",
default=True,
+ when='+clang @12:',
description="Build OpenMP runtime via ENABLE_RUNTIME by just-built Clang",
)
variant('code_signing', default=False,
+ when='+lldb platform=darwin',
description="Enable code-signing on macOS")
variant("python", default=False, description="Install python bindings")
-
variant('version_suffix', default='none', description="Add a symbol suffix")
- variant('z3', default=False, description='Use Z3 for the clang static analyzer')
+ variant(
+ 'shlib_symbol_version',
+ default='none',
+ description="Add shared library symbol version",
+ when='@13:'
+ )
+ variant(
+ 'z3',
+ default=False,
+ when='+clang @8:',
+ description='Use Z3 for the clang static analyzer'
+ )
+
+ provides('libllvm@14', when='@14.0.0:14')
+ provides('libllvm@13', when='@13.0.0:13')
+ provides('libllvm@12', when='@12.0.0:12')
+ provides('libllvm@11', when='@11.0.0:11')
+ provides('libllvm@10', when='@10.0.0:10')
+ provides('libllvm@9', when='@9.0.0:9')
+ provides('libllvm@8', when='@8.0.0:8')
+ provides('libllvm@7', when='@7.0.0:7')
+ provides('libllvm@6', when='@6.0.0:6')
+ provides('libllvm@5', when='@5.0.0:5')
+ provides('libllvm@4', when='@4.0.0:4')
+ provides('libllvm@3', when='@3.0.0:3')
extends("python", when="+python")
@@ -186,7 +210,9 @@ class Llvm(CMakePackage, CudaPackage):
# Universal dependency
depends_on("python@2.7:2.8", when="@:4+python")
depends_on("python", when="@5:+python")
- depends_on('z3', when='@8:+clang+z3')
+
+ # clang and clang-tools dependencies
+ depends_on("z3@4.7.1:", when="+z3")
# openmp dependencies
depends_on("perl-data-dumper", type=("build"))
@@ -194,12 +220,13 @@ class Llvm(CMakePackage, CudaPackage):
depends_on("libelf", when="+cuda") # libomptarget
depends_on("libffi", when="+cuda") # libomptarget
- # ncurses dependency
- depends_on("ncurses+termlib")
+ # llvm-config --system-libs libraries.
+ depends_on("zlib")
# lldb dependencies
depends_on("swig", when="+lldb")
depends_on("libedit", when="+lldb")
+ depends_on("ncurses", when="+lldb")
depends_on("py-six", when="@5.0.0: +lldb +python")
# gold support, required for some features
@@ -209,23 +236,13 @@ class Llvm(CMakePackage, CudaPackage):
depends_on("gmp", when="@:3.6 +polly")
depends_on("isl", when="@:3.6 +polly")
- conflicts("+llvm_dylib", when="+shared_libs")
- conflicts("+link_llvm_dylib", when="~llvm_dylib")
- conflicts("+lldb", when="~clang")
- conflicts("+libcxx", when="~clang")
- conflicts("+internal_unwind", when="~clang")
- conflicts("+compiler-rt", when="~clang")
- conflicts("+flang", when="~clang")
- # Introduced in version 11 as a part of LLVM and not a separate package.
- conflicts("+flang", when="@:10")
-
- conflicts('~mlir', when='+flang', msg='Flang requires MLIR')
-
# Older LLVM do not build with newer compilers, and vice versa
conflicts("%gcc@8:", when="@:5")
conflicts("%gcc@:5.0", when="@8:")
# clang/lib: a lambda parameter cannot shadow an explicitly captured entity
conflicts("%clang@8:", when="@:4")
+ # Internal compiler error on gcc 8.4 on aarch64 https://bugzilla.redhat.com/show_bug.cgi?id=1958295
+ conflicts('%gcc@8.4:8.4.9', when='@12: target=aarch64:')
# When these versions are concretized, but not explicitly with +libcxx, these
# conflicts will enable clingo to set ~libcxx, making the build successful:
@@ -247,42 +264,19 @@ class Llvm(CMakePackage, CudaPackage):
conflicts('%clang@6:', when='@:4+compiler-rt')
conflicts('%apple-clang@6:', when='@:4+compiler-rt')
- # OMP TSAN exists in > 5.x
- conflicts("+omp_tsan", when="@:5")
-
- # OpenMP via ENABLE_RUNTIME restrictions
- conflicts("+omp_as_runtime", when="~clang", msg="omp_as_runtime requires clang being built.")
- conflicts("+omp_as_runtime", when="@:11.1", msg="omp_as_runtime works since LLVM 12.")
-
# cuda_arch value must be specified
conflicts("cuda_arch=none", when="+cuda", msg="A value for cuda_arch must be specified.")
- # MLIR exists in > 10.x
- conflicts("+mlir", when="@:9")
-
- # code signing is only necessary on macOS",
- conflicts('+code_signing', when='platform=linux')
- conflicts('+code_signing', when='platform=cray')
-
- conflicts(
- '+code_signing',
- when='~lldb platform=darwin',
- msg="code signing is only necessary for building the "
- "in-tree debug server on macOS. Turning this variant "
- "off enables a build of llvm with lldb that uses the "
- "system debug server",
- )
-
# LLVM bug https://bugs.llvm.org/show_bug.cgi?id=48234
# CMake bug: https://gitlab.kitware.com/cmake/cmake/-/issues/21469
# Fixed in upstream versions of both
- conflicts('^cmake@3.19.0', when='@6.0.0:11.0.0')
+ conflicts('^cmake@3.19.0', when='@6:11.0.0')
# Github issue #4986
patch("llvm_gcc7.patch", when="@4.0.0:4.0.1+lldb %gcc@7.0:")
# sys/ustat.h has been removed in favour of statfs from glibc-2.28. Use fixed sizes:
- patch('llvm5-sanitizer-ustat.patch', when="@4:6+compiler-rt")
+ patch('llvm5-sanitizer-ustat.patch', when="@4:6.0.0+compiler-rt")
# Fix lld templates: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=230463
patch('llvm4-lld-ELF-Symbols.patch', when="@4+lld%clang@6:")
@@ -295,8 +289,8 @@ class Llvm(CMakePackage, CudaPackage):
patch('sanitizer-ipc_perm_mode.patch', when="@5:7+compiler-rt%clang@11:")
patch('sanitizer-ipc_perm_mode.patch', when="@5:9+compiler-rt%gcc@9:")
- # github.com/spack/spack/issues/24270 and MicrosoftDemangle: %gcc@10: and %clang@13:
- patch('missing-includes.patch', when='@8:11')
+ # github.com/spack/spack/issues/24270: MicrosoftDemangle for %gcc@10: and %clang@13:
+ patch('missing-includes.patch', when='@8')
# Backport from llvm master + additional fix
# see https://bugs.llvm.org/show_bug.cgi?id=39696
@@ -310,7 +304,7 @@ class Llvm(CMakePackage, CudaPackage):
patch("llvm_py37.patch", when="@4:6 ^python@3.7:")
# https://bugs.llvm.org/show_bug.cgi?id=39696
- patch("thread-p9.patch", when="@develop+libcxx")
+ patch("thread-p9.patch", when="@:10 +libcxx")
# https://github.com/spack/spack/issues/19625,
# merged in llvm-11.0.0_rc2, but not found in 11.0.1
@@ -318,16 +312,31 @@ class Llvm(CMakePackage, CudaPackage):
# https://github.com/spack/spack/issues/19908
# merged in llvm main prior to 12.0.0
- patch("llvm_python_path.patch", when="@11.0.0")
+ patch("llvm_python_path.patch", when="@:11")
# Workaround for issue https://github.com/spack/spack/issues/18197
- patch('llvm7_intel.patch', when='@7 %intel@18.0.2,19.0.4')
+ patch('llvm7_intel.patch', when='@7 %intel@18.0.2,19.0.0:19.1.99')
# Remove cyclades support to build against newer kernel headers
# https://reviews.llvm.org/D102059
patch('no_cyclades.patch', when='@10:12.0.0')
patch('no_cyclades9.patch', when='@6:9')
+ patch('llvm-gcc11.patch', when='@9:11%gcc@11:')
+
+ # add -lpthread to build OpenMP libraries with Fujitsu compiler
+ patch('llvm12-thread.patch', when='@12 %fj')
+ patch('llvm13-thread.patch', when='@13 %fj')
+
+ # avoid build failed with Fujitsu compiler
+ patch('llvm13-fujitsu.patch', when='@13 %fj')
+
+ # patch for missing hwloc.h include for libompd
+ patch('llvm14-hwloc-ompd.patch', when='@14')
+
+ # make libflags a list in openmp subproject when ~omp_as_runtime
+ patch('libomp-libflags-as-list.patch', when='@3.7:')
+
# The functions and attributes below implement external package
# detection for LLVM. See:
#
@@ -456,6 +465,11 @@ class Llvm(CMakePackage, CudaPackage):
result = os.path.join(self.spec.prefix.bin, 'flang')
return result
+ @property
+ def libs(self):
+ return LibraryList(self.llvm_config("--libfiles", "all",
+ result="list"))
+
@run_before('cmake')
def codesign_check(self):
if self.spec.satisfies("+code_signing"):
@@ -522,6 +536,8 @@ class Llvm(CMakePackage, CudaPackage):
define("LLVM_REQUIRES_RTTI", True),
define("LLVM_ENABLE_RTTI", True),
define("LLVM_ENABLE_EH", True),
+ define("LLVM_ENABLE_TERMINFO", False),
+ define("LLVM_ENABLE_LIBXML2", False),
define("CLANG_DEFAULT_OPENMP_RUNTIME", "libomp"),
define("PYTHON_EXECUTABLE", python.command.path),
define("LIBOMP_USE_HWLOC", True),
@@ -532,6 +548,11 @@ class Llvm(CMakePackage, CudaPackage):
if version_suffix != 'none':
cmake_args.append(define('LLVM_VERSION_SUFFIX', version_suffix))
+ shlib_symbol_version = spec.variants.get('shlib_symbol_version', None)
+ if shlib_symbol_version is not None and shlib_symbol_version.value != 'none':
+ cmake_args.append(define('LLVM_SHLIB_SYMBOL_VERSION',
+ shlib_symbol_version.value))
+
if python.version >= Version("3"):
cmake_args.append(define("Python3_EXECUTABLE", python.command.path))
else:
@@ -567,11 +588,14 @@ class Llvm(CMakePackage, CudaPackage):
cmake_args.append(from_variant("LIBOMPTARGET_ENABLE_DEBUG", "omp_debug"))
if "+lldb" in spec:
+ projects.append("lldb")
+ cmake_args.append(define('LLDB_ENABLE_LIBEDIT', True))
+ cmake_args.append(define('LLDB_ENABLE_NCURSES', True))
+ cmake_args.append(define('LLDB_ENABLE_LIBXML2', False))
if spec.version >= Version('10'):
cmake_args.append(from_variant("LLDB_ENABLE_PYTHON", 'python'))
else:
- cmake_args.append(define("LLDB_DISABLE_PYTHON",
- '~python' in spec))
+ cmake_args.append(define("LLDB_DISABLE_PYTHON", '~python' in spec))
if spec.satisfies("@5.0.0: +python"):
cmake_args.append(define("LLDB_USE_SYSTEM_SIX", True))
@@ -588,17 +612,13 @@ class Llvm(CMakePackage, CudaPackage):
else:
projects.append("openmp")
- if self.spec.satisfies("@8"):
- cmake_args.append(define('CLANG_ANALYZER_ENABLE_Z3_SOLVER',
- self.spec.satisfies('@8+z3')))
- if self.spec.satisfies("@9:"):
- cmake_args.append(define('LLVM_ENABLE_Z3_SOLVER',
- self.spec.satisfies('@9:+z3')))
+ if '@8' in spec:
+ cmake_args.append(from_variant('CLANG_ANALYZER_ENABLE_Z3_SOLVER', 'z3'))
+ elif '@9:' in spec:
+ cmake_args.append(from_variant('LLVM_ENABLE_Z3_SOLVER', 'z3'))
if "+flang" in spec:
projects.append("flang")
- if "+lldb" in spec:
- projects.append("lldb")
if "+lld" in spec:
projects.append("lld")
if "+compiler-rt" in spec:
@@ -615,7 +635,7 @@ class Llvm(CMakePackage, CudaPackage):
cmake_args.append(define("LINK_POLLY_INTO_TOOLS", True))
cmake_args.extend([
- from_variant("BUILD_SHARED_LIBS", "shared_libs"),
+ define("BUILD_SHARED_LIBS", False),
from_variant("LLVM_BUILD_LLVM_DYLIB", "llvm_dylib"),
from_variant("LLVM_LINK_LLVM_DYLIB", "link_llvm_dylib"),
from_variant("LLVM_USE_SPLIT_DWARF", "split_dwarf"),
@@ -625,27 +645,9 @@ class Llvm(CMakePackage, CudaPackage):
define('LIBCXX_ENABLE_STATIC_ABI_LIBRARY', True)
])
- if "+all_targets" not in spec: # all is default on cmake
-
- targets = ["NVPTX", "AMDGPU"]
- if spec.version < Version("3.9.0"):
- # Starting in 3.9.0 CppBackend is no longer a target (see
- # LLVM_ALL_TARGETS in llvm's top-level CMakeLists.txt for
- # the complete list of targets)
- targets.append("CppBackend")
-
- if spec.target.family in ("x86", "x86_64"):
- targets.append("X86")
- elif spec.target.family == "arm":
- targets.append("ARM")
- elif spec.target.family == "aarch64":
- targets.append("AArch64")
- elif spec.target.family in ("sparc", "sparc64"):
- targets.append("Sparc")
- elif spec.target.family in ("ppc64", "ppc64le", "ppc", "ppcle"):
- targets.append("PowerPC")
-
- cmake_args.append(define("LLVM_TARGETS_TO_BUILD", targets))
+ cmake_args.append(define(
+ "LLVM_TARGETS_TO_BUILD",
+ get_llvm_targets_to_build(spec)))
cmake_args.append(from_variant("LIBOMP_TSAN_SUPPORT", "omp_tsan"))
@@ -706,10 +708,68 @@ class Llvm(CMakePackage, CudaPackage):
ninja()
ninja("install")
if "+python" in self.spec:
- install_tree("llvm/bindings/python", site_packages_dir)
+ install_tree("llvm/bindings/python", python_platlib)
if "+clang" in self.spec:
- install_tree("clang/bindings/python", site_packages_dir)
+ install_tree("clang/bindings/python", python_platlib)
with working_dir(self.build_directory):
install_tree("bin", join_path(self.prefix, "libexec", "llvm"))
+
+ def llvm_config(self, *args, **kwargs):
+ lc = Executable(self.prefix.bin.join('llvm-config'))
+ if not kwargs.get('output'):
+ kwargs['output'] = str
+ ret = lc(*args, **kwargs)
+ if kwargs.get('result') == "list":
+ return ret.split()
+ else:
+ return ret
+
+
+def get_llvm_targets_to_build(spec):
+ targets = spec.variants['targets'].value
+
+ # Build everything?
+ if 'all' in targets:
+ return 'all'
+
+ # Convert targets variant values to CMake LLVM_TARGETS_TO_BUILD array.
+ spack_to_cmake = {
+ "aarch64": "AArch64",
+ "amdgpu": "AMDGPU",
+ "arm": "ARM",
+ "avr": "AVR",
+ "bpf": "BPF",
+ "cppbackend": "CppBackend",
+ "hexagon": "Hexagon",
+ "lanai": "Lanai",
+ "mips": "Mips",
+ "msp430": "MSP430",
+ "nvptx": "NVPTX",
+ "powerpc": "PowerPC",
+ "riscv": "RISCV",
+ "sparc": "Sparc",
+ "systemz": "SystemZ",
+ "webassembly": "WebAssembly",
+ "x86": "X86",
+ "xcore": "XCore"
+ }
+
+ if 'none' in targets:
+ llvm_targets = set()
+ else:
+ llvm_targets = set(spack_to_cmake[target] for target in targets)
+
+ if spec.target.family in ("x86", "x86_64"):
+ llvm_targets.add("X86")
+ elif spec.target.family == "arm":
+ llvm_targets.add("ARM")
+ elif spec.target.family == "aarch64":
+ llvm_targets.add("AArch64")
+ elif spec.target.family in ("sparc", "sparc64"):
+ llvm_targets.add("Sparc")
+ elif spec.target.family in ("ppc64", "ppc64le", "ppc", "ppcle"):
+ llvm_targets.add("PowerPC")
+
+ return list(llvm_targets)
diff --git a/lib/spack/spack/test/util/package_hash.py b/lib/spack/spack/test/util/package_hash.py
index 2d4f00d5dc..f8b1bd5067 100644
--- a/lib/spack/spack/test/util/package_hash.py
+++ b/lib/spack/spack/test/util/package_hash.py
@@ -340,7 +340,7 @@ def test_remove_complex_package_logic_filtered():
@pytest.mark.parametrize("package_spec,expected_hash", [
("amdfftw", "tivb752zddjgvfkogfs7cnnvp5olj6co"),
("grads", "rrlmwml3f2frdnqavmro3ias66h5b2ce"),
- ("llvm", "g3hoqf4rhprd3da7byp5nzco6tcwliiy"),
+ ("llvm", "nufffum5dabmaf4l5tpfcblnbfjknvd3"),
# has @when("@4.1.0") and raw unicode literals
("mfem", "tiiv7uq7v2xtv24vdij5ptcv76dpazrw"),
("mfem@4.0.0", "tiiv7uq7v2xtv24vdij5ptcv76dpazrw"),