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