Skip to content

Commit 9199873

Browse files
committed
kbuild: generate asm-generic wrappers if mandatory headers are missing
Some time ago, Sam pointed out a certain degree of overwrap between generic-y and mandatory-y. (https://lkml.org/lkml/2017/7/10/121) I tweaked the meaning of mandatory-y a little bit; now it defines the minimum set of ASM headers that all architectures must have. If arch does not have specific implementation of a mandatory header, Kbuild will let it fallback to the asm-generic one by automatically generating a wrapper. This will allow to drop lots of redundant generic-y defines. Previously, "mandatory" was used in the context of UAPI, but I guess this can be extended to kernel space ASM headers. Suggested-by: Sam Ravnborg <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Acked-by: Sam Ravnborg <[email protected]>
1 parent d4ce545 commit 9199873

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Documentation/kbuild/makefiles.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,9 +1296,12 @@ See subsequent chapter for the syntax of the Kbuild file.
12961296

12971297
--- 7.4 mandatory-y
12981298

1299-
mandatory-y is essentially used by include/uapi/asm-generic/Kbuild.asm
1300-
to define the minimum set of headers that must be exported in
1301-
include/asm.
1299+
mandatory-y is essentially used by include/(uapi/)asm-generic/Kbuild.asm
1300+
to define the minimum set of ASM headers that all architectures must have.
1301+
1302+
This works like optional generic-y. If a mandatory header is missing
1303+
in arch/$(ARCH)/include/(uapi/)/asm, Kbuild will automatically generate
1304+
a wrapper of the asm-generic one.
13021305

13031306
The convention is to list one subdir per line and
13041307
preferably in alphabetic order.

scripts/Makefile.asm-generic

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ src := $(subst /generated,,$(obj))
1414

1515
include scripts/Kbuild.include
1616

17+
# If arch does not implement mandatory headers, fallback to asm-generic ones.
18+
mandatory-y := $(filter-out $(generated-y), $(mandatory-y))
19+
generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(srctree)/$(src)/$(f)),,$(f)))
20+
1721
generic-y := $(addprefix $(obj)/, $(generic-y))
1822
generated-y := $(addprefix $(obj)/, $(generated-y))
1923

scripts/Makefile.headersinst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,6 @@ check-file := $(installdir)/.check
5656
all-files := $(header-files) $(genhdr-files)
5757
output-files := $(addprefix $(installdir)/, $(all-files))
5858

59-
ifneq ($(mandatory-y),)
60-
missing := $(filter-out $(all-files),$(mandatory-y))
61-
ifneq ($(missing),)
62-
$(error Some mandatory headers ($(missing)) are missing in $(obj))
63-
endif
64-
endif
65-
6659
# Work out what needs to be removed
6760
oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
6861
unwanted := $(filter-out $(all-files),$(oldheaders))

0 commit comments

Comments
 (0)