In options like -march=, it may be only the sub-option which is
unrecognized by the compiler. In such an event the error message often
splits option and argument, typically saying something like "bad value
'<argument>' for '<option>'. Extend the grep invocation to check for
any of the three resulting variants.
To keep things halfway readable, re-wrap and re-indent the entire
construct.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
I'm sorry, re-sending with wider Cc list (as was intended originally).
--- a/Config.mk
+++ b/Config.mk
@@ -90,9 +90,14 @@ PYTHON_PREFIX_ARG ?= --prefix="$(prefix)
# of which would indicate an "unrecognized command-line option" warning/error.
#
# Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
-cc-option = $(shell if test -z "`echo 'void*p=1;' | \
- $(1) $(2) -c -o /dev/null -x c - 2>&1 | grep -- $(2:-Wa$(comma)%=%) -`"; \
- then echo "$(2)"; else echo "$(3)"; fi ;)
+cc-option = $(shell pat='$(2:-Wa$(comma)%=%)'; \
+ opt="$${pat%%=*}" arg="$${pat\#*=}"; \
+ if test -z "`echo 'void*p=1;' | \
+ $(1) $(2) -c -o /dev/null -x c - 2>&1 | \
+ grep -e "$$pat" -e "$$arg.*$$opt" -e "$$opt.*$$arg" -`"; \
+ then echo "$(2)"; \
+ else echo "$(3)"; \
+ fi;)
# cc-option-add: Add an option to compilation flags, but only if supported.
# Usage: $(call cc-option-add CFLAGS,CC,-march=winchip-c6)
On 12.07.2023 16:26, Jan Beulich wrote: > --- a/Config.mk > +++ b/Config.mk > @@ -90,9 +90,14 @@ PYTHON_PREFIX_ARG ?= --prefix="$(prefix) > # of which would indicate an "unrecognized command-line option" warning/error. > # > # Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586) > -cc-option = $(shell if test -z "`echo 'void*p=1;' | \ > - $(1) $(2) -c -o /dev/null -x c - 2>&1 | grep -- $(2:-Wa$(comma)%=%) -`"; \ > - then echo "$(2)"; else echo "$(3)"; fi ;) > +cc-option = $(shell pat='$(2:-Wa$(comma)%=%)'; \ > + opt="$${pat%%=*}" arg="$${pat\#*=}"; \ > + if test -z "`echo 'void*p=1;' | \ > + $(1) $(2) -c -o /dev/null -x c - 2>&1 | \ > + grep -e "$$pat" -e "$$arg.*$$opt" -e "$$opt.*$$arg" -`"; \ Sigh. At least some versions of Clang (I'm looking at 7.0.1 right now) don't quote "-march" in their resulting error message. So I guess all we can do (without finding a different approach to the checking altogether) is further relax the grep pattern, to grep -e "$$pat" -e "$$opt" -e "$$arg" - Of course this has the increasing risk of getting false positives (i.e. false negatives for the overall check result). Jan
© 2016 - 2024 Red Hat, Inc.