summaryrefslogtreecommitdiff
path: root/lib/spack/env
diff options
context:
space:
mode:
authorTom Scogland <scogland1@llnl.gov>2022-05-23 21:57:09 -0700
committerGitHub <noreply@github.com>2022-05-24 00:57:09 -0400
commit330832c22cfa59554f6681a570bdec24ca46e79b (patch)
tree16766a69925ee06f1641df007de0baf96faa131a /lib/spack/env
parent306bed48d747c907cfbd60073cdf6d92c3bca14a (diff)
downloadspack-330832c22cfa59554f6681a570bdec24ca46e79b.tar.gz
spack-330832c22cfa59554f6681a570bdec24ca46e79b.tar.bz2
spack-330832c22cfa59554f6681a570bdec24ca46e79b.tar.xz
spack-330832c22cfa59554f6681a570bdec24ca46e79b.zip
strip -Werror: all specific or none (#30284)
Add a config option to strip `-Werror*` or `-Werror=*` from compile lines everywhere. ```yaml config: keep_werror: false ``` By default, we strip all `-Werror` arguments out of compile lines, to avoid unwanted failures when upgrading compilers. You can re-enable `-Werror` in your builds if you really want to, with either: ```yaml config: keep_werror: all ``` or to keep *just* specific `-Werror=XXX` args: ```yaml config: keep_werror: specific ``` This should make swapping in newer versions of compilers much smoother when maintainers have decided to enable `-Werror` by default.
Diffstat (limited to 'lib/spack/env')
-rwxr-xr-xlib/spack/env/cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index bef7209bfa..6ce60a8730 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -401,7 +401,8 @@ input_command="$*"
# command line and recombine them with Spack arguments later. We
# parse these out so that we can make sure that system paths come
# last, that package arguments come first, and that Spack arguments
-# are injected properly.
+# are injected properly. Based on configuration, we also strip -Werror
+# arguments.
#
# All other arguments, including -l arguments, are treated as
# 'other_args' and left in their original order. This ensures that
@@ -440,6 +441,29 @@ while [ $# -ne 0 ]; do
continue
fi
+ if [ -n "${SPACK_COMPILER_FLAGS_KEEP}" ] ; then
+ # NOTE: the eval is required to allow `|` alternatives inside the variable
+ eval "\
+ case '$1' in
+ $SPACK_COMPILER_FLAGS_KEEP)
+ append other_args_list "$1"
+ shift
+ continue
+ ;;
+ esac
+ "
+ fi
+ if [ -n "${SPACK_COMPILER_FLAGS_REMOVE}" ] ; then
+ eval "\
+ case '$1' in
+ $SPACK_COMPILER_FLAGS_REMOVE)
+ shift
+ continue
+ ;;
+ esac
+ "
+ fi
+
case "$1" in
-isystem*)
arg="${1#-isystem}"