Fix setting SPACK_TARGET_ARGS for concrete specs

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

View File

@ -13,12 +13,14 @@
from llnl.util.filesystem import HeaderList, LibraryList
import spack.build_environment
import spack.build_systems.compiler
import spack.concretize
import spack.config
import spack.deptypes as dt
import spack.package_base
import spack.paths
import spack.spec
import spack.util.environment
import spack.util.spack_yaml as syaml
from spack.build_environment import UseMode, _static_to_shared_library, dso_suffix
from spack.context import Context
@ -779,3 +781,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"