Fix setting SPACK_TARGET_ARGS for concrete specs

This commit is contained in:
Massimiliano Culpo 2024-11-15 08:09:26 +01:00
parent 591b659242
commit c595a7008d
No known key found for this signature in database
GPG Key ID: 3E52BB992233066C

View File

@ -13,6 +13,7 @@
from llnl.util.filesystem import HeaderList, LibraryList
import spack.build_environment
import spack.build_systems.compiler
import spack.compilers
import spack.config
import spack.deptypes as dt
@ -781,3 +782,23 @@ def test_optimization_flags(compiler_spec, target_name, expected_flags, compiler
compiler = spack.spec.parse_with_version_concrete(compiler_spec)
opt_flags = spack.build_environment.optimization_flags(compiler, target)
assert opt_flags == expected_flags
@pytest.mark.skipif(
str(archspec.cpu.host().family) != "x86_64", reason="tests check specific x86_64 uarch flags"
)
@pytest.mark.not_on_windows("Windows doesn't support the compiler wrapper")
def test_optimization_flags_are_using_node_target(default_mock_concretization, monkeypatch):
"""Tests that we are using the target on the node to be compiled to retrieve the uarch
specific flags, and not the target of the compiler.
"""
monkeypatch.setattr(spack.build_systems.compiler, "_implicit_rpaths", lambda pkg: [])
gcc = default_mock_concretization("gcc target=core2")
mpileaks = default_mock_concretization("gcc target=x86_64")
env = EnvironmentModifications()
gcc.package.setup_dependent_build_environment(env, mpileaks)
actions = env.group_by_name()["SPACK_TARGET_ARGS"]
assert len(actions) == 1 and isinstance(actions[0], spack.util.environment.SetEnv)
assert actions[0].value == "-march=x86-64 -mtune=generic"