bugfix: associate nodes directly with specs for compiler flag reordering (#48496)

This commit is contained in:
Greg Becker
2025-01-14 10:15:57 -08:00
committed by GitHub
parent 8196c68ff3
commit 2447d16e55
3 changed files with 16 additions and 3 deletions

View File

@@ -3540,15 +3540,13 @@ def reorder_flags(self):
)
cmd_specs = dict((s.name, s) for spec in self._command_line_specs for s in spec.traverse())
for spec in self._specs.values():
for node, spec in self._specs.items():
# if bootstrapping, compiler is not in config and has no flags
flagmap_from_compiler = {}
if spec.compiler in compilers:
flagmap_from_compiler = compilers[spec.compiler].flags
for flag_type in spec.compiler_flags.valid_compiler_flags():
node = SpecBuilder.make_node(pkg=spec.name)
ordered_flags = []
# 1. Put compiler flags first

View File

@@ -5,6 +5,7 @@
import pytest
import spack.concretize
import spack.config
import spack.environment as ev
import spack.paths
@@ -96,6 +97,18 @@ def test_mix_spec_and_compiler_cfg(concretize_scope, test_repo):
assert s1.satisfies('cflags="-Wall -O2"')
def test_pkg_flags_from_compiler_and_none(concretize_scope, mock_packages):
conf_str = _compiler_cfg_one_entry_with_cflags("-Wall")
update_concretize_scope(conf_str, "compilers")
s1 = Spec("cmake%gcc@12.100.100")
s2 = Spec("cmake-client^cmake%clang")
concrete = dict(spack.concretize.concretize_together([(s1, None), (s2, None)]))
assert concrete[s1].compiler_flags["cflags"] == ["-Wall"]
assert concrete[s2].compiler_flags["cflags"] == []
@pytest.mark.parametrize(
"cmd_flags,req_flags,cmp_flags,dflags,expected_order",
[