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

Re: [XEN PATCH v2 1/4] build,include: rework shell script for headers++.chk


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 15 Jun 2022 08:37:42 +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=wQh1eZRoccmbIlRrRVPPkQHkKBonLorlgOIhyZcQf3g=; b=iOwIbvgXoFWHlLF+B8JGZqODky0cfA40bRHPBPYFf/UoeZR2EE6zUpsTJENdXzc+EEkuQRP1aWUn3XpACb0syyzMP/hoHaxqHPpuze+dcG9dEbmHSYLw8ME/E83MpOyRiEyXBaaQo25nrNsfiUO/hphLsGG2wL8A680aAtkbXfrDtOZwjBgqYg+hfuez2HRT+0xa6QITSsAA1UdC/QvguedEzusntNfhoKCJ2s+PlNi8zR+LYkxlDBrx37QAbSYSnSOOsVidh1Rojc+FlKL0q4byJPMOAvhkxsbQiGkYKqalHdiADU+kVUqtDWvyoa8roYXU1lKkKX9RY21BDkF3eA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nSyA5ZVGzKgV6UifqovkE5NeeDXY1KHn2wKXAUF2OczJDWlRg1z0bDh/YesXrPvXbxsztKK2iJuQ+2kejfZ3z6FRE17ePIckOe82o/Nj1vEgsN5OdSzyZdsxAQRU1YY94pdULz3k9doq6/28lFamwXqohxyOn/rcZBXrMlfq0cjdTxHZdtf/ZI5NrgPTLMVOAxqN7RlERf7FGnZBMdMSDsFg44T4tcujKdVNPz3jYCX90YSg79dbghGe+m/kLEZxcyd1PUIFROkkm/Ud6fir66Ims4+1FsQG1hm4aNyz+Vw8KcKUrCJAAs0cRVuMBFEfRloE7MfVJy77LtcknXq3/g==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 15 Jun 2022 06:37:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.06.2022 18:22, Anthony PERARD wrote:
> The command line generated for headers++.chk by make is quite long,
> and in some environment it is too long. This issue have been seen in
> Yocto build environment.
> 
> Error messages:
>     make[9]: execvp: /bin/sh: Argument list too long
>     make[9]: *** [include/Makefile:181: include/headers++.chk] Error 127
> 
> Rework so that we do the foreach loop in shell rather that make to
> reduce the command line size by a lot. We also need a way to get
> headers prerequisite for some public headers so we use a switch "case"
> in shell to be able to do some simple pattern matching. Variables
> alone in POSIX shell don't allow to work with associative array or
> variables with "/".
> 
> Reported-by: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
> Fixes: 28e13c7f43 ("build: xen/include: use if_changed")
> Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> ---
> 
> Notes:
>     v2:
>     - fix typo in commit message
>     - fix out-of-tree build
>     
>     v1:
>     - was sent as a reply to v1 of the series
> 
>  xen/include/Makefile | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/include/Makefile b/xen/include/Makefile
> index 6d9bcc19b0..49c75a78f9 100644
> --- a/xen/include/Makefile
> +++ b/xen/include/Makefile
> @@ -158,13 +158,22 @@ define cmd_headerscxx_chk
>           touch $@.new;                                                     \
>           exit 0;                                                           \
>       fi;                                                                   \
> -     $(foreach i, $(filter %.h,$^),                                        \
> -         echo "#include "\"$(i)\"                                          \
> +     get_prereq() {                                                        \
> +         case $$1 in                                                       \
> +         $(foreach i, $(filter %.h,$^),                                    \
> +         $(if $($(patsubst $(srctree)/%,%,$(i))-prereq),                   \
> +             $(i)$(close)                                                  \
> +             echo "$(foreach j, $($(patsubst $(srctree)/%,%,$(i))-prereq), \
> +                     -include c$(j))";;))                                  \
> +         esac;                                                             \

If I'm reading this right (indentation looks to be a little misleading
and hence one needs to count parentheses) the case statement could (in
theory) remain without any "body". As per the command language spec I'm
looking at this (if it works in the first place) is an extension, and
formally there's always at least one label required. Since we aim to be
portable in such regards, I'd like to request that there be a final
otherwise empty *) line.

> +     };                                                                    \
> +     for i in $(filter %.h,$^); do                                         \
> +         echo "#include "\"$$i\"                                           \
>           | $(CXX) -x c++ -std=gnu++98 -Wall -Werror -D__XEN_TOOLS__        \
>             -include stdint.h -include $(srcdir)/public/xen.h               \
> -           $(foreach j, $($(patsubst $(srctree)/%,%,$i)-prereq), -include 
> c$(j)) \
> +           `get_prereq $$i`                                                \

While I know we use back-ticked quoting elsewhere, I'd generally
recommend to use $() for readability. But maybe others view this
exactly the other way around ...

And a question without good context to put at: Isn't headers99.chk in
similar need of converting? It looks only slightly less involved than
the C++ one.

Jan

>             -S -o /dev/null -                                               \
> -         || exit $$?; echo $(i) >> $@.new;) \
> +         || exit $$?; echo $$i >> $@.new; done;                            \
>       mv $@.new $@
>  endef
>  




 


Rackspace

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