summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/spack/gitlab/cloud_pipelines/stacks/e4s-on-power/spack.yaml2
-rw-r--r--share/spack/gitlab/cloud_pipelines/stacks/e4s/spack.yaml2
-rw-r--r--var/spack/repos/builtin/packages/iwyu/package.py11
-rw-r--r--var/spack/repos/builtin/packages/llvm/package.py89
-rw-r--r--var/spack/repos/builtin/packages/zig/package.py2
5 files changed, 69 insertions, 37 deletions
diff --git a/share/spack/gitlab/cloud_pipelines/stacks/e4s-on-power/spack.yaml b/share/spack/gitlab/cloud_pipelines/stacks/e4s-on-power/spack.yaml
index 26a594228d..af0f6087fb 100644
--- a/share/spack/gitlab/cloud_pipelines/stacks/e4s-on-power/spack.yaml
+++ b/share/spack/gitlab/cloud_pipelines/stacks/e4s-on-power/spack.yaml
@@ -128,7 +128,7 @@ spack:
- libnrm
- libquo
- libunwind
- - llvm +all_targets +clang +compiler-rt +libcxx +lld +lldb +llvm_dylib +flang ~cuda
+ - llvm targets=amdgpu,nvptx +clang +compiler-rt +libcxx +lld +lldb +llvm_dylib +flang ~cuda
- loki
- mercury
- metall
diff --git a/share/spack/gitlab/cloud_pipelines/stacks/e4s/spack.yaml b/share/spack/gitlab/cloud_pipelines/stacks/e4s/spack.yaml
index 3e86a84c18..d2ed08d04d 100644
--- a/share/spack/gitlab/cloud_pipelines/stacks/e4s/spack.yaml
+++ b/share/spack/gitlab/cloud_pipelines/stacks/e4s/spack.yaml
@@ -139,7 +139,7 @@ spack:
- libnrm
- libquo
- libunwind
- - llvm +all_targets +clang +compiler-rt +libcxx +lld +lldb +llvm_dylib +flang ~cuda
+ - llvm targets=amdgpu,nvptx +clang +compiler-rt +libcxx +lld +lldb +llvm_dylib +flang ~cuda
- loki
- mercury
- metall
diff --git a/var/spack/repos/builtin/packages/iwyu/package.py b/var/spack/repos/builtin/packages/iwyu/package.py
index a430dacd6f..cfbc016e75 100644
--- a/var/spack/repos/builtin/packages/iwyu/package.py
+++ b/var/spack/repos/builtin/packages/iwyu/package.py
@@ -32,15 +32,8 @@ class Iwyu(CMakePackage):
depends_on('llvm+clang@8.0:8', when='@0.12')
depends_on('llvm+clang@7.0:7', when='@0.11')
- # Non-X86 CPU use all_targets variants because iwyu use X86AsmParser
- depends_on('llvm+all_targets', when='target=aarch64:')
- depends_on('llvm+all_targets', when='target=arm:')
- depends_on('llvm+all_targets', when='target=ppc:')
- depends_on('llvm+all_targets', when='target=ppcle:')
- depends_on('llvm+all_targets', when='target=ppc64:')
- depends_on('llvm+all_targets', when='target=ppc64le:')
- depends_on('llvm+all_targets', when='target=sparc:')
- depends_on('llvm+all_targets', when='target=sparc64:')
+ # iwyu uses X86AsmParser
+ depends_on('llvm targets=x86')
@when('@0.14:')
def cmake_args(self):
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
index 8d353b071b..cfdefbabc2 100644
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -138,10 +138,14 @@ class Llvm(CMakePackage, CudaPackage):
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",
@@ -271,6 +275,11 @@ class Llvm(CMakePackage, CudaPackage):
# Fixed in upstream versions of both
conflicts('^cmake@3.19.0', when='@6.0.0:11.0.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)
+ conflicts("targets=cppbackend", when='@3.9.0:')
+
# Github issue #4986
patch("llvm_gcc7.patch", when="@4.0.0:4.0.1+lldb %gcc@7.0:")
@@ -618,27 +627,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,3 +697,51 @@ class Llvm(CMakePackage, CudaPackage):
with working_dir(self.build_directory):
install_tree("bin", join_path(self.prefix, "libexec", "llvm"))
+
+
+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/var/spack/repos/builtin/packages/zig/package.py b/var/spack/repos/builtin/packages/zig/package.py
index c29f71ba28..cf20ebf0e2 100644
--- a/var/spack/repos/builtin/packages/zig/package.py
+++ b/var/spack/repos/builtin/packages/zig/package.py
@@ -17,6 +17,6 @@ class Zig(CMakePackage):
default='Release', description='CMake build type'
)
- depends_on('llvm@11.0.0: +all_targets')
+ depends_on('llvm@11.0.0: targets=all')
provides('ziglang')