kbuild: Remove stale asm-generic wrappers
Subsystems (5)
v3 cover kbuild: Remove stale asm-generic wrappers
This patchset attempts to fix kbuild to automatically remove stale asm-generic wrappers, i.e. when files are removed from generic-y and added directly into arch/*/include/uapi/asm/, but where the existing wrapper in arch/*/include/generated/asm/ continues to be used.
MIPS was recently burned by this in v4.3 (see patch 2), with continuing reports of build failures when people upgrade their trees, which go away after arch/mips/include/generated is removed (or reportedly make mrproper/distclean). It is particularly irritating during bisection.
Since v2 I've seen other cases of this breaking MIPS build, and testing on x86_64, starting a build first on v4.0 and then on mainline with this patchset shows one stale generated header:
REMOVE arch/x86/include/generated/asm/scatterlist.h
Changes in v3:
- Ensure FORCE actually gets marked .PHONY.
Changes in v2:
- New patch 1 to add tracking of generated headers that aren't generic-y wrappers, via generated-y, particularly for x86 (thanks to kbuild test robot).
- Rewrite a bit, drawing inspiration from Makefile.headersinst.
- Exclude genhdr-y and generated-y (thanks to kbuild test robot).
James Hogan (2):
kbuild, x86: Track generated headers with generated-y
kbuild: Remove stale asm-generic wrappers
Documentation/kbuild/makefiles.txt | 14 ++++++++++++++ arch/x86/include/asm/Kbuild | 6 ++++++ scripts/Makefile.asm-generic | 17 ++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-)
Signature · 1 line
2.4.10
PATCH v3 1/2 kbuild, x86: Track generated headers with generated-y
Track generated header files which aren't already in genhdr-y, alongside generic-y wrappers in the */include/generated/[uapi/]asm/ directories. Currently only x86 generates extra headers in these directories, for the purposes of enumerating system calls for different ABIs, and xen hypercalls.
This will allow the asm-generic wrapper handling code to remove stale wrappers when files are removed from generic-y, without also removing these headers which are generated separately.
---
Changes in v2:
- New patch (thanks to kbuild test robot).
--- Documentation/kbuild/makefiles.txt | 14 ++++++++++++++ arch/x86/include/asm/Kbuild | 6 ++++++ 2 files changed, 20 insertions(+)
Documentation/kbuild/makefiles.txt +14 -0
@@ -47,6 +47,7 @@ This document describes the Linux kernel Makefiles. --- 7.2 genhdr-y --- 7.3 destination-y --- 7.4 generic-y + --- 7.5 generated-y === 8 Kbuild Variables === 9 Makefile language
@@ -1319,6 +1320,19 @@ See subsequent chapter for the syntax of the Kbuild file. Example: termios.h #include <asm-generic/termios.h> + --- 7.5 generated-y + + If an architecture generates other header files alongside generic-y + wrappers, and not included in genhdr-y, then generated-y specifies + them. + + This prevents them being treated as stale asm-generic wrappers and + removed. + + Example: + #arch/x86/include/asm/Kbuild + generated-y += syscalls_32.h + === 8 Kbuild Variables The top Makefile exports the following variables:
arch/x86/include/asm/Kbuild +6 -0
@@ -1,5 +1,11 @@ +generated-y += syscalls_32.h +generated-y += syscalls_64.h +generated-y += unistd_32_ia32.h +generated-y += unistd_64_x32.h +generated-y += xen-hypercalls.h + genhdr-y += unistd_32.h genhdr-y += unistd_64.h genhdr-y += unistd_x32.h
Signature · 1 line
2.4.10
PATCH v3 2/2 kbuild: Remove stale asm-generic wrappers
In reply to James HoganWhen a header file is removed from generic-y (often accompanied by the addition of an arch specific header), the generated wrapper file will persist, and in some cases may still take precedence over the new arch header.
For example commit f1fe2d21f4e1 ("MIPS: Add definitions for extended context") removed ucontext.h from generic-y in arch/mips/include/asm/, and added an arch/mips/include/uapi/asm/ucontext.h. The continued use of the wrapper when reusing a dirty build tree resulted in build failures in arch/mips/kernel/signal.c:
arch/mips/kernel/signal.c: In function ‘sc_to_extcontext’:arch/mips/kernel/signal.c:142:12: error: ‘struct ucontext’ has no member named ‘uc_extcontext’
return &uc->uc_extcontext;
^Fix by detecting and removing wrapper headers in generated header directories that do not correspond to a filename in generic-y, genhdr-y, or the newly introduced generated-y.
---
Changes in v3:
- Ensure FORCE actually gets marked .PHONY.
Changes in v2:
- Rewrite a bit, drawing inspiration from Makefile.headersinst.
- Exclude genhdr-y and generated-y (thanks to kbuild test robot).
--- scripts/Makefile.asm-generic | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
scripts/Makefile.asm-generic +16 -1
@@ -13,11 +13,26 @@ include scripts/Kbuild.include # Create output directory if not already present _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) +# Stale wrappers when the corresponding files are removed from generic-y +# need removing. +generated-y := $(generic-y) $(genhdr-y) $(generated-y) +all-files := $(patsubst %, $(obj)/%, $(generated-y)) +old-headers := $(wildcard $(obj)/*.h) +unwanted := $(filter-out $(all-files),$(old-headers)) + quiet_cmd_wrap = WRAP $@ cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ -all: $(patsubst %, $(obj)/%, $(generic-y)) +quiet_cmd_remove = REMOVE $(unwanted) +cmd_remove = rm -f $(unwanted) + +all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE + $(if $(unwanted),$(call cmd,remove),) @: $(obj)/%.h: $(call cmd,wrap) + +PHONY += FORCE +.PHONY: $(PHONY) +FORCE: ;
Signature · 1 line
2.4.10
Quoted 9 lines · CEST James Hogan
This patchset attempts to fix kbuild to automatically remove stale asm-generic wrappers, i.e. when files are removed from generic-y and added directly into
arch/*/include/uapi/asm/, but where the existing wrapper inarch/*/include/generated/asm/continues to be used.MIPS was recently burned by this in v4.3 (see patch 2), with continuing reports of build failures when people upgrade their trees, which go away after
arch/mips/include/generatedis removed (or reportedly make mrproper/distclean). It is particularly irritating during bisection.
Nice series!
There are a number of files that we leave behind after a make clean, and I also wondered if we could remove some more of them, but I couldn't easily figure out which of them were left intentionally.
The asm-generic wrappers certainly are not there for a good reason, and it's good to see them gone.
Arnd