From b3cc4b4cb36cf845f426a6fefffed4c4e7b8a0e2 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 22 Jan 2025 09:37:41 +0100 Subject: [PATCH] Fix non-determinism when using mixed compilers --- lib/spack/spack/solver/concretize.lp | 9 +++++++++ lib/spack/spack/test/concretization/core.py | 7 ++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index e523ede0249..a60919db63c 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -1760,6 +1760,15 @@ opt_criterion(1, "edge wiring"). depends_on(ParentNode, PackageNode) }. +#minimize{ 0@201: #true }. +#minimize{ 0@1: #true }. +#minimize{ + Weight@1,ParentNode,ProviderNode,Virtual + : provider_weight(ProviderNode, Virtual, Weight), + not attr("root", ProviderNode), + depends_on(ParentNode, ProviderNode) +}. + %----------- % Notes %----------- diff --git a/lib/spack/spack/test/concretization/core.py b/lib/spack/spack/test/concretization/core.py index d3498e88fd5..dfe0417831b 100644 --- a/lib/spack/spack/test/concretization/core.py +++ b/lib/spack/spack/test/concretization/core.py @@ -434,18 +434,19 @@ def test_compiler_flag_propagation(self, spec_str, expected, not_expected): for constraint in not_expected: assert not root.satisfies(constraint) - @pytest.mark.xfail(reason="FIXME (compiler as nodes): flaky test, revisit") def test_mixing_compilers_only_affects_subdag(self): """Tests that, when we mix compilers, the one with lower penalty is used for nodes where the compiler is not forced. """ spec = spack.concretize.concretize_one("dt-diamond%clang ^dt-diamond-bottom%gcc") - + print(spec.tree()) for x in spec.traverse(deptype=("link", "run")): if "c" not in x or not x.name.startswith("dt-diamond"): continue expected_gcc = x.name != "dt-diamond" - assert bool(x.dependencies(name="llvm", deptype="build")) is not expected_gcc + assert ( + bool(x.dependencies(name="llvm", deptype="build")) is not expected_gcc + ), x.long_spec assert bool(x.dependencies(name="gcc", deptype="build")) is expected_gcc assert x.satisfies("%clang") is not expected_gcc assert x.satisfies("%gcc") is expected_gcc