Import recent changes

This commit is contained in:
Erik Schnetter 2016-03-17 21:53:13 -04:00
parent 84b7cd593f
commit f3ea0420f8

185
lib/spack/env/cc vendored
View file

@ -65,7 +65,7 @@ function die {
}
for param in $parameters; do
if [ -z "${!param}" ]; then
if [[ -z ${!param} ]]; then
die "Spack compiler must be run from spack! Input $param was missing!"
fi
done
@ -78,10 +78,11 @@ done
# 'command' is set based on the input command to $SPACK_[CC|CXX|F77|F90]
#
# 'mode' is set to one of:
# cpp preprocess
# cc compile
# as assemble
# ld link
# ccld compile & link
# cpp preprocessor
# vcheck version check
#
command=$(basename "$0")
@ -131,6 +132,9 @@ if [ -z "$mode" ]; then
if [ "$arg" = -E ]; then
mode=cpp
break
elif [ "$arg" = -S ]; then
mode=as
break
elif [ "$arg" = -c ]; then
mode=cc
break
@ -146,22 +150,25 @@ fi
# Check that at least one of the real commands was actually selected,
# otherwise we don't know what to execute.
if [ -z "$command" ]; then
if [[ -z $command ]]; then
die "ERROR: Compiler '$SPACK_COMPILER_SPEC' does not support compiling $language programs."
fi
if [ "$mode" == vcheck ] ; then
exec ${command} "$@"
fi
# Save original command for debug logging
input_command="$@"
args=("$@")
<<<<<<< HEAD
# Dump parsed values for unit testing if asked for
if [[ -n $SPACK_TEST_COMMAND ]]; then
#
# Now do real parsing of the command line args, trying hard to keep
# non-rpath linker arguments in the proper order w.r.t. other command
# line arguments. This is important for things like groups.
# non-rpath linker arguments in the proper order w.r.t. other command line
# arguments. This is important for things like groups.
#
includes=()
libraries=()
@ -188,32 +195,44 @@ if [[ -n $SPACK_TEST_COMMAND ]]; then
;;
-Wl,*)
arg="${1#-Wl,}"
if [ -z "$arg" ]; then shift; arg="$1"; fi
if [[ "$arg" = -rpath=* ]]; then
rpaths+=("${arg#-rpath=}")
elif [[ "$arg" = -rpath ]]; then
# TODO: Handle multiple -Wl, continuations of -Wl,-rpath
if [[ $arg == -rpath=* ]]; then
arg="${arg#-rpath=}"
for rpath in ${arg//,/ }; do
rpaths+=("$rpath")
done
elif [[ $arg == -rpath,* ]]; then
arg="${arg#-rpath,}"
for rpath in ${arg//,/ }; do
rpaths+=("$rpath")
done
elif [[ $arg == -rpath ]]; then
shift; arg="$1"
if [[ "$arg" != -Wl,* ]]; then
if [[ $arg != '-Wl,'* ]]; then
die "-Wl,-rpath was not followed by -Wl,*"
fi
rpaths+=("${arg#-Wl,}")
arg="${arg#-Wl,}"
for rpath in ${arg//,/ }; do
rpaths+=("$rpath")
done
else
other_args+=("-Wl,$arg")
fi
;;
-Xlinker,*)
arg="${1#-Xlinker,}"
if [ -z "$arg" ]; then shift; arg="$1"; fi
if [[ "$arg" = -rpath=* ]]; then
-Xlinker)
shift; arg="$1";
if [[ $arg = -rpath=* ]]; then
rpaths+=("${arg#-rpath=}")
elif [[ "$arg" = -rpath ]]; then
elif [[ $arg = -rpath ]]; then
shift; arg="$1"
if [[ "$arg" != -Xlinker,* ]]; then
die "-Xlinker,-rpath was not followed by -Xlinker,*"
if [[ $arg != -Xlinker ]]; then
die "-Xlinker -rpath was not followed by -Xlinker <arg>"
fi
rpaths+=("${arg#-Xlinker,}")
shift; arg="$1"
rpaths+=("$arg")
else
other_args+=("-Xlinker,$arg")
other_args+=("-Xlinker")
other_args+=("$arg")
fi
;;
*)
@ -222,88 +241,6 @@ if [[ -n $SPACK_TEST_COMMAND ]]; then
esac
shift
done
=======
if [ "$mode" == vcheck ] ; then
exec ${command} "$@"
fi
#
# Now do real parsing of the command line args, trying hard to keep
# non-rpath linker arguments in the proper order w.r.t. other command
# line arguments. This is important for things like groups.
#
includes=()
libraries=()
libs=()
rpaths=()
other_args=()
while [ -n "$1" ]; do
case "$1" in
-I*)
arg="${1#-I}"
if [ -z "$arg" ]; then shift; arg="$1"; fi
includes+=("$arg")
;;
-L*)
arg="${1#-L}"
if [ -z "$arg" ]; then shift; arg="$1"; fi
libraries+=("$arg")
;;
-l*)
arg="${1#-l}"
if [ -z "$arg" ]; then shift; arg="$1"; fi
libs+=("$arg")
;;
-Wl,*)
arg="${1#-Wl,}"
# TODO: Handle multiple -Wl, continuations of -Wl,-rpath
if [[ $arg == -rpath=* ]]; then
arg="${arg#-rpath=}"
for rpath in ${arg//,/ }; do
rpaths+=("$rpath")
done
elif [[ $arg == -rpath,* ]]; then
arg="${arg#-rpath,}"
for rpath in ${arg//,/ }; do
rpaths+=("$rpath")
done
elif [[ $arg == -rpath ]]; then
shift; arg="$1"
if [[ $arg != '-Wl,'* ]]; then
die "-Wl,-rpath was not followed by -Wl,*"
fi
arg="${arg#-Wl,}"
for rpath in ${arg//,/ }; do
rpaths+=("$rpath")
done
else
other_args+=("-Wl,$arg")
fi
;;
-Xlinker)
shift; arg="$1";
if [[ $arg = -rpath=* ]]; then
rpaths+=("${arg#-rpath=}")
elif [[ $arg = -rpath ]]; then
shift; arg="$1"
if [[ $arg != -Xlinker ]]; then
die "-Xlinker -rpath was not followed by -Xlinker <arg>"
fi
shift; arg="$1"
rpaths+=("$arg")
else
other_args+=("-Xlinker")
other_args+=("$arg")
fi
;;
*)
other_args+=("$1")
;;
esac
shift
done
>>>>>>> develop
IFS=$'\n'
case "$SPACK_TEST_COMMAND" in
@ -329,8 +266,8 @@ done
echo "${other_args[*]}"
;;
*)
echo "ERROR: Unknown test command"
exit 1 ;;
die "ERROR: Unknown test command"
;;
esac
exit
fi
@ -338,11 +275,14 @@ fi
# Read spack dependencies from the path environment variable
IFS=':' read -ra deps <<< "$SPACK_DEPENDENCIES"
for dep in "${deps[@]}"; do
if [ -d "$dep/include" ]; then
args=("-I$dep/include" "${args[@]}")
if [[ -d $dep/include ]]; then
if [[ $mode = cpp || $mode = cc || $mode = as || $mode = ccld ]]; then
args=("-I$dep/include" "${args[@]}")
fi
fi
if [ -d "$dep/lib" ]; then
if [[ -d $dep/lib ]]; then
# libraries+=("$dep/lib")
if [[ $mode = ccld ]]; then
args=("-L$dep/lib" "-Wl,-rpath,$dep/lib" "${args[@]}")
elif [[ $mode = ld ]]; then
@ -350,7 +290,7 @@ for dep in "${deps[@]}"; do
fi
fi
if [ -d "$dep/lib64" ]; then
if [[ -d $dep/lib64 ]]; then
# libraries+=("$dep/lib64")
if [[ $mode = ccld ]]; then
args=("-L$dep/lib" "-Wl,-rpath,$dep/lib" "${args[@]}")
@ -362,8 +302,18 @@ done
# Include all -L's and prefix/whatever dirs in rpath
if [[ $mode = ccld ]]; then
# for dir in "${libraries[@]}"; do
# if [[ dir = $SPACK_INSTALL* ]]; then
# args=("-Wl,-rpath,$dir" "${args[@]}")
# fi
# done
args=("-Wl,-rpath,$SPACK_PREFIX/lib" "-Wl,-rpath,$SPACK_PREFIX/lib64" "${args[@]}")
elif [[ $mode = ld ]]; then
# for dir in "${libraries[@]}"; do
# if [[ dir = $SPACK_INSTALL* ]]; then
# args=("-rpath" "$dir" "${args[@]}")
# fi
# done
args=("-rpath" "$SPACK_PREFIX/lib" "-rpath" "$SPACK_PREFIX/lib64" "${args[@]}")
fi
@ -385,28 +335,23 @@ PATH=""
for dir in "${env_path[@]}"; do
remove=""
for rm_dir in "${spack_env_dirs[@]}"; do
if [ "$dir" = "$rm_dir" ]; then remove=True; fi
if [[ $dir = $rm_dir ]]; then remove=True; fi
done
if [ -z "$remove" ]; then
if [ -z "$PATH" ]; then
PATH="$dir"
else
PATH="$PATH:$dir"
fi
if [[ -z $remove ]]; then
PATH="${PATH:+$PATH:}$dir"
fi
done
export PATH
full_command=("$command")
full_command+=("${args[@]}")
full_command=("$command" "${args[@]}")
#
# Write the input and output commands to debug logs if it's asked for.
#
if [ "$SPACK_DEBUG" = "TRUE" ]; then
if [[ $SPACK_DEBUG = TRUE ]]; then
input_log="$SPACK_DEBUG_LOG_DIR/spack-cc-$SPACK_SHORT_SPEC.in.log"
output_log="$SPACK_DEBUG_LOG_DIR/spack-cc-$SPACK_SHORT_SPEC.out.log"
echo "$input_command" >> $input_log
echo "$input_command" >> $input_log
echo "$mode ${full_command[@]}" >> $output_log
fi