cc: make error messages more clear

- [x] Our wrapper error messages are sometimes hard to differentiate from other build
      output, so prefix all errors from `die()` with '[spack cc] ERROR:'

- [x] The error we raise when running, say, `fc` without a Fortran compiler was not
      clear enough. Clarify the message and the comment.
This commit is contained in:
Todd Gamblin 2021-10-04 13:24:57 -07:00
parent 052b2e1b08
commit 84c878b66a

13
lib/spack/env/cc vendored
View File

@ -70,7 +70,7 @@ SPACK_SYSTEM_DIRS"
# die MESSAGE # die MESSAGE
# Print a message and exit with error code 1. # Print a message and exit with error code 1.
die() { die() {
echo "$@" echo "[spack cc] ERROR: $*"
exit 1 exit 1
} }
@ -191,7 +191,7 @@ system_dir() {
# Fail with a clear message if the input contains any bell characters. # Fail with a clear message if the input contains any bell characters.
if eval "[ \"\${*#*${lsep}}\" != \"\$*\" ]"; then if eval "[ \"\${*#*${lsep}}\" != \"\$*\" ]"; then
die "ERROR: Compiler command line contains our separator ('${lsep}'). Cannot parse." die "Compiler command line contains our separator ('${lsep}'). Cannot parse."
fi fi
# ensure required variables are set # ensure required variables are set
@ -337,10 +337,11 @@ if [ "$SPACK_TEST_COMMAND" = "dump-mode" ]; then
exit exit
fi fi
# Check that at least one of the real commands was actually selected, # If, say, SPACK_CC is set but SPACK_FC is not, we want to know. Compilers do not
# otherwise we don't know what to execute. # *have* to set up Fortran executables, so we need to tell the user when a build is
# about to attempt to use them unsuccessfully.
if [ -z "$command" ]; then if [ -z "$command" ]; then
die "ERROR: Compiler '$SPACK_COMPILER_SPEC' does not support compiling $language programs." die "Compiler '$SPACK_COMPILER_SPEC' does not have a $language compiler configured."
fi fi
# #
@ -755,7 +756,7 @@ if [ -n "${SPACK_TEST_COMMAND=}" ]; then
eval "printf '%s\n' \"\$0: \$var: \$$var\"" eval "printf '%s\n' \"\$0: \$var: \$$var\""
;; ;;
*) *)
die "ERROR: Unknown test command: '$SPACK_TEST_COMMAND'" die "Unknown test command: '$SPACK_TEST_COMMAND'"
;; ;;
esac esac
fi fi