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

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


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 14 Aug 2023 09:06:44 +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=z2woV/ng/nyzy+lSTOkMPdiFfI4fnGFigN9WwfghKkc=; b=DqmlozNJpYGqJy0ZeP22kc3TkFQajm+Mna8ChhrFGLnse1i+vdXt8br8zltsqXx42+9ij2CoRzg0n7MJP80JnhN0/UrKT96bXmD/BQvUvX3IZBvcGp+RfKBH3YoX3vpANFY9oEtzR2jEkl9z4GpwcxVX3E11heNll2mXfncC6WIvePQQ+RyaHqhfcbvDHUS/UVed6pOuMO8SaTtp82MZKLB/BnCdDXHHQGL6ouBqL+S03EwpsYmvbBw9D49dAf9UJUM3Iw304leB6Z6uxNvoBAHEhmcm7EHEASz7hlsMjhvUFwiVLnUWuuV6Oim46PzB9STwv+AuJ++IilQeADYg5g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HR7ex3eM4ppj1CkOWSezEQQHw8uMp//zHXHI61f9FwysJawTrRXG2zUJ7LPWxGcVqIJQH0jUi6Rt68NMNNlmDwRER7EEO4NHA7ae4LiTwJw2e2wR0dFpV/lQBp8DTnqgenr5/FhrjfWeUV93p7UpvLfd3ivwzanM/6QX+9nQH28ZdfRjmk51Cn7ysnK4M0NqKBaiCQcaF3bu/hMAR0Ydnt/1zB5Gfhl01nOUwZFsVSSDDwSi2argqynJIvQIX+JBYRsGustvZbwBSBxjzle6zntbLDmLxUC4IuYRzkAN2yOwkr5CW6Ioupk2X4Yf13XgrvPlJL/dAsT8VXxc6W5tDA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, 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>
  • Delivery-date: Mon, 14 Aug 2023 07:06:54 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.08.2023 09:01, Jan Beulich wrote:
> On 11.08.2023 15:48, Anthony PERARD wrote:
>> On Wed, Jul 26, 2023 at 12:33:07PM +0200, Jan Beulich wrote:
>>> 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;)
>>
>> This patch looks fine. Shouldn't the comment been updated as well? At
>> the moment, it only discuss about -Wno-*, which it seems is why `grep`
>> was introduced in the first place.
> 
> Right, but that has been an issue already before.
> 
>> But isn't it doing doing pattern matching on an error message going to
>> lead sometime to false positive?
> 
> There's a certain risk, of course.
> 
>> Linux's build system seems to works
>> fine by just using the exit value. They've got a few trick to deal with
>> -Wno-* and with clang.
>>
>> For -Wno-$(warning), they test -W$(warning) instead. For clang, they've
>> enable additional warnings:
>>     -Werror=unknown-warning-option
>>     -Werror=ignored-optimization-argument
>>     -Werror=option-ignored
>>     -Werror=unused-command-line-argument
> 
> Ah, yes, this would likely be a better way to test things. Time to redo
> what was done 12 years ago. I guess for the purpose of this series I'll
> keep what I have, but take note to rework things afterwards (which now
> would likely mean post-4.18, as the new-submissions deadline has passed).

Hmm, or maybe I could simply call this v4 then, especially when directly
integrating -Wno-* handling right here (by suitably using $(patsubst ...).
The extra Clang aspects (if indeed needed; didn't check yet) may not
easily be coverable that way, though.

Jan



 


Rackspace

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