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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Tue, 14 Jun 2022 17:22:45 +0100
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 14 Jun 2022 16:23:13 +0000
  • Ironport-data: A9a23:INnBtaqiHdWsiaV2QScEX9XrRT9eBmILZRIvgKrLsJaIsI4StFCzt garIBmGb67YZWXye9kka9y3ph4H68fVz4c1SAZl+XsyQShE+JuZCYyVIHmrMnLJJKUvbq7GA +byyDXkBJppJpMJjk71atANlVEliefQAOCU5NfsYkidfyc9IMsaoU8lyrdRbrJA24DjWVvT4 I+q+aUzBXf+s9JKGjNMg068gEsHUMTa4Fv0aXRnOJinFHeH/5UkJMp3yZOZdhMUcaENdgKOf M7RzanRw4/s10xF5uVJMFrMWhZirrb6ZWBig5fNMkSoqkAqSicais7XOBeAAKv+Zvrgc91Zk b1wWZKMpQgBGJbyvLUkQRNkL2J/eoZG/Zz8L1KhmJnGp6HGWyOEL/RGCUg3OcsT+/ptAHEI/ vsdQNwPRknd3aTsmuv9E7QywJR4RCXoFNp3VnVIxDfFDfEgUNbbTr/D/9Nw1zYsnMFeW/3ZY qL1bBIwMk2cOUIQZz/7DrpvzOyPvEDZVwF58kjKiKs25GXO6k9+he2F3N39JYXRGJQ9clyjj mDb+2X0BDkKOdrZziCKmlq3nfPGly7/XIMUFZW7++RsjVnVwXYcYDUJUXOrrP//jVSxM/pPJ kpR9icwoKwa8E2wUsK7TxC+uGSDvBMXR5xXCeJSwCuA0LbO6gCVQE0NVCdcaccOvdUzAzct0 zehndnkGDhuu729Um+G+/GfqjbaBMQOBTZcP2leF1JDuoS95tFo5v7Scjp9OIiOsPmkICP6/ wzJrW8Vh7AwtsAhyYzuqDgrnAmQSoj1oh8dv1uKAzj8sVknOOZJdKTztwGFsK8owJKxCwDY4 SNaw5X2APUmV8nlqcCbfAka8FhFDd6hOSaUv1NgFoJJG9+Fqy/6JtA4DN2TyS5U3ic4ldzBO ha7Vft5vsM7AZdTRfYfj3iNI8or17P8Mt/uS+rZaNFDCrAoKlLapX0zPxHNhT+1+KTJrU3YE cbzTCpRJSxCVfQPIMSeHI/xLoPHNghhnDiOFPgXPjys0KaEZW79dIrpxGCmN7hjhIvd+V292 48Ga6OilkQEOMWjM3a/zGLmBQ1TRZTNLcuu+5I/my/qClcOJVzN/NeKnet9I9U8xPQK/goKl 1nkMnJlJJPErSWvAW23hrpLNNsDgb4XQaoHABER
  • Ironport-hdrordr: A9a23:eqfz2qvCXlfNHosKaMPgXT1E7skDctV00zEX/kB9WHVpm6uj5q aTdZUgpHjJYVMqMk3I9urvBEDtexzhHP1OkOss1NWZLW3bUQKTRekP0WKF+UyCJ8SXzIVgPM xbEpSWZueRMbErt6vHCEvRKadE/OW6
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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;                                                             \
+       };                                                                    \
+       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`                                                \
              -S -o /dev/null -                                               \
-           || exit $$?; echo $(i) >> $@.new;) \
+           || exit $$?; echo $$i >> $@.new; done;                            \
        mv $@.new $@
 endef
 
-- 
Anthony PERARD




 


Rackspace

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