Skip to content

Commit c0ff68f

Browse files
NicolasDichtelmichal42
authored andcommitted
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>
1 parent f722406 commit c0ff68f

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

scripts/Makefile.headersinst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,24 @@ header-y := $(filter-out $(generic-y), $(header-y))
4747
all-files := $(header-y) $(genhdr-y) $(wrapper-files)
4848
output-files := $(addprefix $(installdir)/, $(all-files))
4949

50-
input-files := $(foreach hdr, $(header-y), \
50+
input-files1 := $(foreach hdr, $(header-y), \
5151
$(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)),, \
5357
$(if $(wildcard $(oldsrcdir)/$(hdr)), \
5458
$(wildcard $(oldsrcdir)/$(hdr)), \
5559
$(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), \
5863
$(if $(wildcard $(gendir)/$(hdr)), \
5964
$(wildcard $(gendir)/$(hdr)), \
6065
$(error Missing generated UAPI file $(gendir)/$(hdr)) \
6166
))
67+
input-files3-name := $(notdir $(input-files3))
6268

6369
# Work out what needs to be removed
6470
oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
@@ -72,7 +78,9 @@ printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
7278
quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
7379
file$(if $(word 2, $(all-files)),s))
7480
cmd_install = \
75-
$(CONFIG_SHELL) $< $(installdir) $(input-files); \
81+
$(CONFIG_SHELL) $< $(installdir) $(srcdir) $(input-files1-name); \
82+
$(CONFIG_SHELL) $< $(installdir) $(oldsrcdir) $(input-files2-name); \
83+
$(CONFIG_SHELL) $< $(installdir) $(gendir) $(input-files3-name); \
7684
for F in $(wrapper-files); do \
7785
echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \
7886
done; \
@@ -98,7 +106,7 @@ __headersinst: $(subdirs) $(install-file)
98106
@:
99107

100108
targets += $(install-file)
101-
$(install-file): scripts/headers_install.sh $(input-files) FORCE
109+
$(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE
102110
$(if $(unwanted),$(call cmd,remove),)
103111
$(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
104112
$(call if_changed,install)

scripts/headers_install.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
if [ $# -lt 1 ]
44
then
5-
echo "Usage: headers_install.sh OUTDIR [FILES...]
5+
echo "Usage: headers_install.sh OUTDIR SRCDIR [FILES...]
66
echo
77
echo "Prepares kernel header files for use by user space, by removing"
88
echo "all compiler.h definitions and #includes, removing any"
99
echo "#ifdef __KERNEL__ sections, and putting __underscores__ around"
1010
echo "asm/inline/volatile keywords."
1111
echo
1212
echo "OUTDIR: directory to write each userspace header FILE to."
13+
echo "SRCDIR: source directory where files are picked."
1314
echo "FILES: list of header files to operate on."
1415

1516
exit 1
@@ -19,6 +20,8 @@ fi
1920

2021
OUTDIR="$1"
2122
shift
23+
SRCDIR="$1"
24+
shift
2225

2326
# Iterate through files listed on command line
2427

@@ -34,7 +37,7 @@ do
3437
-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
3538
-e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \
3639
-e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \
37-
"$i" > "$OUTDIR/$FILE.sed" || exit 1
40+
"$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
3841
scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
3942
> "$OUTDIR/$FILE"
4043
[ $? -gt 1 ] && exit 1

0 commit comments

Comments
 (0)