compiler-wrapper: set SPACK_COMPILER_EXTRA_RPATHS (#49828)
Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
parent
035096006e
commit
5c71d36330
@ -777,3 +777,54 @@ def test_optimization_flags_are_using_node_target(default_mock_concretization, m
|
|||||||
|
|
||||||
assert len(actions) == 1 and isinstance(actions[0], spack.util.environment.SetEnv)
|
assert len(actions) == 1 and isinstance(actions[0], spack.util.environment.SetEnv)
|
||||||
assert actions[0].value == "-march=x86-64 -mtune=generic"
|
assert actions[0].value == "-march=x86-64 -mtune=generic"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.regression("49827")
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"gcc_config,expected_rpaths",
|
||||||
|
[
|
||||||
|
(
|
||||||
|
"""\
|
||||||
|
gcc:
|
||||||
|
externals:
|
||||||
|
- spec: gcc@14.2.0 languages=c
|
||||||
|
prefix: /fake/path1
|
||||||
|
extra_attributes:
|
||||||
|
compilers:
|
||||||
|
c: /fake/path1
|
||||||
|
extra_rpaths:
|
||||||
|
- /extra/rpaths1
|
||||||
|
- /extra/rpaths2
|
||||||
|
""",
|
||||||
|
"/extra/rpaths1:/extra/rpaths2",
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"""\
|
||||||
|
gcc:
|
||||||
|
externals:
|
||||||
|
- spec: gcc@14.2.0 languages=c
|
||||||
|
prefix: /fake/path1
|
||||||
|
extra_attributes:
|
||||||
|
compilers:
|
||||||
|
c: /fake/path1
|
||||||
|
""",
|
||||||
|
None,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
@pytest.mark.not_on_windows("Windows doesn't use the compiler-wrapper")
|
||||||
|
def test_extra_rpaths_is_set(
|
||||||
|
working_env, mutable_config, mock_packages, gcc_config, expected_rpaths
|
||||||
|
):
|
||||||
|
"""Tests that using a compiler with an 'extra_rpaths' section will set the corresponding
|
||||||
|
SPACK_COMPILER_EXTRA_RPATHS variable for the wrapper.
|
||||||
|
"""
|
||||||
|
cfg_data = syaml.load_config(gcc_config)
|
||||||
|
spack.config.set("packages", cfg_data)
|
||||||
|
mpich = spack.concretize.concretize_one("mpich %gcc@14")
|
||||||
|
spack.build_environment.setup_package(mpich.package, dirty=False)
|
||||||
|
|
||||||
|
if expected_rpaths is not None:
|
||||||
|
assert os.environ["SPACK_COMPILER_EXTRA_RPATHS"] == expected_rpaths
|
||||||
|
else:
|
||||||
|
assert "SPACK_COMPILER_EXTRA_RPATHS" not in os.environ
|
||||||
|
@ -162,6 +162,7 @@ def setup_dependent_build_environment(self, env, dependent_spec):
|
|||||||
|
|
||||||
bin_dir = self.bin_dir()
|
bin_dir = self.bin_dir()
|
||||||
implicit_rpaths, env_paths = [], []
|
implicit_rpaths, env_paths = [], []
|
||||||
|
extra_rpaths = []
|
||||||
for language, attr_name, wrapper_var_name, spack_var_name in _var_list:
|
for language, attr_name, wrapper_var_name, spack_var_name in _var_list:
|
||||||
compiler_pkg = dependent_spec[language].package
|
compiler_pkg = dependent_spec[language].package
|
||||||
if not hasattr(compiler_pkg, attr_name):
|
if not hasattr(compiler_pkg, attr_name):
|
||||||
@ -215,12 +216,21 @@ def setup_dependent_build_environment(self, env, dependent_spec):
|
|||||||
# Check if this compiler has implicit rpaths
|
# Check if this compiler has implicit rpaths
|
||||||
implicit_rpaths.extend(_implicit_rpaths(pkg=compiler_pkg))
|
implicit_rpaths.extend(_implicit_rpaths(pkg=compiler_pkg))
|
||||||
|
|
||||||
|
# Add extra rpaths, if they are defined in an external spec
|
||||||
|
extra_rpaths.extend(
|
||||||
|
getattr(compiler_pkg.spec, "extra_attributes", {}).get("extra_rpaths", [])
|
||||||
|
)
|
||||||
|
|
||||||
if implicit_rpaths:
|
if implicit_rpaths:
|
||||||
# Implicit rpaths are accumulated across all compilers so, whenever they are mixed,
|
# Implicit rpaths are accumulated across all compilers so, whenever they are mixed,
|
||||||
# the compiler used in ccld mode will account for rpaths from other compilers too.
|
# the compiler used in ccld mode will account for rpaths from other compilers too.
|
||||||
implicit_rpaths = lang.dedupe(implicit_rpaths)
|
implicit_rpaths = lang.dedupe(implicit_rpaths)
|
||||||
env.set("SPACK_COMPILER_IMPLICIT_RPATHS", ":".join(implicit_rpaths))
|
env.set("SPACK_COMPILER_IMPLICIT_RPATHS", ":".join(implicit_rpaths))
|
||||||
|
|
||||||
|
if extra_rpaths:
|
||||||
|
extra_rpaths = lang.dedupe(extra_rpaths)
|
||||||
|
env.set("SPACK_COMPILER_EXTRA_RPATHS", ":".join(extra_rpaths))
|
||||||
|
|
||||||
env.set("SPACK_ENABLE_NEW_DTAGS", self.enable_new_dtags)
|
env.set("SPACK_ENABLE_NEW_DTAGS", self.enable_new_dtags)
|
||||||
env.set("SPACK_DISABLE_NEW_DTAGS", self.disable_new_dtags)
|
env.set("SPACK_DISABLE_NEW_DTAGS", self.disable_new_dtags)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user