This Spack extension provides useful commands for modifying and validating and filter Spack environments.
To register the extension with Spack, activate a Spack instance ($SPACK_ROOT defined and spack executable available), then run:
. source_me.shThe filter-compilers subcommand can be used to filter compilers inclusively or exclusively from Spack packages configuration to ensure unwanted compilers are not considered for use by the concretizer:
spack filter-compilers <compiler-specs> (--keep-only | --remove)Example: keep only a single gcc version:
spack filter-compilers [email protected] --keep-onlyThe fix-intel-config subcommand performs various fixes for Intel OneAPI external specs:
-
Library path configuration: Adds
LD_LIBRARY_PATHmodifications to external Intel Classic (intel-oneapi-compilers-classic) specs. Without this, some package installations may fail with libimf.so not being found. -
Compiler consolidation (optional with
-c/--consolidate): Consolidates intel-oneapi-compilers externals by version. Some Intel OneAPI installations have separate externals for C/C++ compilers (icx/icpx) and Fortran (ifx) with slightly different version numbers (e.g., 2025.3.1 vs 2025.3.0). The consolidation feature automatically merges these into a single external based on the first two version numbers.
Basic usage (applies library path fix only):
spack fix-intel-configWith compiler consolidation:
spack fix-intel-config --consolidateNote: This should be run after detecting external Intel installations.
The fetch-deps subcommand can be used to fetch dependencies for Go packages (defined in go.mod) or Rust/Cargo packages (defined in Cargo.toml). This command requires a concretized environment. It checks the environment for go or rust dependents, fetches their source code, and retrieves dependencies to $GOMODCACHE/$CARGO_HOME (or default location).
To fetch dependencies for all Go-based packages:
spack fetch-deps goTo fetch dependencies for all Rust/Cargo-based packages and ensure that the spec'd rust dependency is used to do the fetching (this will install the rust package via Spack if it is not already present):
spack fetch-deps rust --use-spack-rustImportant
All of the following commands must be run in an active, concretized environment. Unconcretized root specs will not be accounted for.
To check a concretized environment for more than one concretized spec for a given package name and ignore duplicates for specific packages foo and bar:
spack validate check-duplicates --ignore foo --ignore barTo verify that only specific packages to be built for a given compiler:
spack validate allow-pkgs-for-compiler gcc foo barwill return an error message if any packages other than foo and bar are spec'd with %gcc.
To verify that only packages explicitly approved by the user have been concretized:
spack validate check-approved-pkgs --packages foo baror
spack validate check-approved-pkgs --pkgs-from-file approved_list.txtwhere approved_list.txt contains newline-delimited package names:
gmake
cmake
gcc
gcc-runtime
...
To verify that only specific C/C++/Fortran compilers have been concretized:
spack validate compilers intel-oneapi-compilers gccwill return an error if any packages have c/cxx/fortran providers that are not intel-oneapi-compilers or gcc.
To run a deploy based on a deployments.yaml for a given spack-stack directory and site, run
spack deployCompared with the deploy.py utility in spack-stack, this will implement more robust checks. This copy and not the spack-stack one should be used for WCOSS2 installations.
To access the extensions via Spack Python API (spack-python etc.), do, e.g.:
spack.extensions.load_extension("helpers")
from spack.extensions.helpers import *
from spack.extensions.helpers.cmd import validateafter associating the extensions with your Spack instance (i.e., sourcing source_me.sh).
To run the unit tests:
spack unit-test --extension=helpersSee tests/README.md for more details.