Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: fix make headers_install when path is too long

If headers_install is executed from a deep/long directory structure, the
shell's maximum argument length can be execeeded, which breaks the operation
with:

| make[2]: execvp: /bin/sh: Argument list too long
| make[2]: ***

Instead of passing each files name with the entire path, I give only the file
name without the source path and give this path as a new argument to
headers_install.pl.

Because there is three possible paths, I have tree input-files list, one per
path.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Tested-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>

authored by

Nicolas Dichtel and committed by
Michal Marek
c0ff68f1 f722406f

+19 -8
+14 -6
scripts/Makefile.headersinst
··· 47 47 all-files := $(header-y) $(genhdr-y) $(wrapper-files) 48 48 output-files := $(addprefix $(installdir)/, $(all-files)) 49 49 50 - input-files := $(foreach hdr, $(header-y), \ 50 + input-files1 := $(foreach hdr, $(header-y), \ 51 51 $(if $(wildcard $(srcdir)/$(hdr)), \ 52 - $(wildcard $(srcdir)/$(hdr)), \ 52 + $(wildcard $(srcdir)/$(hdr))) \ 53 + ) 54 + input-files1-name := $(notdir $(input-files1)) 55 + input-files2 := $(foreach hdr, $(header-y), \ 56 + $(if $(wildcard $(srcdir)/$(hdr)),, \ 53 57 $(if $(wildcard $(oldsrcdir)/$(hdr)), \ 54 58 $(wildcard $(oldsrcdir)/$(hdr)), \ 55 59 $(error Missing UAPI file $(srcdir)/$(hdr))) \ 56 - )) \ 57 - $(foreach hdr, $(genhdr-y), \ 60 + )) 61 + input-files2-name := $(notdir $(input-files2)) 62 + input-files3 := $(foreach hdr, $(genhdr-y), \ 58 63 $(if $(wildcard $(gendir)/$(hdr)), \ 59 64 $(wildcard $(gendir)/$(hdr)), \ 60 65 $(error Missing generated UAPI file $(gendir)/$(hdr)) \ 61 66 )) 67 + input-files3-name := $(notdir $(input-files3)) 62 68 63 69 # Work out what needs to be removed 64 70 oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) ··· 78 72 quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ 79 73 file$(if $(word 2, $(all-files)),s)) 80 74 cmd_install = \ 81 - $(CONFIG_SHELL) $< $(installdir) $(input-files); \ 75 + $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(input-files1-name); \ 76 + $(CONFIG_SHELL) $< $(installdir) $(oldsrcdir) $(input-files2-name); \ 77 + $(CONFIG_SHELL) $< $(installdir) $(gendir) $(input-files3-name); \ 82 78 for F in $(wrapper-files); do \ 83 79 echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ 84 80 done; \ ··· 106 98 @: 107 99 108 100 targets += $(install-file) 109 - $(install-file): scripts/headers_install.sh $(input-files) FORCE 101 + $(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE 110 102 $(if $(unwanted),$(call cmd,remove),) 111 103 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) 112 104 $(call if_changed,install)
+5 -2
scripts/headers_install.sh
··· 2 2 3 3 if [ $# -lt 1 ] 4 4 then 5 - echo "Usage: headers_install.sh OUTDIR [FILES...] 5 + echo "Usage: headers_install.sh OUTDIR SRCDIR [FILES...] 6 6 echo 7 7 echo "Prepares kernel header files for use by user space, by removing" 8 8 echo "all compiler.h definitions and #includes, removing any" ··· 10 10 echo "asm/inline/volatile keywords." 11 11 echo 12 12 echo "OUTDIR: directory to write each userspace header FILE to." 13 + echo "SRCDIR: source directory where files are picked." 13 14 echo "FILES: list of header files to operate on." 14 15 15 16 exit 1 ··· 19 18 # Grab arguments 20 19 21 20 OUTDIR="$1" 21 + shift 22 + SRCDIR="$1" 22 23 shift 23 24 24 25 # Iterate through files listed on command line ··· 37 34 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ 38 35 -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ 39 36 -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ 40 - "$i" > "$OUTDIR/$FILE.sed" || exit 1 37 + "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 41 38 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ 42 39 > "$OUTDIR/$FILE" 43 40 [ $? -gt 1 ] && exit 1