No flag propagation when compilers are different

Flag propagation is not activated on nodes with
a compiler that is different from the propagation
source
This commit is contained in:
Massimiliano Culpo 2025-02-05 11:55:30 +01:00
parent 922b9b0e50
commit f75555136b
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C
2 changed files with 17 additions and 9 deletions

View File

@ -1244,15 +1244,18 @@ error(100, "Cannot propagate the variant '{0}' from the package: {1} because pac
% A propagated flag implies: % A propagated flag implies:
% 1. The same flag type is not set on this node % 1. The same flag type is not set on this node
% 2. This node has the same compiler as the propagation source % 2. This node has the same compilers as the propagation source
node_compiler(node(X, Package), node(Y, Compiler)) :-
attr("virtual_on_edge", node(X, Package), node(Y, Compiler), Language),
attr("version", node(Y, Compiler), Version),
compiler(Compiler), language(Language).
propagated_flag(node(PackageID, Package), node_flag(FlagType, Flag, FlagGroup, Source), SourceNode) :- propagated_flag(node(PackageID, Package), node_flag(FlagType, Flag, FlagGroup, Source), SourceNode) :-
propagate(node(PackageID, Package), node_flag(FlagType, Flag, FlagGroup, Source), _), propagate(node(PackageID, Package), node_flag(FlagType, Flag, FlagGroup, Source), _),
not attr("node_flag_set", node(PackageID, Package), node_flag(FlagType, _, _, "literal")), not attr("node_flag_set", node(PackageID, Package), node_flag(FlagType, _, _, "literal")),
% FIXME (compiler as nodes): do we need to match the compiler? % Same compilers as propagation source
% Same compiler as propagation source node_compiler(node(PackageID, Package), CompilerNode) : node_compiler(SourceNode, CompilerNode);
% node_compiler(node(PackageID, Package), CompilerID),
% node_compiler(SourceNode, CompilerID),
attr("propagate", SourceNode, node_flag(FlagType, Flag, FlagGroup, Source), _), attr("propagate", SourceNode, node_flag(FlagType, Flag, FlagGroup, Source), _),
node(PackageID, Package) != SourceNode, node(PackageID, Package) != SourceNode,
not runtime(Package). not runtime(Package).

View File

@ -198,10 +198,6 @@ def test_propagate_and_compiler_cfg(concretize_scope, test_repo):
assert root_spec["y"].satisfies("cflags='-f1 -f2'") assert root_spec["y"].satisfies("cflags='-f1 -f2'")
# Note: setting flags on a dependency overrides propagation, which
# is tested in test/concretize.py:test_compiler_flag_propagation
def test_propagate_and_pkg_dep(concretize_scope, test_repo): def test_propagate_and_pkg_dep(concretize_scope, test_repo):
root_spec1 = spack.concretize.concretize_one("x ~activatemultiflag cflags=='-f1'") root_spec1 = spack.concretize.concretize_one("x ~activatemultiflag cflags=='-f1'")
assert root_spec1["y"].satisfies("cflags='-f1 -d1'") assert root_spec1["y"].satisfies("cflags='-f1 -d1'")
@ -275,3 +271,12 @@ def test_diamond_dep_flag_mixing(concretize_scope, test_repo):
spec1 = root_spec1["y"] spec1 = root_spec1["y"]
assert spec1.satisfies('cflags="-c1 -c2 -d1 -d2 -e1 -e2"') assert spec1.satisfies('cflags="-c1 -c2 -d1 -d2 -e1 -e2"')
assert spec1.compiler_flags["cflags"] == "-c1 -c2 -e1 -e2 -d1 -d2".split() assert spec1.compiler_flags["cflags"] == "-c1 -c2 -e1 -e2 -d1 -d2".split()
def test_flag_injection_different_compilers(mock_packages, mutable_config):
"""Tests that flag propagation is not activated on nodes with a compiler that is different
from the propagation source.
"""
s = spack.concretize.concretize_one('mpileaks %gcc cflags=="-O2" ^callpath %llvm')
assert s.satisfies('cflags="-O2"') and s["c"].name == "gcc"
assert not s["callpath"].satisfies('cflags="-O2"') and s["callpath"]["c"].name == "llvm"