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

[PATCH v2 1/4] build: make cc-option properly deal with unrecognized sub-options


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 19 Jul 2023 11:43:46 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z83+4fe8wofcAMxwXz+EOVByzKrzaNqIk9SWCUEUwCk=; b=Nd0eiKBVRluNQKj9i0Z9ZGs4DI6BPUlrPxuLGsHcpeYFUUsQBVPrBtPhCzCFPgejVFus6R1iiAQ3bS4WitDrqDSqjKn5TwpqcwNwrBx2HbX0fCi6GsPgPgp3NuUCYkE8H61jiDI3RjFeX/F28OuXR3A/+8088GscdtKSuOlLOS+hQMlkBMNWH1FCjAcpyOmPiSuBknnIBObGHNLSCl7FlufqgJrN66FC9OpkQj3O3JcGjnejT2uPTvj3TDxVPlJp58itGul+l1IIPGImBBxZm3/HEsereID1nFukZYYsHLR3baOQM+jInLnKD/zdSNKaO2GfnhfKCxMaGU++/Lfa9Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gj0dCoej+ia+2mBWKbvdq2P/GuVb74PigAfecpC1r4t99+8R7WOoqj2Ll2qHvEaFvDFiUzSYL9KJY3RARyyH0K+Lo789GkAj0275ETW6k3JJmFemQhebBKqlr5N8WQl9JuYGSz6iijwP6asMpYCGUopCdTwbNqiun8lOo75VUtNP+DxI0nLbjgwcVJsm7W8h1oq9k49XILis7bJBOBEearAvkDyS+E9iBlPhvpyHqAq7mlFrsY4OKxujAWAhG7+S1p3PqA4UrDJJc9ITAhWazlVyG5VB3rLwNHU0fpbBinjxMch0Bhl2KqqR4wPiRyPgOPr2/TRKfJtoSZ6sjkZlyA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Wed, 19 Jul 2023 09:44:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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 accordingly,
also accounting for Clang to not mention e.g. -march at all when an
incorrect argument was given for it.

To keep things halfway readable, re-wrap and re-indent the entire
construct.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
In principle -e "$$pat" could now be omitted from the grep invocation,
since if that matches, both $$opt and $$arg will, too. But I thought I'd
leave it for completeness.
---
v2: Further relax grep patterns for clang, which doesn't mention -march
    when complaining about an invalid argument to it.

--- 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 "$$opt" -e "$$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)




 


Rackspace

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