[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] build: make cc-option properly deal with unrecognized sub-options



commit 824b5a40dd3de0bd58fa306f4be8d6e13e1c327d
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Aug 23 09:25:52 2023 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Aug 23 09:25:52 2023 +0200

    build: make cc-option properly deal with unrecognized sub-options
    
    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>'. Instead of extend the grep invocation, stop
    parsing compiler output altogether. Instead substitute -Wno-* options by
    their -W* counterparts for probing (obviously assuming that such a
    counterpart always exists).
    
    Suggested-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 Config.mk | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Config.mk b/Config.mk
index dc3afaa47e..29c29f8d7f 100644
--- a/Config.mk
+++ b/Config.mk
@@ -85,17 +85,17 @@ PYTHON_PREFIX_ARG ?= --prefix="$(prefix)"
 
 # cc-option: Check if compiler supports first option, else fall back to second.
 #
-# This is complicated by the fact that unrecognised -Wno-* options:
+# This is complicated by the fact that with most gcc versions unrecognised
+# -Wno-* options:
 #   (a) are ignored unless the compilation emits a warning; and
 #   (b) even then produce a warning rather than an error
-# To handle this we do a test compile, passing the option-under-test, on a code
-# fragment that will always produce a warning (integer assigned to pointer).
-# We then grep for the option-under-test in the compiler's output, the presence
-# of which would indicate an "unrecognized command-line option" warning/error.
+# Further Clang also only warns for unrecognised -W* options.  To handle this
+# we do a test compile, substituting -Wno-* by -W* and adding -Werror.  This
+# way all unrecognised options are diagnosed uniformly, allowing us to merely
+# check exit status.
 #
 # 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)%=%) -`"; \
+cc-option = $(shell if $(1) $(2:-Wno-%=-W%) -Werror -c -o /dev/null -x c 
/dev/null >/dev/null 2>&1; \
               then echo "$(2)"; else echo "$(3)"; fi ;)
 
 # cc-option-add: Add an option to compilation flags, but only if supported.
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.