Fix non-determinism when using mixed compilers

This commit is contained in:
Massimiliano Culpo 2025-01-22 09:37:41 +01:00
parent bb65d495d9
commit b3cc4b4cb3
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C
2 changed files with 13 additions and 3 deletions

View File

@ -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
%-----------

View File

@ -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