summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-05-08 19:12:26 +0200
committerGitHub <noreply@github.com>2023-05-08 10:12:26 -0700
commit0139288ced598cb45c4d947473f1d886b603607b (patch)
treef1f565b7e77b496b09f3429493e0affd9160d9b4 /var
parentd0cba2bf35f347a5ca09163f8b93ba9788f46ba1 (diff)
downloadspack-0139288ced598cb45c4d947473f1d886b603607b.tar.gz
spack-0139288ced598cb45c4d947473f1d886b603607b.tar.bz2
spack-0139288ced598cb45c4d947473f1d886b603607b.tar.xz
spack-0139288ced598cb45c4d947473f1d886b603607b.zip
Add a "requires" directive, extend functionality of package requirements (#36286)
Add a "require" directive to packages, which functions exactly like requirements specified in packages.yaml (uses the same fact-generation logic); update both to allow making the requirement conditional. * Packages may now use "require" to add constraints. This can be useful for something like "require(%gcc)" (where before we had to add a conflict for every compiler except gcc). * Requirements (in packages.yaml or in a "require" directive) can be conditional on a spec, e.g. "require(%gcc, when=@1.0.0)" (version 1.0.0 can only build with gcc). * Requirements may include a message which clarifies why they are needed. The concretizer assigns a high priority to errors which generate these messages (in particular over errors for unsatisfied requirements that do not produce messages, but also over a number of more-generic errors).
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin.mock/packages/requires_clang/package.py18
-rw-r--r--var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py18
-rw-r--r--var/spack/repos/builtin/packages/bucky/package.py8
-rw-r--r--var/spack/repos/builtin/packages/dyninst/package.py12
-rw-r--r--var/spack/repos/builtin/packages/ffte/package.py7
-rw-r--r--var/spack/repos/builtin/packages/gcc/package.py4
6 files changed, 41 insertions, 26 deletions
diff --git a/var/spack/repos/builtin.mock/packages/requires_clang/package.py b/var/spack/repos/builtin.mock/packages/requires_clang/package.py
new file mode 100644
index 0000000000..9f1c2d0ba4
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/requires_clang/package.py
@@ -0,0 +1,18 @@
+# Copyright 2013-2023 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)
+
+from spack.package import *
+
+
+class RequiresClang(Package):
+ """Simple package with no dependencies"""
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/b-1.0.tar.gz"
+
+ version("1.0", md5="0123456789abcdef0123456789abcdef")
+ version("0.9", md5="abcd456789abcdef0123456789abcdef")
+
+ requires("%clang", msg="can only be compiled with Clang")
diff --git a/var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py b/var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py
new file mode 100644
index 0000000000..18f924e92f
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/requires_clang_or_gcc/package.py
@@ -0,0 +1,18 @@
+# Copyright 2013-2023 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)
+
+from spack.package import *
+
+
+class RequiresClangOrGcc(Package):
+ """Simple package with no dependencies"""
+
+ homepage = "http://www.example.com"
+ url = "http://www.example.com/b-1.0.tar.gz"
+
+ version("1.0", md5="0123456789abcdef0123456789abcdef")
+ version("0.9", md5="abcd456789abcdef0123456789abcdef")
+
+ requires("%gcc", "%clang", policy="one_of")
diff --git a/var/spack/repos/builtin/packages/bucky/package.py b/var/spack/repos/builtin/packages/bucky/package.py
index 5bd0c9fdf6..601729e82e 100644
--- a/var/spack/repos/builtin/packages/bucky/package.py
+++ b/var/spack/repos/builtin/packages/bucky/package.py
@@ -18,13 +18,7 @@ class Bucky(MakefilePackage):
version("1.4.4", sha256="1621fee0d42314d9aa45d0082b358d4531e7d1d1a0089c807c1b21fbdc4e4592")
- # Compilation requires gcc
- conflicts("%cce")
- conflicts("%apple-clang")
- conflicts("%nag")
- conflicts("%pgi")
- conflicts("%xl")
- conflicts("%xl_r")
+ requires("%gcc", msg="bucky can only be compiled with GCC")
build_directory = "src"
diff --git a/var/spack/repos/builtin/packages/dyninst/package.py b/var/spack/repos/builtin/packages/dyninst/package.py
index c977fcc408..4079212ecf 100644
--- a/var/spack/repos/builtin/packages/dyninst/package.py
+++ b/var/spack/repos/builtin/packages/dyninst/package.py
@@ -87,19 +87,11 @@ class Dyninst(CMakePackage):
patch("v9.3.2-auto.patch", when="@9.3.2 %gcc@:4.7")
patch("tribool.patch", when="@9.3.0:10.0.0 ^boost@1.69:")
+ requires("%gcc", msg="dyninst builds only with GCC")
+
# No Mac support (including apple-clang)
conflicts("platform=darwin", msg="macOS is not supported")
- # We currently only build with gcc
- conflicts("%clang")
- conflicts("%arm")
- conflicts("%cce")
- conflicts("%fj")
- conflicts("%intel")
- conflicts("%pgi")
- conflicts("%xl")
- conflicts("%xl_r")
-
# Version 11.0 requires a C++11-compliant ABI
conflicts("%gcc@:5", when="@11.0.0:")
diff --git a/var/spack/repos/builtin/packages/ffte/package.py b/var/spack/repos/builtin/packages/ffte/package.py
index 8b5b36c788..ed6de99aa4 100644
--- a/var/spack/repos/builtin/packages/ffte/package.py
+++ b/var/spack/repos/builtin/packages/ffte/package.py
@@ -32,12 +32,7 @@ class Ffte(Package):
depends_on("mpi", when="+mpi")
- conflicts("%cce", when="+cuda", msg="Must use NVHPC compiler")
- conflicts("%clang", when="+cuda", msg="Must use NVHPC compiler")
- conflicts("%gcc", when="+cuda", msg="Must use NVHPC compiler")
- conflicts("%llvm", when="+cuda", msg="Must use NVHPC compiler")
- conflicts("%nag", when="+cuda", msg="Must use NVHPC compiler")
- conflicts("%intel", when="+cuda", msg="Must use NVHPC compiler")
+ requires("%nvhpc", when="+cuda", msg="ffte+cuda must use NVHPC compiler")
def edit(self, spec, prefix):
"No make-file, must create one from scratch."
diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py
index 15bede82c0..259629d31e 100644
--- a/var/spack/repos/builtin/packages/gcc/package.py
+++ b/var/spack/repos/builtin/packages/gcc/package.py
@@ -273,9 +273,7 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
# See https://gcc.gnu.org/install/prerequisites.html#GDC-prerequisite
with when("@12:"):
# All versions starting 12 have to be built GCC:
- for c in spack.compilers.supported_compilers():
- if c != "gcc":
- conflicts("%{0}".format(c))
+ requires("%gcc")
# And it has to be GCC older than the version we build:
vv = ["11", "12.1.0", "12.2.0"]