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

Re: [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: Fri, 21 Jul 2023 07:52: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=qItS7tULWpEoXGK8qSfHuaaQHSiXsvIKMSCmCACX/Vk=; b=neke5Wcc9fQnBgRoAoJ/91zGKwpmyKgGgHrzqLNTOkpZhP/vdyOYD5sEuH7YqzfZrqSO91IjMn5f/zfXIjCa7t1hiCZEwlzhsbUs4MzLGWMp0oWKBklbFMTjHm++Uax8CDCVx4GQ+FiEmBKHN3fyidXxxgdxFSTI9uPuCA4Oa3TvBqTdzAXnOuSFTnvRNfiF/CaOEiyp7EXe5G78NDL2KnUSQ+Ty+TvsuRX/miLTcNxkHfr41tTzQ8o57UU0dbpK9gpL2G6MmKHRjVg2uED6zBggvAiGSgGNqQuMCjlRc3X044VqmVxIWnlLuYTCjj0tFeMBLZEzEmmYSM38EwUwTA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R+Gc6HG5tQvk3UAdJyc+/NfhSC76frJ3Mhu88e0QPUpi9uk6KB447zMUPP8cfZ+q6GATdmrspQbuP3I3waUHAXe5WbDd2NhpCwzLE2TKDr0lraKC8UpEYlj+GvG2/qoPU23bz+vqrtGlapl3T/JALT+M5s/NFn2pp6UC2lFlWLpr3Zg5fXKS0AmrOZ4FkBQxSHwSyCYsuIUBRsy7J9F0sumynvc6lA0cAm4j7kAwKayUF8kS++yFSzXFMgNdkRNb9YQbgLWy/zuAnnfkRjIgMZ8T+jyaBY/JE3JqPug2lhIMv3Af9hMyNVwvgmfnrxNcVfVZXXM4pJAlWqL97VR1ow==
  • 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: Fri, 21 Jul 2023 05:52:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 19.07.2023 11:43, 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.
> ---
> v2: Further relax grep patterns for clang, which doesn't mention -march
>     when complaining about an invalid argument to it.

I wonder whether it would be sufficient (and a little less lax) ...

> --- 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" -`"; \

... to check for only $$arg here (which will be the same as $$pat when
there's no = in the full option).

In either case there's likely going to be an issue with options taking
very simple (e.g. plain numeric) arguments.

Jan

> +                    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®.