Skip to content

Commit fc80c51

Browse files
committed
Merge tag 'kbuild-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: - run the checker (e.g. sparse) after the compiler - remove unneeded cc-option tests for old compiler flags - fix tar-pkg to install dtbs - introduce ccflags-remove-y and asflags-remove-y syntax - allow to trace functions in sub-directories of lib/ - introduce hostprogs-always-y and userprogs-always-y syntax - various Makefile cleanups * tag 'kbuild-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kbuild: stop filtering out $(GCC_PLUGINS_CFLAGS) from cc-option base kbuild: include scripts/Makefile.* only when relevant CONFIG is enabled kbuild: introduce hostprogs-always-y and userprogs-always-y kbuild: sort hostprogs before passing it to ifneq kbuild: move host .so build rules to scripts/gcc-plugins/Makefile kbuild: Replace HTTP links with HTTPS ones kbuild: trace functions in subdirectories of lib/ kbuild: introduce ccflags-remove-y and asflags-remove-y kbuild: do not export LDFLAGS_vmlinux kbuild: always create directories of targets powerpc/boot: add DTB to 'targets' kbuild: buildtar: add dtbs support kbuild: remove cc-option test of -ffreestanding kbuild: remove cc-option test of -fno-stack-protector Revert "kbuild: Create directory for target DTB" kbuild: run the checker after the compiler
2 parents 7a6b604 + 132305b commit fc80c51

File tree

65 files changed

+251
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+251
-221
lines changed

Documentation/kbuild/Kconfig.recursion-issue-02

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
# "select FW_LOADER" [0], in the end the simple alternative solution to this
4343
# problem consisted on matching semantics with newly introduced features.
4444
#
45-
# [0] http://lkml.kernel.org/r/[email protected]
45+
# [0] https://lkml.kernel.org/r/[email protected]
4646

4747
mainmenu "Simple example to demo cumulative kconfig recursive dependency implication"
4848

Documentation/kbuild/kconfig-language.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ followed by a test macro::
540540
If you need to expose a compiler capability to makefiles and/or C source files,
541541
`CC_HAS_` is the recommended prefix for the config option::
542542

543-
config CC_HAS_STACKPROTECTOR_NONE
544-
def_bool $(cc-option,-fno-stack-protector)
543+
config CC_HAS_ASM_GOTO
544+
def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
545545

546546
Build as module only
547547
~~~~~~~~~~~~~~~~~~~~
@@ -688,10 +688,10 @@ and real world requirements were not well understood. As it stands though
688688
only reverse engineering techniques have been used to deduce semantics from
689689
variability modeling languages such as Kconfig [3]_.
690690

691-
.. [0] http://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf
692-
.. [1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
693-
.. [2] http://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf
694-
.. [3] http://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf
691+
.. [0] https://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf
692+
.. [1] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
693+
.. [2] https://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf
694+
.. [3] https://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf
695695
696696
Full SAT solver for Kconfig
697697
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -710,10 +710,10 @@ such efforts somehow on Kconfig. There is enough interest from mentors of
710710
existing projects to not only help advise how to integrate this work upstream
711711
but also help maintain it long term. Interested developers should visit:
712712

713-
http://kernelnewbies.org/KernelProjects/kconfig-sat
713+
https://kernelnewbies.org/KernelProjects/kconfig-sat
714714

715-
.. [4] http://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf
716-
.. [5] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
715+
.. [4] https://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf
716+
.. [5] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
717717
.. [6] https://cados.cs.fau.de
718718
.. [7] https://vamos.cs.fau.de
719719
.. [8] https://undertaker.cs.fau.de

Documentation/kbuild/llvm.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Getting Help
7676
Getting LLVM
7777
-------------
7878

79-
- http://releases.llvm.org/download.html
79+
- https://releases.llvm.org/download.html
8080
- https://github.com/llvm/llvm-project
8181
- https://llvm.org/docs/GettingStarted.html
8282
- https://llvm.org/docs/CMake.html

Documentation/kbuild/makefiles.rst

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,24 @@ more details, with real examples.
368368

369369
subdir-ccflags-y := -Werror
370370

371+
ccflags-remove-y, asflags-remove-y
372+
These flags are used to remove particular flags for the compiler,
373+
assembler invocations.
374+
375+
Example::
376+
377+
ccflags-remove-$(CONFIG_MCOUNT) += -pg
378+
371379
CFLAGS_$@, AFLAGS_$@
372380
CFLAGS_$@ and AFLAGS_$@ only apply to commands in current
373381
kbuild makefile.
374382

375383
$(CFLAGS_$@) specifies per-file options for $(CC). The $@
376384
part has a literal value which specifies the file that it is for.
377385

386+
CFLAGS_$@ has the higher priority than ccflags-remove-y; CFLAGS_$@
387+
can re-add compiler flags that were removed by ccflags-remove-y.
388+
378389
Example::
379390

380391
# drivers/scsi/Makefile
@@ -387,6 +398,9 @@ more details, with real examples.
387398
$(AFLAGS_$@) is a similar feature for source files in assembly
388399
languages.
389400

401+
AFLAGS_$@ has the higher priority than asflags-remove-y; AFLAGS_$@
402+
can re-add assembler flags that were removed by asflags-remove-y.
403+
390404
Example::
391405

392406
# arch/arm/kernel/Makefile
@@ -735,6 +749,10 @@ Both possibilities are described in the following.
735749
hostprogs := lxdialog
736750
always-y := $(hostprogs)
737751

752+
Kbuild provides the following shorthand for this:
753+
754+
hostprogs-always-y := lxdialog
755+
738756
This will tell kbuild to build lxdialog even if not referenced in
739757
any rule.
740758

@@ -817,7 +835,32 @@ The syntax is quite similar. The difference is to use "userprogs" instead of
817835
5.4 When userspace programs are actually built
818836
----------------------------------------------
819837

820-
Same as "When host programs are actually built".
838+
Kbuild builds userspace programs only when told to do so.
839+
There are two ways to do this.
840+
841+
(1) Add it as the prerequisite of another file
842+
843+
Example::
844+
845+
#net/bpfilter/Makefile
846+
userprogs := bpfilter_umh
847+
$(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh
848+
849+
$(obj)/bpfilter_umh is built before $(obj)/bpfilter_umh_blob.o
850+
851+
(2) Use always-y
852+
853+
Example::
854+
855+
userprogs := binderfs_example
856+
always-y := $(userprogs)
857+
858+
Kbuild provides the following shorthand for this:
859+
860+
userprogs-always-y := binderfs_example
861+
862+
This will tell Kbuild to build binderfs_example when it visits this
863+
Makefile.
821864

822865
6 Kbuild clean infrastructure
823866
=============================

Makefile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ KBUILD_CFLAGS_MODULE := -DMODULE
508508
KBUILD_LDFLAGS_MODULE :=
509509
export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds
510510
KBUILD_LDFLAGS :=
511-
GCC_PLUGINS_CFLAGS :=
512511
CLANG_FLAGS :=
513512

514513
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
@@ -747,9 +746,6 @@ endif
747746
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
748747
KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
749748

750-
include scripts/Makefile.kcov
751-
include scripts/Makefile.gcc-plugins
752-
753749
ifdef CONFIG_READABLE_ASM
754750
# Disable optimizations that make assembler listings hard to read.
755751
# reorder blocks reorders the control in the function
@@ -764,7 +760,7 @@ ifneq ($(CONFIG_FRAME_WARN),0)
764760
KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
765761
endif
766762

767-
stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
763+
stackp-flags-y := -fno-stack-protector
768764
stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
769765
stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
770766

@@ -959,10 +955,19 @@ ifdef CONFIG_RETPOLINE
959955
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
960956
endif
961957

962-
include scripts/Makefile.kasan
963-
include scripts/Makefile.extrawarn
964-
include scripts/Makefile.ubsan
965-
include scripts/Makefile.kcsan
958+
# include additional Makefiles when needed
959+
include-y := scripts/Makefile.extrawarn
960+
include-$(CONFIG_KASAN) += scripts/Makefile.kasan
961+
include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
962+
include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
963+
include-$(CONFIG_KCOV) += scripts/Makefile.kcov
964+
include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
965+
966+
include $(addprefix $(srctree)/, $(include-y))
967+
968+
# scripts/Makefile.gcc-plugins is intentionally included last.
969+
# Do not add $(call cc-option,...) below this line. When you build the kernel
970+
# from the clean source tree, the GCC plugins do not exist at this point.
966971

967972
# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
968973
KBUILD_CPPFLAGS += $(KCPPFLAGS)
@@ -1120,7 +1125,6 @@ KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
11201125

11211126
export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
11221127
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
1123-
export LDFLAGS_vmlinux
11241128
# used by scripts/Makefile.package
11251129
export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
11261130

@@ -1152,7 +1156,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
11521156

11531157
# Final link of vmlinux with optional arch pass after final link
11541158
cmd_link-vmlinux = \
1155-
$(CONFIG_SHELL) $< $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_vmlinux) ; \
1159+
$(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
11561160
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
11571161

11581162
vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE

arch/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,6 @@ config HAVE_STACKPROTECTOR
481481
An arch should select this symbol if:
482482
- it has implemented a stack canary (e.g. __stack_chk_guard)
483483

484-
config CC_HAS_STACKPROTECTOR_NONE
485-
def_bool $(cc-option,-fno-stack-protector)
486-
487484
config STACKPROTECTOR
488485
bool "Stack Protector buffer overflow detection"
489486
depends on HAVE_STACKPROTECTOR

arch/arm/boot/compressed/Makefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ endif
8484

8585
# -fstack-protector-strong triggers protection checks in this code,
8686
# but it is being used too early to link to meaningful stack_chk logic.
87-
nossp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
8887
$(foreach o, $(libfdt_objs) atags_to_fdt.o, \
89-
$(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt $(nossp-flags-y)))
88+
$(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector))
9089

9190
# These were previously generated C files. When you are building the kernel
9291
# with O=, make sure to remove the stale files in the output tree. Otherwise,
@@ -103,13 +102,9 @@ clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S
103102

104103
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
105104

106-
ifeq ($(CONFIG_FUNCTION_TRACER),y)
107-
ORIG_CFLAGS := $(KBUILD_CFLAGS)
108-
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
109-
endif
110-
111105
ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
112106
-I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
107+
ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg
113108
asflags-y := -DZIMAGE
114109

115110
# Supply kernel BSS size to the decompressor via a linker symbol.

arch/mips/vdso/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ cflags-vdso := $(ccflags-vdso) \
3535
-O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
3636
-mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \
3737
-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
38-
$(call cc-option, -fno-asynchronous-unwind-tables) \
39-
$(call cc-option, -fno-stack-protector)
38+
$(call cc-option, -fno-asynchronous-unwind-tables)
4039
aflags-vdso := $(ccflags-vdso) \
4140
-D__ASSEMBLY__ -Wa,-gdwarf-2
4241

arch/powerpc/boot/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,8 @@ initrd-y := $(patsubst zImage%, zImage.initrd%, \
366366
$(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
367367
initrd-y := $(filter-out $(image-y), $(initrd-y))
368368
targets += $(image-y) $(initrd-y)
369+
targets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \
370+
$(patsubst $(x).%, dts/%.dtb, $(filter $(x).%, $(image-y))))
369371

370372
$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
371373

arch/powerpc/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
1616
CFLAGS_btext.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
1717
CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
1818

19-
CFLAGS_prom_init.o += $(call cc-option, -fno-stack-protector)
19+
CFLAGS_prom_init.o += -fno-stack-protector
2020
CFLAGS_prom_init.o += -DDISABLE_BRANCH_PROFILING
2121
CFLAGS_prom_init.o += -ffreestanding
2222

0 commit comments

Comments
 (0)