Allow compiler wrapper to modify environment (#2275)
* Allow compiler wrapper to modify environment This adds the ability to set environment variables in the compiler wrappers. These are specified as part of the compilers.yaml config. The user may also specify RPATHs in compilers.yaml that should be added. * Minor doc tweak
This commit is contained in:
22
lib/spack/env/cc
vendored
22
lib/spack/env/cc
vendored
@@ -174,6 +174,18 @@ if [[ -z $command ]]; then
|
||||
die "ERROR: Compiler '$SPACK_COMPILER_SPEC' does not support compiling $language programs."
|
||||
fi
|
||||
|
||||
#
|
||||
# Set paths as defined in the 'environment' section of the compiler config
|
||||
# names are stored in SPACK_ENV_TO_SET
|
||||
# values are stored in SPACK_ENV_SET_<varname>
|
||||
#
|
||||
IFS=':' read -ra env_set_varnames <<< "$SPACK_ENV_TO_SET"
|
||||
for varname in "${env_set_varnames[@]}"; do
|
||||
spack_varname="SPACK_ENV_SET_$varname"
|
||||
export $varname=${!spack_varname}
|
||||
unset $spack_varname
|
||||
done
|
||||
|
||||
#
|
||||
# Filter '.' and Spack environment directories out of PATH so that
|
||||
# this script doesn't just call itself
|
||||
@@ -311,6 +323,16 @@ elif [[ $mode == ld ]]; then
|
||||
$add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib" "${args[@]}")
|
||||
fi
|
||||
|
||||
# Set extra RPATHs
|
||||
IFS=':' read -ra extra_rpaths <<< "$SPACK_COMPILER_EXTRA_RPATHS"
|
||||
for extra_rpath in "${extra_rpaths[@]}"; do
|
||||
if [[ $mode == ccld ]]; then
|
||||
$add_rpaths && args=("$rpath$extra_rpath" "${args[@]}")
|
||||
elif [[ $mode == ld ]]; then
|
||||
$add_rpaths && args=("-rpath" "$extra_rpath" "${args[@]}")
|
||||
fi
|
||||
done
|
||||
|
||||
# Add SPACK_LDLIBS to args
|
||||
case "$mode" in
|
||||
ld|ccld)
|
||||
|
Reference in New Issue
Block a user