Kbuild: pass headers to headers_install.sh on stdin
PATCH 1/1 Kbuild: pass headers to headers_install.sh on stdin
While using make V=1 to test some things, I noticed on our builders that headers_install was failing because the argument list to /bin/sh was too long. Working around it is slightly kludgy...
First, passing the args list to headers_install.sh via stdin instead of as arguments.
Secondly, filtering $srctree out of $input-files to reduce the length of the args list to the subshell.
Lastly, re-add $srctree when we loop over $input-files and pass the file list back through to headers_install.sh.
You can reproduce the issue locally by putting your build dir in a long path.
make[2]: execvp: /bin/sh: Argument list too long make[2]: ***
[/home/kyle/A(lots of times)/linux/usr/include/linux/.install] Error 127
make[1]: *** [linux] Error 2
make: *** [headers_install] Error 2
scripts/Makefile.headersinst +5 -1
@@ -59,6 +59,8 @@ input-files := $(foreach hdr, $(header-y), \ $(wildcard $(gendir)/$(hdr)), \ $(error Missing generated UAPI file $(gendir)/$(hdr)) \ )) +input-files := $(foreach hdr, $(input-files), \ + $(subst $(srctree)/,,$(hdr))) # Work out what needs to be removed oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
@@ -72,7 +74,9 @@ printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@)) quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ file$(if $(word 2, $(all-files)),s)) cmd_install = \ - $(CONFIG_SHELL) $< $(installdir) $(input-files); \ + for f in $(input-files); do \ + echo "$(srctree)/$$f"; \ + done | $(CONFIG_SHELL) $< $(installdir); \ for F in $(wrapper-files); do \ echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ done; \
scripts/headers_install.sh +3 -4
@@ -2,7 +2,7 @@ if [ $# -lt 1 ] then - echo "Usage: headers_install.sh OUTDIR [FILES...] + echo "Usage: FILES | headers_install.sh OUTDIR echo echo "Prepares kernel header files for use by user space, by removing" echo "all compiler.h definitions and #includes, removing any"
@@ -10,7 +10,7 @@ then echo "asm/inline/volatile keywords." echo echo "OUTDIR: directory to write each userspace header FILE to." - echo "FILES: list of header files to operate on." + echo "FILES: list of header files to operate on, passed stdin." exit 1 fi
@@ -18,13 +18,12 @@ fi # Grab arguments OUTDIR="$1" -shift # Iterate through files listed on command line FILE= trap 'rm -f "$OUTDIR/$FILE" "$OUTDIR/$FILE.sed"' EXIT -for i in "$@" +while read i do FILE="$(basename "$i")" sed -r \
Dne 6.6.2013 19:05, Kyle McMartin napsal(a):
Quoted 3 lines
While using make V=1 to test some things, I noticed on our builders that
headers_installwas failing because the argument list to/bin/shwas too long. Working around it is slightly kludgy...
This is already fixed with
commit c0ff68f1611d6855a06d672989ad5cfea160a4eb
Author: Nicolas Dichtel <[email protected]> Date: Mon Apr 29 14:15:51 2013 +0200
kbuild: fix make headers_install when path is too long
in linux-next.
Michal
Quoted 8 lines · Michal Marek
Dne 6.6.2013 19:05, Kyle McMartin napsal(a):
Quoted 3 lines
While using make V=1 to test some things, I noticed on our builders that
headers_installwas failing because the argument list to/bin/shwas too long. Working around it is slightly kludgy...This is already fixed with
Quoted 9 lines
commit
c0ff68f1611d6855a06d672989ad5cfea160a4ebAuthor: Nicolas Dichtel <[email protected]> Date: Mon Apr 29 14:15:51 2013 +0200kbuild: fix make
headers_installwhen path is too longin linux-next.
OK, I guess.
--Kyle
Quoted 13 lines · Kyle McMartin
Quoted 12 lines · Michal Marek
Dne 6.6.2013 19:05, Kyle McMartin napsal(a):
Quoted 3 lines
While using make V=1 to test some things, I noticed on our builders that
headers_installwas failing because the argument list to/bin/shwas too long. Working around it is slightly kludgy...This is already fixed with
commit
c0ff68f1611d6855a06d672989ad5cfea160a4ebAuthor: Nicolas Dichtel <[email protected]> Date: Mon Apr 29 14:15:51 2013 +0200
Quoted 7 lines
Quoted 5 lines
kbuild: fix make
headers_installwhen path is too longin linux-next.
OK, I guess.
Wait... not OK. This is broken now. People are clearly having to fix it again and wasting their time because a fix is already available. Why is a fix for it sitting in linux-next? Please get that fix into Linus' tree.
josh
Dne 6.6.2013 19:59, Josh Boyer napsal(a):
Quoted 20 lines · Kyle McMartin
Quoted 19 lines · Michal Marek
Quoted 17 lines
Dne 6.6.2013 19:05, Kyle McMartin napsal(a):
Quoted 3 lines
While using make V=1 to test some things, I noticed on our builders that
headers_installwas failing because the argument list to/bin/shwas too long. Working around it is slightly kludgy...This is already fixed with
commit
c0ff68f1611d6855a06d672989ad5cfea160a4ebAuthor: Nicolas Dichtel <[email protected]> Date: Mon Apr 29 14:15:51 2013 +0200kbuild: fix make
headers_installwhen path is too longin linux-next.
Quoted 6 lines
Quoted 1 line
OK, I guess.
Wait... not OK. This is broken now. People are clearly having to fix it again and wasting their time because a fix is already available. Why is a fix for it sitting in linux-next? Please get that fix into Linus' tree.
This bug has been there for about five years (as far as I can tell, it was introduced by 7712401). It is a coincidence that two people report it now within a couple of weeks, but IMO this does not make the bug so urgent that it can't wait for the next -rc1.
Michal