compilers set in run env shouldn't impact build
Adds `drop` to EnvironmentModifications courtesy of @haampie, and uses it to clear modifications of CC, CXX, F77 and FC made by `setup_{,dependent_}run_environment` routines when producing an environment in BUILD context.
This commit is contained in:
parent
f80df0ca47
commit
0663ac3633
@ -1016,10 +1016,17 @@ def get_env_modifications(self) -> EnvironmentModifications:
|
||||
self._make_runnable(dspec, env)
|
||||
|
||||
if self.should_setup_run_env & flag:
|
||||
run_env_mods = EnvironmentModifications()
|
||||
for spec in dspec.dependents(deptype=dt.LINK | dt.RUN):
|
||||
if id(spec) in self.nodes_in_subdag:
|
||||
pkg.setup_dependent_run_environment(env, spec)
|
||||
pkg.setup_run_environment(env)
|
||||
pkg.setup_dependent_run_environment(run_env_mods, spec)
|
||||
pkg.setup_run_environment(run_env_mods)
|
||||
run_env_dict = run_env_mods.group_by_name()
|
||||
if self.context == Context.BUILD:
|
||||
run_env_mods.drop("CC", "CXX", "F77", "FC")
|
||||
env.extend(run_env_mods)
|
||||
|
||||
|
||||
return env
|
||||
|
||||
def _make_buildtime_detectable(self, dep: spack.spec.Spec, env: EnvironmentModifications):
|
||||
|
@ -596,6 +596,14 @@ def group_by_name(self) -> Dict[str, ModificationList]:
|
||||
modifications[item.name].append(item)
|
||||
return modifications
|
||||
|
||||
def drop(self, *name) -> bool:
|
||||
"""Drop all modifications to the variable with the given name."""
|
||||
old_mods = self.env_modifications
|
||||
new_mods = [x for x in self.env_modifications if x.name not in name]
|
||||
self.env_modifications = new_mods
|
||||
|
||||
return len(old_mods) != len(new_mods)
|
||||
|
||||
def is_unset(self, variable_name: str) -> bool:
|
||||
"""Returns True if the last modification to a variable is to unset it, False otherwise."""
|
||||
modifications = self.group_by_name()
|
||||
|
Loading…
Reference in New Issue
Block a user