From 84c878b66ac59c34b5df3c14a756419341c143e8 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 4 Oct 2021 13:24:57 -0700 Subject: 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. --- lib/spack/env/cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/spack/env/cc b/lib/spack/env/cc index 4bef0ddf9e..c498db0583 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -70,7 +70,7 @@ SPACK_SYSTEM_DIRS" # die MESSAGE # Print a message and exit with error code 1. die() { - echo "$@" + echo "[spack cc] ERROR: $*" exit 1 } @@ -191,7 +191,7 @@ system_dir() { # Fail with a clear message if the input contains any bell characters. 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 # ensure required variables are set @@ -337,10 +337,11 @@ if [ "$SPACK_TEST_COMMAND" = "dump-mode" ]; then exit fi -# Check that at least one of the real commands was actually selected, -# otherwise we don't know what to execute. +# If, say, SPACK_CC is set but SPACK_FC is not, we want to know. Compilers do not +# *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 - 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 # @@ -755,7 +756,7 @@ if [ -n "${SPACK_TEST_COMMAND=}" ]; then eval "printf '%s\n' \"\$0: \$var: \$$var\"" ;; *) - die "ERROR: Unknown test command: '$SPACK_TEST_COMMAND'" + die "Unknown test command: '$SPACK_TEST_COMMAND'" ;; esac fi -- cgit v1.2.3-60-g2f50