Skip to content

Commit 5b67fbf

Browse files
committed
Merge tag 'kbuild-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: "Build system: - add CONFIG_UNUSED_KSYMS_WHITELIST, which will be useful to define a fixed set of export symbols for Generic Kernel Image (GKI) - allow to run 'make dt_binding_check' without .config - use full schema for checking DT examples in *.yaml files - make modpost fail for missing MODULE_IMPORT_NS(), which makes more sense because we know the produced modules are never loadable - Remove unused 'AS' variable Kconfig: - sanitize DEFCONFIG_LIST, and remove ARCH_DEFCONFIG from Kconfig files - relax the 'imply' behavior so that symbols implied by 'y' can become 'm' - make 'imply' obey 'depends on' in order to make 'imply' really weak Misc: - add documentation on building the kernel with Clang/LLVM - revive __HAVE_ARCH_STRLEN for 32bit sparc to use optimized strlen() - fix warning from deb-pkg builds when CONFIG_DEBUG_INFO=n - various script and Makefile cleanups" * tag 'kbuild-v5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits) Makefile: Update kselftest help information kbuild: deb-pkg: fix warning when CONFIG_DEBUG_INFO is unset kbuild: add outputmakefile to no-dot-config-targets kbuild: remove AS variable net: wan: wanxl: refactor the firmware rebuild rule net: wan: wanxl: use $(M68KCC) instead of $(M68KAS) for rebuilding firmware net: wan: wanxl: use allow to pass CROSS_COMPILE_M68k for rebuilding firmware kbuild: add comment about grouped target kbuild: add -Wall to KBUILD_HOSTCXXFLAGS kconfig: remove unused variable in qconf.cc sparc: revive __HAVE_ARCH_STRLEN for 32bit sparc kbuild: refactor Makefile.dtbinst more kbuild: compute the dtbs_install destination more simply Makefile: disallow data races on gcc-10 as well kconfig: make 'imply' obey the direct dependency kconfig: allow symbols implied by y to become m net: drop_monitor: use IS_REACHABLE() to guard net_dm_hw_report() modpost: return error if module is missing ns imports and MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n modpost: rework and consolidate logging interface kbuild: allow to run dt_binding_check without kernel configuration ...
2 parents a162984 + e51d8da commit 5b67fbf

35 files changed

+356
-200
lines changed

Documentation/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Makefile for Sphinx documentation
33
#
44

5-
subdir-y := devicetree/bindings/
5+
# for cleaning
6+
subdir- := devicetree/bindings
67

78
# Check for broken documentation file references
89
ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
*.example.dts
2-
processed-schema.yaml
2+
processed-schema*.yaml

Documentation/devicetree/bindings/Makefile

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
DT_DOC_CHECKER ?= dt-doc-validate
33
DT_EXTRACT_EX ?= dt-extract-example
44
DT_MK_SCHEMA ?= dt-mk-schema
5-
DT_MK_SCHEMA_FLAGS := $(if $(DT_SCHEMA_FILES), -u)
65

76
quiet_cmd_chk_binding = CHKDT $(patsubst $(srctree)/%,%,$<)
87
cmd_chk_binding = $(DT_DOC_CHECKER) -u $(srctree)/$(src) $< ; \
@@ -11,26 +10,35 @@ quiet_cmd_chk_binding = CHKDT $(patsubst $(srctree)/%,%,$<)
1110
$(obj)/%.example.dts: $(src)/%.yaml FORCE
1211
$(call if_changed,chk_binding)
1312

14-
DT_TMP_SCHEMA := processed-schema.yaml
13+
# Use full schemas when checking %.example.dts
14+
DT_TMP_SCHEMA := $(obj)/processed-schema-examples.yaml
1515

1616
quiet_cmd_mk_schema = SCHEMA $@
1717
cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs)
1818

19-
DT_DOCS = $(shell \
19+
DT_DOCS = $(addprefix $(src)/, \
20+
$(shell \
2021
cd $(srctree)/$(src) && \
2122
find * \( -name '*.yaml' ! \
22-
-name $(DT_TMP_SCHEMA) ! \
23+
-name 'processed-schema*' ! \
2324
-name '*.example.dt.yaml' \) \
24-
)
25+
))
2526

26-
DT_SCHEMA_FILES ?= $(addprefix $(src)/,$(DT_DOCS))
27+
DT_SCHEMA_FILES ?= $(DT_DOCS)
2728

28-
ifeq ($(CHECK_DTBS),)
29-
extra-y += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES))
30-
extra-y += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES))
31-
endif
29+
extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES))
30+
extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES))
31+
extra-$(CHECK_DT_BINDING) += processed-schema-examples.yaml
3232

33-
$(obj)/$(DT_TMP_SCHEMA): $(DT_SCHEMA_FILES) FORCE
33+
override DTC_FLAGS := \
34+
-Wno-avoid_unnecessary_addr_size \
35+
-Wno-graph_child_address
36+
37+
$(obj)/processed-schema-examples.yaml: $(DT_DOCS) FORCE
38+
$(call if_changed,mk_schema)
39+
40+
$(obj)/processed-schema.yaml: DT_MK_SCHEMA_FLAGS := -u
41+
$(obj)/processed-schema.yaml: $(DT_SCHEMA_FILES) FORCE
3442
$(call if_changed,mk_schema)
3543

36-
extra-y += $(DT_TMP_SCHEMA)
44+
extra-y += processed-schema.yaml

Documentation/devicetree/writing-schema.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ Note that ``dtbs_check`` will skip any binding schema files with errors. It is
147147
necessary to use ``dt_binding_check`` to get all the validation errors in the
148148
binding schema files.
149149

150+
It is possible to run both in a single command::
151+
152+
make dt_binding_check dtbs_check
153+
150154
It is also possible to run checks with a single schema file by setting the
151155
``DT_SCHEMA_FILES`` variable to a specific schema file.
152156

Documentation/kbuild/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Kernel Build System
2020
issues
2121
reproducible-builds
2222
gcc-plugins
23+
llvm
2324

2425
.. only:: subproject and html
2526

Documentation/kbuild/kconfig-language.rst

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ applicable everywhere (see syntax).
159159
Given the following example::
160160

161161
config FOO
162-
tristate
162+
tristate "foo"
163163
imply BAZ
164164

165165
config BAZ
166-
tristate
166+
tristate "baz"
167167
depends on BAR
168168

169169
The following values are possible:
@@ -173,14 +173,35 @@ applicable everywhere (see syntax).
173173
=== === ============= ==============
174174
n y n N/m/y
175175
m y m M/y/n
176-
y y y Y/n
176+
y y y Y/m/n
177+
n m n N/m
178+
m m m M/n
179+
y m n M/n
177180
y n * N
178181
=== === ============= ==============
179182

180183
This is useful e.g. with multiple drivers that want to indicate their
181184
ability to hook into a secondary subsystem while allowing the user to
182185
configure that subsystem out without also having to unset these drivers.
183186

187+
Note: If the combination of FOO=y and BAR=m causes a link error,
188+
you can guard the function call with IS_REACHABLE()::
189+
190+
foo_init()
191+
{
192+
if (IS_REACHABLE(CONFIG_BAZ))
193+
baz_register(&foo);
194+
...
195+
}
196+
197+
Note: If the feature provided by BAZ is highly desirable for FOO,
198+
FOO should imply not only BAZ, but also its dependency BAR::
199+
200+
config FOO
201+
tristate "foo"
202+
imply BAR
203+
imply BAZ
204+
184205
- limiting menu display: "visible if" <expr>
185206

186207
This attribute is only applicable to menu blocks, if the condition is

Documentation/kbuild/llvm.rst

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
==============================
2+
Building Linux with Clang/LLVM
3+
==============================
4+
5+
This document covers how to build the Linux kernel with Clang and LLVM
6+
utilities.
7+
8+
About
9+
-----
10+
11+
The Linux kernel has always traditionally been compiled with GNU toolchains
12+
such as GCC and binutils. Ongoing work has allowed for `Clang
13+
<https://clang.llvm.org/>`_ and `LLVM <https://llvm.org/>`_ utilities to be
14+
used as viable substitutes. Distributions such as `Android
15+
<https://www.android.com/>`_, `ChromeOS
16+
<https://www.chromium.org/chromium-os>`_, and `OpenMandriva
17+
<https://www.openmandriva.org/>`_ use Clang built kernels. `LLVM is a
18+
collection of toolchain components implemented in terms of C++ objects
19+
<https://www.aosabook.org/en/llvm.html>`_. Clang is a front-end to LLVM that
20+
supports C and the GNU C extensions required by the kernel, and is pronounced
21+
"klang," not "see-lang."
22+
23+
Clang
24+
-----
25+
26+
The compiler used can be swapped out via `CC=` command line argument to `make`.
27+
`CC=` should be set when selecting a config and during a build.
28+
29+
make CC=clang defconfig
30+
31+
make CC=clang
32+
33+
Cross Compiling
34+
---------------
35+
36+
A single Clang compiler binary will typically contain all supported backends,
37+
which can help simplify cross compiling.
38+
39+
ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- make CC=clang
40+
41+
`CROSS_COMPILE` is not used to prefix the Clang compiler binary, instead
42+
`CROSS_COMPILE` is used to set a command line flag: `--target <triple>`. For
43+
example:
44+
45+
clang --target aarch64-linux-gnu foo.c
46+
47+
LLVM Utilities
48+
--------------
49+
50+
LLVM has substitutes for GNU binutils utilities. These can be invoked as
51+
additional parameters to `make`.
52+
53+
make CC=clang AS=clang LD=ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip \\
54+
OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-objsize \\
55+
READELF=llvm-readelf HOSTCC=clang HOSTCXX=clang++ HOSTAR=llvm-ar \\
56+
HOSTLD=ld.lld
57+
58+
Getting Help
59+
------------
60+
61+
- `Website <https://clangbuiltlinux.github.io/>`_
62+
- `Mailing List <https://groups.google.com/forum/#!forum/clang-built-linux>`_: <[email protected]>
63+
- `Issue Tracker <https://github.com/ClangBuiltLinux/linux/issues>`_
64+
- IRC: #clangbuiltlinux on chat.freenode.net
65+
- `Telegram <https://t.me/ClangBuiltLinux>`_: @ClangBuiltLinux
66+
- `Uncyclo <https://github.com/ClangBuiltLinux/linux/wiki>`_
67+
- `Beginner Bugs <https://github.com/ClangBuiltLinux/linux/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22>`_
68+
69+
Getting LLVM
70+
-------------
71+
72+
- http://releases.llvm.org/download.html
73+
- https://github.com/llvm/llvm-project
74+
- https://llvm.org/docs/GettingStarted.html
75+
- https://llvm.org/docs/CMake.html
76+
- https://apt.llvm.org/
77+
- https://www.archlinux.org/packages/extra/x86_64/llvm/
78+
- https://github.com/ClangBuiltLinux/tc-build
79+
- https://github.com/ClangBuiltLinux/linux/wiki/Building-Clang-from-source
80+
- https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4139,6 +4139,7 @@ B: https://github.com/ClangBuiltLinux/linux/issues
41394139
C: irc://chat.freenode.net/clangbuiltlinux
41404140
S: Supported
41414141
K: \b(?i:clang|llvm)\b
4142+
F: Documentation/kbuild/llvm.rst
41424143

41434144
CLEANCACHE API
41444145
M: Konrad Rzeszutek Wilk <[email protected]>

Makefile

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ clean-targets := %clean mrproper cleandocs
255255
no-dot-config-targets := $(clean-targets) \
256256
cscope gtags TAGS tags help% %docs check% coccicheck \
257257
$(version_h) headers headers_% archheaders archscripts \
258-
%asm-generic kernelversion %src-pkg
258+
%asm-generic kernelversion %src-pkg dt_binding_check \
259+
outputmakefile
259260
no-sync-config-targets := $(no-dot-config-targets) install %install \
260261
kernelrelease
261262
single-targets := %.a %.i %.ko %.lds %.ll %.lst %.mod %.o %.s %.symtypes %/
@@ -388,6 +389,9 @@ endif
388389
KCONFIG_CONFIG ?= .config
389390
export KCONFIG_CONFIG
390391

392+
# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
393+
export KBUILD_DEFCONFIG := defconfig
394+
391395
# SHELL used by kbuild
392396
CONFIG_SHELL := sh
393397

@@ -400,12 +404,11 @@ HOSTCXX = g++
400404
KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \
401405
-fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \
402406
$(HOSTCFLAGS)
403-
KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
407+
KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS)
404408
KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS)
405409
KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
406410

407411
# Make variables (CC, etc...)
408-
AS = $(CROSS_COMPILE)as
409412
LD = $(CROSS_COMPILE)ld
410413
CC = $(CROSS_COMPILE)gcc
411414
CPP = $(CC) -E
@@ -472,7 +475,7 @@ KBUILD_LDFLAGS :=
472475
GCC_PLUGINS_CFLAGS :=
473476
CLANG_FLAGS :=
474477

475-
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
478+
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
476479
export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE READELF PAHOLE LEX YACC AWK INSTALLKERNEL
477480
export PERL PYTHON PYTHON3 CHECK CHECKFLAGS MAKE UTS_MACHINE HOSTCXX
478481
export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS LDFLAGS_MODULE
@@ -535,7 +538,7 @@ endif
535538
ifneq ($(GCC_TOOLCHAIN),)
536539
CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
537540
endif
538-
ifeq ($(shell $(AS) --version 2>&1 | head -n 1 | grep clang),)
541+
ifeq ($(if $(AS),$(shell $(AS) --version 2>&1 | head -n 1 | grep clang)),)
539542
CLANG_FLAGS += -no-integrated-as
540543
endif
541544
CLANG_FLAGS += -Werror=unknown-warning-option
@@ -674,6 +677,7 @@ $(KCONFIG_CONFIG):
674677
#
675678
# This exploits the 'multi-target pattern rule' trick.
676679
# The syncconfig should be executed only once to make all the targets.
680+
# (Note: use the grouped target '&:' when we bump to GNU Make 4.3)
677681
%/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG)
678682
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
679683
else # !may-sync-config
@@ -714,6 +718,7 @@ endif
714718

715719
# Tell gcc to never replace conditional load with a non-conditional one
716720
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
721+
KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
717722

718723
include scripts/Makefile.kcov
719724
include scripts/Makefile.gcc-plugins
@@ -729,7 +734,7 @@ KBUILD_CFLAGS += $(call cc-option,-fno-reorder-blocks,) \
729734
endif
730735

731736
ifneq ($(CONFIG_FRAME_WARN),0)
732-
KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
737+
KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
733738
endif
734739

735740
stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
@@ -1063,9 +1068,12 @@ endif
10631068

10641069
autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h)
10651070

1071+
quiet_cmd_autoksyms_h = GEN $@
1072+
cmd_autoksyms_h = mkdir -p $(dir $@); \
1073+
$(CONFIG_SHELL) $(srctree)/scripts/gen_autoksyms.sh $@
1074+
10661075
$(autoksyms_h):
1067-
$(Q)mkdir -p $(dir $@)
1068-
$(Q)touch $@
1076+
$(call cmd,autoksyms_h)
10691077

10701078
ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
10711079

@@ -1240,14 +1248,18 @@ ifneq ($(dtstree),)
12401248
$(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
12411249

12421250
PHONY += dtbs dtbs_install dtbs_check
1243-
dtbs dtbs_check: include/config/kernel.release scripts_dtc
1251+
dtbs: include/config/kernel.release scripts_dtc
12441252
$(Q)$(MAKE) $(build)=$(dtstree)
12451253

1246-
dtbs_check: export CHECK_DTBS=1
1247-
dtbs_check: dt_binding_check
1254+
ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),)
1255+
export CHECK_DTBS=y
1256+
dtbs: dt_binding_check
1257+
endif
1258+
1259+
dtbs_check: dtbs
12481260

12491261
dtbs_install:
1250-
$(Q)$(MAKE) $(dtbinst)=$(dtstree)
1262+
$(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH)
12511263

12521264
ifdef CONFIG_OF_EARLY_FLATTREE
12531265
all: dtbs
@@ -1259,6 +1271,10 @@ PHONY += scripts_dtc
12591271
scripts_dtc: scripts_basic
12601272
$(Q)$(MAKE) $(build)=scripts/dtc
12611273

1274+
ifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),)
1275+
export CHECK_DT_BINDING=y
1276+
endif
1277+
12621278
PHONY += dt_binding_check
12631279
dt_binding_check: scripts_dtc
12641280
$(Q)$(MAKE) $(build)=Documentation/devicetree/bindings
@@ -1470,12 +1486,15 @@ help:
14701486
@echo ' nsdeps - Generate missing symbol namespace dependencies'
14711487
@echo ''
14721488
@echo 'Kernel selftest:'
1473-
@echo ' kselftest - Build and run kernel selftest (run as root)'
1474-
@echo ' Build, install, and boot kernel before'
1475-
@echo ' running kselftest on it'
1476-
@echo ' kselftest-clean - Remove all generated kselftest files'
1477-
@echo ' kselftest-merge - Merge all the config dependencies of kselftest to existing'
1478-
@echo ' .config.'
1489+
@echo ' kselftest - Build and run kernel selftest'
1490+
@echo ' Build, install, and boot kernel before'
1491+
@echo ' running kselftest on it'
1492+
@echo ' Run as root for full coverage'
1493+
@echo ' kselftest-all - Build kernel selftest'
1494+
@echo ' kselftest-install - Build and install kernel selftest'
1495+
@echo ' kselftest-clean - Remove all generated kselftest files'
1496+
@echo ' kselftest-merge - Merge all the config dependencies of'
1497+
@echo ' kselftest to existing .config.'
14791498
@echo ''
14801499
@$(if $(dtstree), \
14811500
echo 'Devicetree:'; \

arch/sh/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ config SUPERH64
8787
select HAVE_EXIT_THREAD
8888
select KALLSYMS
8989

90-
config ARCH_DEFCONFIG
91-
string
92-
default "arch/sh/configs/shx3_defconfig" if SUPERH32
93-
default "arch/sh/configs/cayman_defconfig" if SUPERH64
94-
9590
config GENERIC_BUG
9691
def_bool y
9792
depends on BUG && SUPERH32

arch/sparc/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ config SPARC64
9696
select PCI_DOMAINS if PCI
9797
select ARCH_HAS_GIGANTIC_PAGE
9898

99-
config ARCH_DEFCONFIG
100-
string
101-
default "arch/sparc/configs/sparc32_defconfig" if SPARC32
102-
default "arch/sparc/configs/sparc64_defconfig" if SPARC64
103-
10499
config ARCH_PROC_KCORE_TEXT
105100
def_bool y
106101

0 commit comments

Comments
 (0)