summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Becker <becker33@llnl.gov>2022-11-06 16:40:00 -0800
committerGitHub <noreply@github.com>2022-11-06 16:40:00 -0800
commit52cc798948e41eaa30dd7645bfa2d1ecda5f0fd3 (patch)
tree9bf0b3deb9bbc77cd5724b4309d7d6ab4ce7a608
parent258edf7dac07710ea6c50316dc53e5154d9cb3b7 (diff)
downloadspack-52cc798948e41eaa30dd7645bfa2d1ecda5f0fd3.tar.gz
spack-52cc798948e41eaa30dd7645bfa2d1ecda5f0fd3.tar.bz2
spack-52cc798948e41eaa30dd7645bfa2d1ecda5f0fd3.tar.xz
spack-52cc798948e41eaa30dd7645bfa2d1ecda5f0fd3.zip
solver: do not punish explicitly requested compiler mismatches (#30074)
-rw-r--r--lib/spack/spack/solver/concretize.lp19
-rw-r--r--lib/spack/spack/test/concretize.py11
2 files changed, 29 insertions, 1 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index 02528e694d..a06d57ae10 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -44,6 +44,8 @@ node_flag_set(Package, Flag, Value) :- attr("node_flag_set", Package, Flag, Val
node_compiler_version_set(Package, Compiler, Version)
:- attr("node_compiler_version_set", Package, Compiler, Version).
+node_compiler_set(Package, Compiler)
+ :- attr("node_compiler_set", Package, Compiler).
variant_default_value_from_cli(Package, Variant, Value)
:- attr("variant_default_value_from_cli", Package, Variant, Value).
@@ -1011,6 +1013,12 @@ compiler_match(Package, Dependency)
compiler_mismatch(Package, Dependency)
:- depends_on(Package, Dependency),
+ not node_compiler_set(Dependency, _),
+ not compiler_match(Package, Dependency).
+
+compiler_mismatch_required(Package, Dependency)
+ :- depends_on(Package, Dependency),
+ node_compiler_set(Dependency, _),
not compiler_match(Package, Dependency).
#defined node_compiler_set/2.
@@ -1282,7 +1290,7 @@ opt_criterion(45, "preferred providers (non-roots)").
}.
% Try to minimize the number of compiler mismatches in the DAG.
-opt_criterion(40, "compiler mismatches").
+opt_criterion(40, "compiler mismatches that are not from CLI").
#minimize{ 0@240: #true }.
#minimize{ 0@40: #true }.
#minimize{
@@ -1291,6 +1299,15 @@ opt_criterion(40, "compiler mismatches").
build_priority(Package, Priority)
}.
+opt_criterion(39, "compiler mismatches that are not from CLI").
+#minimize{ 0@239: #true }.
+#minimize{ 0@39: #true }.
+#minimize{
+ 1@39+Priority,Package,Dependency
+ : compiler_mismatch_required(Package, Dependency),
+ build_priority(Package, Priority)
+}.
+
% Try to minimize the number of compiler mismatches in the DAG.
opt_criterion(35, "OS mismatches").
#minimize{ 0@235: #true }.
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index fd8baf8522..b943fad755 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -352,6 +352,17 @@ class TestConcretize(object):
assert set(spec.compiler_flags["cflags"]) == set(["-g"])
assert spec.satisfies("^openblas cflags='-O3'")
+ def test_mixing_compilers_only_affects_subdag(self):
+ spack.config.set("packages:all:compiler", ["clang", "gcc"])
+ spec = Spec("dt-diamond%gcc ^dt-diamond-bottom%clang").concretized()
+ for dep in spec.traverse():
+ assert ("%clang" in dep) == (dep.name == "dt-diamond-bottom")
+
+ def test_compiler_inherited_upwards(self):
+ spec = Spec("dt-diamond ^dt-diamond-bottom%clang").concretized()
+ for dep in spec.traverse():
+ assert "%clang" in dep
+
def test_architecture_inheritance(self):
"""test_architecture_inheritance is likely to fail with an
UnavailableCompilerVersionError if the architecture is concretized