Skip to content

Commit e6c498a

Browse files
committed
compiler-wrapper: improve error message when no dep on c, cxx, fortran (#1100)
* show the missing `depends_on` statement when language specific environment variables are not set, to help users troubleshoot the issue: ``` SPACK_CC_* variables not set: this usually means a missing `depends_on("c", type="build")` in package.py ``` * ensure that `die` outputs errors that are recognized by `spack log-parse`.
1 parent 38dc29d commit e6c498a

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

cc.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ SPACK_MANAGED_DIRS"
6464
# die MESSAGE
6565
# Print a message and exit with error code 1.
6666
die() {
67-
echo "[spack cc] ERROR: $*"
67+
echo "[spack cc]: Error: $*"
6868
exit 1
6969
}
7070

@@ -282,7 +282,6 @@ fi
282282
# Figure out the type of compiler, the language, and the mode so that
283283
# the compiler script knows what to do.
284284
#
285-
# Possible languages are C, C++, Fortran 77, and Fortran 90.
286285
# 'command' is set based on the input command to $SPACK_[CC|CXX|F77|F90]
287286
#
288287
# 'mode' is set to one of:
@@ -307,31 +306,31 @@ case "$command" in
307306
;;
308307
cc|c89|c99|gcc|clang|armclang|icc|icx|pgcc|nvc|xlc|xlc_r|fcc|amdclang|cl.exe|craycc)
309308
command="$SPACK_CC"
310-
language="C"
309+
vdep=c
311310
comp="CC"
312311
lang_flags=C
313312
debug_flags="-g"
314313
vcheck_flags="${SPACK_ALWAYS_CFLAGS}"
315314
;;
316315
c++|CC|g++|clang++|armclang++|icpc|icpx|pgc++|nvc++|xlc++|xlc++_r|FCC|amdclang++|crayCC)
317316
command="$SPACK_CXX"
318-
language="C++"
317+
vdep=cxx
319318
comp="CXX"
320319
lang_flags=CXX
321320
debug_flags="-g"
322321
vcheck_flags="${SPACK_ALWAYS_CXXFLAGS}"
323322
;;
324323
ftn|f90|fc|f95|gfortran|flang|armflang|ifort|ifx|pgfortran|nvfortran|xlf90|xlf90_r|nagfor|frt|amdflang|crayftn)
325324
command="$SPACK_FC"
326-
language="Fortran 90"
325+
vdep=fortran
327326
comp="FC"
328327
lang_flags=F
329328
debug_flags="-g"
330329
vcheck_flags="${SPACK_ALWAYS_FFLAGS}"
331330
;;
332331
f77|xlf|xlf_r|pgf77)
333332
command="$SPACK_F77"
334-
language="Fortran 77"
333+
vdep=fortran
335334
comp="F77"
336335
lang_flags=F
337336
debug_flags="-g"
@@ -397,12 +396,11 @@ fi
397396
dtags_to_add="${SPACK_DTAGS_TO_ADD}"
398397
dtags_to_strip="${SPACK_DTAGS_TO_STRIP}"
399398

400-
linker_arg="ERROR: LINKER ARG WAS NOT SET, MAYBE THE PACKAGE DOES NOT DEPEND ON ${comp}?"
401-
eval "linker_arg=\${SPACK_${comp}_LINKER_ARG:?${linker_arg}}"
402-
403-
# Set up rpath variable according to language.
404-
rpath="ERROR: RPATH ARG WAS NOT SET, MAYBE THE PACKAGE DOES NOT DEPEND ON ${comp}?"
405-
eval "rpath=\${SPACK_${comp}_RPATH_ARG:?${rpath}}"
399+
eval "linker_arg=\"\$SPACK_${comp}_LINKER_ARG\""
400+
eval "rpath=\"\$SPACK_${comp}_RPATH_ARG\""
401+
if [ -z "$linker_arg" ] || [ -z "$rpath" ]; then
402+
die "SPACK_${comp}_* variables not set: this usually means a missing \`depends_on(\"$vdep\", type=\"build\")\` in package.py"
403+
fi
406404

407405
# Dump the mode and exit if the command is dump-mode.
408406
if [ "$SPACK_TEST_COMMAND" = "dump-mode" ]; then
@@ -620,7 +618,7 @@ categorize_arguments() {
620618
# library. Filter it out.
621619
# TODO: generalize filtering of args with an env var, so that
622620
# TODO: we do not have to special case this here.
623-
if { [ "$mode" = "ccld" ] || [ $mode = "ld" ]; } \
621+
if { [ "$mode" = "ccld" ] || [ "$mode" = "ld" ]; } \
624622
&& [ "$1" != "${1#-loopopt}" ]; then
625623
shift
626624
continue

0 commit comments

Comments
 (0)