Toolchains: parse-time aliases for dependencies#50481
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR includes 2 primary components:
Conditional dependencies
Conditional dependencies can be expressed with a
when=clause on the dependency edge attributesFor example:
means that hdf5 depends on mpich for mpi when it depends on mpi, and depends on gcc for fortran when the fortran variant is turned on.
You may need to quote this on the CLI, like so:
> spack spec "hdf5 %[when=+fortran virtuals=fortran] gcc ^[when=^mpi, virtuals=mpi ] mpich"Toolchains
Toolchains are parse-time aliases for dependencies. This allows complex dependency relationships to be encoded by simple aliases. The toolchains feature is designed to facilitate the use-case previously allowed by configuring compilers to have the fortran compiler from a different compiler set -- toolchains are however more general, and can apply to any dependencies.
Toolchains are configured in the
toolchainsconfig section, e.g.With this configuration, you can now use
%clang_gfortranand%gcc_mpichas you would a compiler. You can add flags, e.g.:The
clang_gfortrantoolchain is roughly equivalent to configuring a Spack v0.* compiler to have clang executables for c/cxx and gfortran for fortran. Thegcc_mpichtoolchain uses only gcc, but is extended to also include the mpi implementation to use.You can currently only use
%(direct dependency) in toolchain conditions, though we are working on enabling^conditions in a later PR.You can write the same toolchains with conditional dependencies, but it's much harder to read:
Some notes on using toolchains:
TODO: