summaryrefslogtreecommitdiff
path: root/lib/spack/env
diff options
context:
space:
mode:
authorAdam J. Stewart <ajstewart426@gmail.com>2016-05-05 10:50:07 -0500
committerAdam J. Stewart <ajstewart426@gmail.com>2016-05-09 16:59:39 -0500
commit4473311bdbddb6abe2f1ad9748536db89f79081d (patch)
treed5fa7b1902e1c2904b1047218379bf5c49bd17d1 /lib/spack/env
parentcbae98670b79964420974ff5490c4461b539c27a (diff)
downloadspack-4473311bdbddb6abe2f1ad9748536db89f79081d.tar.gz
spack-4473311bdbddb6abe2f1ad9748536db89f79081d.tar.bz2
spack-4473311bdbddb6abe2f1ad9748536db89f79081d.tar.xz
spack-4473311bdbddb6abe2f1ad9748536db89f79081d.zip
Allow compilers to specify their own rpath linking flags
Diffstat (limited to 'lib/spack/env')
-rwxr-xr-xlib/spack/env/cc39
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index cb07a2ffea..4564e84bd2 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -38,15 +38,20 @@
# -Wl,-rpath arguments for dependency /lib directories.
#
-# This is the list of environment variables that need to be set before
+# This is an array of environment variables that need to be set before
# the script runs. They are set by routines in spack.build_environment
# as part of spack.package.Package.do_install().
-parameters="
-SPACK_PREFIX
-SPACK_ENV_PATH
-SPACK_DEBUG_LOG_DIR
-SPACK_COMPILER_SPEC
-SPACK_SHORT_SPEC"
+parameters=(
+ SPACK_PREFIX
+ SPACK_ENV_PATH
+ SPACK_DEBUG_LOG_DIR
+ SPACK_COMPILER_SPEC
+ SPACK_CC_RPATH_ARG
+ SPACK_CXX_RPATH_ARG
+ SPACK_F77_RPATH_ARG
+ SPACK_FC_RPATH_ARG
+ SPACK_SHORT_SPEC
+)
# The compiler input variables are checked for sanity later:
# SPACK_CC, SPACK_CXX, SPACK_F77, SPACK_FC
@@ -64,7 +69,7 @@ function die {
exit 1
}
-for param in $parameters; do
+for param in ${parameters[@]}; do
if [[ -z ${!param} ]]; then
die "Spack compiler must be run from Spack! Input '$param' is missing."
fi
@@ -85,6 +90,7 @@ done
# ccld compile & link
command=$(basename "$0")
+comp="CC"
case "$command" in
cpp)
mode=cpp
@@ -92,18 +98,22 @@ case "$command" in
cc|c89|c99|gcc|clang|icc|pgcc|xlc)
command="$SPACK_CC"
language="C"
+ comp="CC"
;;
c++|CC|g++|clang++|icpc|pgc++|xlc++)
command="$SPACK_CXX"
language="C++"
+ comp="CXX"
;;
f90|fc|f95|gfortran|ifort|pgfortran|xlf90|nagfor)
command="$SPACK_FC"
language="Fortran 90"
+ comp="FC"
;;
f77|gfortran|ifort|pgfortran|xlf|nagfor)
command="$SPACK_F77"
language="Fortran 77"
+ comp="F77"
;;
ld)
mode=ld
@@ -142,6 +152,9 @@ if [[ -z $mode ]]; then
done
fi
+# Set up rpath variable according to language.
+eval rpath=\$SPACK_${comp}_RPATH_ARG
+
# Dump the version and exit if we're in testing mode.
if [[ $SPACK_TEST_COMMAND == dump-mode ]]; then
echo "$mode"
@@ -188,7 +201,7 @@ for dep in "${deps[@]}"; do
# Prepend lib and RPATH directories
if [[ -d $dep/lib ]]; then
if [[ $mode == ccld ]]; then
- $add_rpaths && args=("-Wl,-rpath,$dep/lib" "${args[@]}")
+ $add_rpaths && args=("$rpath$dep/lib" "${args[@]}")
args=("-L$dep/lib" "${args[@]}")
elif [[ $mode == ld ]]; then
$add_rpaths && args=("-rpath" "$dep/lib" "${args[@]}")
@@ -199,7 +212,7 @@ for dep in "${deps[@]}"; do
# Prepend lib64 and RPATH directories
if [[ -d $dep/lib64 ]]; then
if [[ $mode == ccld ]]; then
- $add_rpaths && args=("-Wl,-rpath,$dep/lib64" "${args[@]}")
+ $add_rpaths && args=("$rpath$dep/lib64" "${args[@]}")
args=("-L$dep/lib64" "${args[@]}")
elif [[ $mode == ld ]]; then
$add_rpaths && args=("-rpath" "$dep/lib64" "${args[@]}")
@@ -210,9 +223,11 @@ done
# Include all -L's and prefix/whatever dirs in rpath
if [[ $mode == ccld ]]; then
- $add_rpaths && args=("-Wl,-rpath,$SPACK_PREFIX/lib" "-Wl,-rpath,$SPACK_PREFIX/lib64" "${args[@]}")
+ $add_rpaths && args=("$rpath$SPACK_PREFIX/lib64" "${args[@]}")
+ $add_rpaths && args=("$rpath$SPACK_PREFIX/lib" "${args[@]}")
elif [[ $mode == ld ]]; then
- $add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib" "-rpath" "$SPACK_PREFIX/lib64" "${args[@]}")
+ $add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib64" "${args[@]}")
+ $add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib" "${args[@]}")
fi
#