[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: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Fri, 11 Aug 2023 14:48:21 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • 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: Fri, 11 Aug 2023 13:48:37 +0000
  • Ironport-data: A9a23:BDpqiKo94Q0cPrzj1gqHG24VHm5eBmLJZRIvgKrLsJaIsI4StFCzt garIBmGO/+MZWGhfop0Pdm39R9QuZGEyoRqHFZspX83FnlHpJuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GpwUmAWP6gR5weOziBNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXACwqagmugsDt/LGYRLVRusk7Nc/kYpxK7xmMzRmBZRonaZXKQqGM7t5ExjYgwMtJGJ4yZ eJAN2ApNk6ZJUQSZBFOUslWcOSA3xETdxVRrk6VoqwmpXDe1gVr3JDmMcbPe8zMTsJQ9qqdj jufrj6lU01DbbRzzxKe8Vu+jKzPuRjqc5keHeyfr9pIrGWMkzl75Bo+CgLg/KjRZlSFc9BVJ lEQ+yEuhbMv70HtRd74NzWorXjBshMCVt54F+wh9BrL2qfS+xyeBGUPUnhGctNOnM0rQT0n0 HeZktWvAiZg2JWOUm6U/LqQqTK0OAAWIHUEaCtCShEKi/H8pKkjgxSJScxseIa8ltDvECv86 yyLpiM5wb4UiKY2O76TpA6dxWj2/96QE1Bzv1+MNo640u9nTJKCY5WF7HqA0fVjItqkclSZp X4LxdfLuYjiEqqxvCCKRewMGpSg6PCELCDQjDZTInUxy9i+0yX9JN4NuVmSMG8sa59ZImGxP Cc/rCsLvPdu0G2Wgbibim5bI+Aj1uDeGNvsTZg4hfIeM8EqJGdrEMyDDHN8PlwBcmB2zcnT2 r/BK65A6Er27ow2pAdav89HjdcWKtkWnAs/v6zTwRW9yqa5b3WIU7oDO1bmRrlnvfra8V+Pr IcBapDiJ/BjvAvWOHa/HWk7dwpiEJTGLcqu95w/mhCrfWKK513N+9eOmOh8KuSJboxel/vS/ 2HVZ6Or4AOXuJEzEi3TMioLQOq2Df5CQYcTYXRE0aCAhyJyPu5CLc43K/MKQFXQ3LA6laElF aVVIJno7zYmYm2vxgnxpKLV9ORKHClHTyrUV8Z5SFDTp6JdejE=
  • Ironport-hdrordr: A9a23:fvHIwK7/zkLzpo1KVQPXwFfXdLJyesId70hD6qkRc20uTiX8ra qTdZsgtSMc9wxhOk3I9erwQJVoIkmzyXcW2/h2AZ6YUAHtuW21Mbx45YHhzyaIIVyaygc178 4JGJSWY+eAdGSS4/yKmzWQIpIJytOA7Ke0wcDZ0ndjTQtjdqFn6ENFGh+We3cGJzWuxqBUKH Nf3Kd6TvabFkg/X4CdAGQEUOjIr8DKkpX9CCR2YyIP2U2oiy6p577xGwWZ2BAFFxhI3bAp/S zklAP+j5/T1M1TAyW861Pu
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

But isn't it doing doing pattern matching on an error message going to
lead sometime to false positive? 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


In any case, the patch is fine.
Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>

Thanks,

-- 
Anthony PERARD



 


Rackspace

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