Skip to content

Don't let runtime env variables of compiler like deps leak into the build environment#40916

Merged
trws merged 4 commits intospack:developfrom
haampie:fix/dont-let-runtime-env-variables-mess-up-build-environment
Nov 6, 2023
Merged

Don't let runtime env variables of compiler like deps leak into the build environment#40916
trws merged 4 commits intospack:developfrom
haampie:fix/dont-let-runtime-env-variables-mess-up-build-environment

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Nov 6, 2023

When depending on libllvm or libgcc as a build/link type dep, we don't want
their setup_run_environment changes to modify CC / CXX / F77 / FC, since
Spack determines the actual compiler and should manage those variables.

We still want module files to be generated with those CC / CXX / F77 / FC
variables, so it would be wrong to remove those variables from
setup_run_environment.

The alternative would be to setup the compiler env changes last, but quite
some packages already rely on setting CXX in setup_build_environment,
and we also don't want to break that.

haampie and others added 3 commits November 6, 2023 21:04
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.
@spackbot-app spackbot-app bot added build-environment core PR affects Spack core functionality dependencies new-version tests General test capability(ies) utilities labels Nov 6, 2023
@haampie
Copy link
Copy Markdown
Member Author

haampie commented Nov 6, 2023

@spackbot run pipeline

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented Nov 6, 2023

I've started that pipeline for you!

@haampie haampie requested a review from trws November 6, 2023 21:54
@haampie haampie added this to the v0.21.0 milestone Nov 6, 2023
@trws trws merged commit 461eb94 into spack:develop Nov 6, 2023
Copy link
Copy Markdown
Member

@tgamblin tgamblin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM -- minor request and we're good

pkg.setup_dependent_run_environment(run_env_mods, spec)
pkg.setup_run_environment(run_env_mods)
if self.context == Context.BUILD:
# Don't let the runtime environment of comiler like dependencies leak into the
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Don't let the runtime environment of comiler like dependencies leak into the
# Don't let the runtime environment of compiler-like dependencies leak into the

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't you heard about the co-miler?

pkg.setup_run_environment(env)
pkg.setup_dependent_run_environment(run_env_mods, spec)
pkg.setup_run_environment(run_env_mods)
if self.context == Context.BUILD:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO here to handle this better when we have proper "compiler" dependencies, mention this is a stopgap

@tgamblin
Copy link
Copy Markdown
Member

tgamblin commented Nov 6, 2023

Heh ok looks like Tom beat me to it. This is good -- we DO need to sort out how this will work with compiler deps.

@haampie haampie deleted the fix/dont-let-runtime-env-variables-mess-up-build-environment branch November 8, 2023 20:11
gabrielctn pushed a commit to gabrielctn/spack that referenced this pull request Nov 24, 2023
…uild environment (spack#40916)

* Test that setup_run_environment changes to CC/CXX/FC/F77 are dropped in build env

* 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.

* comment / style

* comment

---------

Co-authored-by: Tom Scogland <[email protected]>
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Dec 14, 2023
…uild environment (spack#40916)

* Test that setup_run_environment changes to CC/CXX/FC/F77 are dropped in build env

* 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.

* comment / style

* comment

---------

Co-authored-by: Tom Scogland <[email protected]>
@nboelte
Copy link
Copy Markdown
Contributor

nboelte commented Feb 16, 2024

We used setup_run_environment() to clear modifications to PATH. This change breaks that.

Is there any way we can now unset PATH modifications for a package? It is set by _make_runnable() and can no longer be unset by setup_run_environment() with env.clear().

Edit: Ah. An explicit removal with env.remove_path() works :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-environment core PR affects Spack core functionality dependencies new-version tests General test capability(ies) utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants