summaryrefslogtreecommitdiff
path: root/var
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2023-11-30 18:36:24 +0100
committerTodd Gamblin <tgamblin@llnl.gov>2023-12-21 12:22:58 -0800
commitea7e3e4f9fdf98abd22f530dc61048ad0ce23d04 (patch)
treea8205a86f9b4bc15487eec436a47d96a1a73d279 /var
parent8371bb4e192f876978fd77ea81c728bcd3475768 (diff)
downloadspack-ea7e3e4f9fdf98abd22f530dc61048ad0ce23d04.tar.gz
spack-ea7e3e4f9fdf98abd22f530dc61048ad0ce23d04.tar.bz2
spack-ea7e3e4f9fdf98abd22f530dc61048ad0ce23d04.tar.xz
spack-ea7e3e4f9fdf98abd22f530dc61048ad0ce23d04.zip
Compilers can inject first order rules into the solver
* Restore PackageBase class, and modify only ASP This prevents a noticeable slowdown in concretization due to the number of directives involved. * Fix issue with 'clang' being preferred to 'gcc', due to runtime version weights * Constraints on runtimes are declared by compilers The declaration of available runtime versions, and of their compatibility constraints are in the associated compiler class. Co-authored-by: Harmen Stoppels <harmenstoppels@gmail.com>
Diffstat (limited to 'var')
-rw-r--r--var/spack/repos/builtin/packages/gcc-runtime/package.py72
-rw-r--r--var/spack/repos/builtin/packages/gcc/package.py29
-rw-r--r--var/spack/repos/compiler_runtime.test/packages/a/package.py13
-rw-r--r--var/spack/repos/compiler_runtime.test/packages/b/package.py12
-rw-r--r--var/spack/repos/compiler_runtime.test/packages/gcc-runtime/package.py13
-rw-r--r--var/spack/repos/compiler_runtime.test/packages/gcc/package.py32
-rw-r--r--var/spack/repos/compiler_runtime.test/repo.yaml2
7 files changed, 103 insertions, 70 deletions
diff --git a/var/spack/repos/builtin/packages/gcc-runtime/package.py b/var/spack/repos/builtin/packages/gcc-runtime/package.py
index f0cd13dd14..ff13e05476 100644
--- a/var/spack/repos/builtin/packages/gcc-runtime/package.py
+++ b/var/spack/repos/builtin/packages/gcc-runtime/package.py
@@ -20,6 +20,8 @@ class GccRuntime(Package):
homepage = "https://gcc.gnu.org"
has_code = False
+ tags = ["runtime"]
+
maintainers("haampie")
license("GPL-3.0-or-later WITH GCC-exception-3.1")
@@ -42,76 +44,6 @@ class GccRuntime(Package):
"ubsan",
]
- for v in [
- "13.2",
- "13.1",
- "12.3",
- "12.2",
- "12.1",
- "11.4",
- "11.3",
- "11.2",
- "11.1",
- "10.5",
- "10.4",
- "10.3",
- "10.2",
- "10.1",
- "9.5",
- "9.4",
- "9.3",
- "9.2",
- "9.1",
- "8.5",
- "8.4",
- "8.3",
- "8.2",
- "8.1",
- "7.5",
- "7.4",
- "7.3",
- "7.2",
- "7.1",
- "6.5",
- "6.4",
- "6.3",
- "6.2",
- "6.1",
- "5.5",
- "5.4",
- "5.3",
- "5.2",
- "5.1",
- "4.9.4",
- "4.9.3",
- "4.9.2",
- "4.9.1",
- "4.9.0",
- "4.8.5",
- "4.8.4",
- "4.8.3",
- "4.8.2",
- "4.8.1",
- "4.8.0",
- "4.7.4",
- "4.7.3",
- "4.7.2",
- "4.7.1",
- "4.7.0",
- "4.6.4",
- "4.6.3",
- "4.6.2",
- "4.6.1",
- "4.6.0",
- "4.5.4",
- "4.5.3",
- "4.5.2",
- "4.5.1",
- "4.5.0",
- ]:
- version(v)
- requires(f"%gcc@{v}", when=f"@{v}")
-
def install(self, spec, prefix):
if spec.platform in ["linux", "cray", "freebsd"]:
libraries = self._get_libraries_elf()
diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py
index f6dce2ea00..2fb8d23aed 100644
--- a/var/spack/repos/builtin/packages/gcc/package.py
+++ b/var/spack/repos/builtin/packages/gcc/package.py
@@ -1111,3 +1111,32 @@ class Gcc(AutotoolsPackage, GNUMirrorPackage):
),
),
)
+
+ @classmethod
+ def runtime_constraints(cls, *, compiler, pkg):
+ """Callback function to inject runtime-related rules into the solver.
+
+ Rule-injection is obtained through method calls of the ``pkg`` argument.
+
+ Documentation for this function is temporary. When the API will be in its final state,
+ we'll document the behavior at https://spack.readthedocs.io/en/latest/
+
+ Args:
+ compiler: compiler object (node attribute) currently considered
+ pkg: object used to forward information to the solver
+ """
+ pkg("*").depends_on(
+ "gcc-runtime",
+ when="%gcc",
+ type="link",
+ description="If any package uses %gcc, it depends on gcc-runtime",
+ )
+ pkg("*").depends_on(
+ f"gcc-runtime@{str(compiler.version)}:",
+ when=f"%{str(compiler.spec)}",
+ type="link",
+ description=f"If any package uses %{str(compiler.spec)}, "
+ f"it depends on gcc-runtime@{str(compiler.version)}:",
+ )
+ # The version of gcc-runtime is the same as the %gcc used to "compile" it
+ pkg("gcc-runtime").requires(f"@={str(compiler.version)}", when=f"%{str(compiler.spec)}")
diff --git a/var/spack/repos/compiler_runtime.test/packages/a/package.py b/var/spack/repos/compiler_runtime.test/packages/a/package.py
new file mode 100644
index 0000000000..1f68aadc2f
--- /dev/null
+++ b/var/spack/repos/compiler_runtime.test/packages/a/package.py
@@ -0,0 +1,13 @@
+# 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 A(Package):
+ homepage = "http://www.example.com"
+ has_code = False
+
+ version("1.0")
+ depends_on("b")
diff --git a/var/spack/repos/compiler_runtime.test/packages/b/package.py b/var/spack/repos/compiler_runtime.test/packages/b/package.py
new file mode 100644
index 0000000000..ab9f3150e6
--- /dev/null
+++ b/var/spack/repos/compiler_runtime.test/packages/b/package.py
@@ -0,0 +1,12 @@
+# 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 B(Package):
+ homepage = "http://www.example.com"
+ has_code = False
+
+ version("1.0")
diff --git a/var/spack/repos/compiler_runtime.test/packages/gcc-runtime/package.py b/var/spack/repos/compiler_runtime.test/packages/gcc-runtime/package.py
new file mode 100644
index 0000000000..61d40a2df6
--- /dev/null
+++ b/var/spack/repos/compiler_runtime.test/packages/gcc-runtime/package.py
@@ -0,0 +1,13 @@
+# 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 GccRuntime(Package):
+ homepage = "https://example.com"
+ has_code = False
+ tags = ["runtime"]
+ requires("%gcc")
diff --git a/var/spack/repos/compiler_runtime.test/packages/gcc/package.py b/var/spack/repos/compiler_runtime.test/packages/gcc/package.py
new file mode 100644
index 0000000000..db81066599
--- /dev/null
+++ b/var/spack/repos/compiler_runtime.test/packages/gcc/package.py
@@ -0,0 +1,32 @@
+# 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 Gcc(Package):
+ homepage = "http://www.example.com/"
+ has_code = False
+
+ version("13.2.0")
+ version("12.3.0")
+
+ @classmethod
+ def runtime_constraints(cls, *, compiler, pkg):
+ pkg("*").depends_on(
+ "gcc-runtime",
+ when="%gcc",
+ type="link",
+ description="If any package uses %gcc, it depends on gcc-runtime",
+ )
+ pkg("*").depends_on(
+ f"gcc-runtime@{str(compiler.version)}:",
+ when=f"%{str(compiler.spec)}",
+ type="link",
+ description=f"If any package uses %{str(compiler.spec)}, "
+ f"it depends on gcc-runtime@{str(compiler.version)}:",
+ )
+ # The version of gcc-runtime is the same as the %gcc used to "compile" it
+ pkg("gcc-runtime").requires(f"@={str(compiler.version)}", when=f"%{str(compiler.spec)}")
diff --git a/var/spack/repos/compiler_runtime.test/repo.yaml b/var/spack/repos/compiler_runtime.test/repo.yaml
new file mode 100644
index 0000000000..1be826a641
--- /dev/null
+++ b/var/spack/repos/compiler_runtime.test/repo.yaml
@@ -0,0 +1,2 @@
+repo:
+ namespace: compiler_runtime.test