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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 26 Jul 2023 12:33:07 +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=BUQNrBvwkCW3i8IvMZ9HOVhTuG/uMRjUcx7MUJQ2KDs=; b=BqiMFfDHMyCh6kt6o/J9vFXJIUoOERDjuXhf5T1MLG3pWGLRbEZLfTovXT0Pzn7MySSZPP8lCDTm9dj2/4htp5A3y0XOkyEr2tv9J7r/SNd/5P7Nhp4MxH4IQrEa+lQsIHy+Wj8KwkTs+u4+fj1ZzPIN2j74gpHjHctJJOe3uRcLi13Lms5zNnPsiJPE4BE4gaNwnYX8bFfPmECT1svyAK0z62jamfAFg5fPy0bUO+mdhMuChIyl7z+wD8KMOD0VVszkoGzIpb8g4B0FVREKxY93KT4DKacYiLeVOlH84Lbev69trJInBcfllr8Pzvh8xGRVoiWB/k7hWUM77Cxbsw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kEKu4H5/KA/7ug4A//MCHkUTExtYmWcW/xp8/4bv4ryRMoP93r/tTQKpTowX/7UUjIsKFADjfRdnWVnaq2W3+c30od/O0RgZeL8O0kheB6g1AYz7gxbLU6w/q4GU5XKKRZc+0aA4t5G8pLIITEdKEge5HXrKUWw+ourARIPSDso1854UhPksdXc/YOX7puoRGrKx5M01BfjcCSzpd4jF2IIb/BQSNHLswzwnFMrBnFljPk9k5Qo+goRQ5JVomfs8+FqYK8QEnHfouFenf/i0ThCBuSt/SW/g8AznOdtbrXK81YuJtGebOedW8tgve601oGg0XXdhrxr3dE+a9NVwOg==
  • 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, 26 Jul 2023 10:33:15 +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.
---
v3: Fix build with make 4.3 and newer, where the treatment of \# has
    changed.
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
@@ -8,6 +8,7 @@ endif
 comma   := ,
 open    := (
 close   := )
+sharp   := \#
 squote  := '
 #' Balancing squote, to help syntax highlighting
 empty   :=
@@ -90,9 +91,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$(sharp)*=}"; \
+                    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®.