Commit fc80c51f authored by Linus Torvalds's avatar Linus Torvalds

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
parents 7a6b6044 132305b3
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
# "select FW_LOADER" [0], in the end the simple alternative solution to this # "select FW_LOADER" [0], in the end the simple alternative solution to this
# problem consisted on matching semantics with newly introduced features. # problem consisted on matching semantics with newly introduced features.
# #
# [0] http://lkml.kernel.org/r/1432241149-8762-1-git-send-email-mcgrof@do-not-panic.com # [0] https://lkml.kernel.org/r/1432241149-8762-1-git-send-email-mcgrof@do-not-panic.com
mainmenu "Simple example to demo cumulative kconfig recursive dependency implication" mainmenu "Simple example to demo cumulative kconfig recursive dependency implication"
......
...@@ -540,8 +540,8 @@ followed by a test macro:: ...@@ -540,8 +540,8 @@ followed by a test macro::
If you need to expose a compiler capability to makefiles and/or C source files, If you need to expose a compiler capability to makefiles and/or C source files,
`CC_HAS_` is the recommended prefix for the config option:: `CC_HAS_` is the recommended prefix for the config option::
config CC_HAS_STACKPROTECTOR_NONE config CC_HAS_ASM_GOTO
def_bool $(cc-option,-fno-stack-protector) def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC))
Build as module only Build as module only
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
...@@ -688,10 +688,10 @@ and real world requirements were not well understood. As it stands though ...@@ -688,10 +688,10 @@ and real world requirements were not well understood. As it stands though
only reverse engineering techniques have been used to deduce semantics from only reverse engineering techniques have been used to deduce semantics from
variability modeling languages such as Kconfig [3]_. variability modeling languages such as Kconfig [3]_.
.. [0] http://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf .. [0] https://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf
.. [1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf .. [1] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
.. [2] http://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf .. [2] https://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf
.. [3] http://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf .. [3] https://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf
Full SAT solver for Kconfig Full SAT solver for Kconfig
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
...@@ -710,10 +710,10 @@ such efforts somehow on Kconfig. There is enough interest from mentors of ...@@ -710,10 +710,10 @@ such efforts somehow on Kconfig. There is enough interest from mentors of
existing projects to not only help advise how to integrate this work upstream existing projects to not only help advise how to integrate this work upstream
but also help maintain it long term. Interested developers should visit: but also help maintain it long term. Interested developers should visit:
http://kernelnewbies.org/KernelProjects/kconfig-sat https://kernelnewbies.org/KernelProjects/kconfig-sat
.. [4] http://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf .. [4] https://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf
.. [5] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf .. [5] https://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
.. [6] https://cados.cs.fau.de .. [6] https://cados.cs.fau.de
.. [7] https://vamos.cs.fau.de .. [7] https://vamos.cs.fau.de
.. [8] https://undertaker.cs.fau.de .. [8] https://undertaker.cs.fau.de
......
...@@ -76,7 +76,7 @@ Getting Help ...@@ -76,7 +76,7 @@ Getting Help
Getting LLVM Getting LLVM
------------- -------------
- http://releases.llvm.org/download.html - https://releases.llvm.org/download.html
- https://github.com/llvm/llvm-project - https://github.com/llvm/llvm-project
- https://llvm.org/docs/GettingStarted.html - https://llvm.org/docs/GettingStarted.html
- https://llvm.org/docs/CMake.html - https://llvm.org/docs/CMake.html
......
...@@ -368,6 +368,14 @@ more details, with real examples. ...@@ -368,6 +368,14 @@ more details, with real examples.
subdir-ccflags-y := -Werror subdir-ccflags-y := -Werror
ccflags-remove-y, asflags-remove-y
These flags are used to remove particular flags for the compiler,
assembler invocations.
Example::
ccflags-remove-$(CONFIG_MCOUNT) += -pg
CFLAGS_$@, AFLAGS_$@ CFLAGS_$@, AFLAGS_$@
CFLAGS_$@ and AFLAGS_$@ only apply to commands in current CFLAGS_$@ and AFLAGS_$@ only apply to commands in current
kbuild makefile. kbuild makefile.
...@@ -375,6 +383,9 @@ more details, with real examples. ...@@ -375,6 +383,9 @@ more details, with real examples.
$(CFLAGS_$@) specifies per-file options for $(CC). The $@ $(CFLAGS_$@) specifies per-file options for $(CC). The $@
part has a literal value which specifies the file that it is for. part has a literal value which specifies the file that it is for.
CFLAGS_$@ has the higher priority than ccflags-remove-y; CFLAGS_$@
can re-add compiler flags that were removed by ccflags-remove-y.
Example:: Example::
# drivers/scsi/Makefile # drivers/scsi/Makefile
...@@ -387,6 +398,9 @@ more details, with real examples. ...@@ -387,6 +398,9 @@ more details, with real examples.
$(AFLAGS_$@) is a similar feature for source files in assembly $(AFLAGS_$@) is a similar feature for source files in assembly
languages. languages.
AFLAGS_$@ has the higher priority than asflags-remove-y; AFLAGS_$@
can re-add assembler flags that were removed by asflags-remove-y.
Example:: Example::
# arch/arm/kernel/Makefile # arch/arm/kernel/Makefile
...@@ -735,6 +749,10 @@ Both possibilities are described in the following. ...@@ -735,6 +749,10 @@ Both possibilities are described in the following.
hostprogs := lxdialog hostprogs := lxdialog
always-y := $(hostprogs) always-y := $(hostprogs)
Kbuild provides the following shorthand for this:
hostprogs-always-y := lxdialog
This will tell kbuild to build lxdialog even if not referenced in This will tell kbuild to build lxdialog even if not referenced in
any rule. any rule.
...@@ -817,7 +835,32 @@ The syntax is quite similar. The difference is to use "userprogs" instead of ...@@ -817,7 +835,32 @@ The syntax is quite similar. The difference is to use "userprogs" instead of
5.4 When userspace programs are actually built 5.4 When userspace programs are actually built
---------------------------------------------- ----------------------------------------------
Same as "When host programs are actually built". Kbuild builds userspace programs only when told to do so.
There are two ways to do this.
(1) Add it as the prerequisite of another file
Example::
#net/bpfilter/Makefile
userprogs := bpfilter_umh
$(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh
$(obj)/bpfilter_umh is built before $(obj)/bpfilter_umh_blob.o
(2) Use always-y
Example::
userprogs := binderfs_example
always-y := $(userprogs)
Kbuild provides the following shorthand for this:
userprogs-always-y := binderfs_example
This will tell Kbuild to build binderfs_example when it visits this
Makefile.
6 Kbuild clean infrastructure 6 Kbuild clean infrastructure
============================= =============================
......
...@@ -508,7 +508,6 @@ KBUILD_CFLAGS_MODULE := -DMODULE ...@@ -508,7 +508,6 @@ KBUILD_CFLAGS_MODULE := -DMODULE
KBUILD_LDFLAGS_MODULE := KBUILD_LDFLAGS_MODULE :=
export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds
KBUILD_LDFLAGS := KBUILD_LDFLAGS :=
GCC_PLUGINS_CFLAGS :=
CLANG_FLAGS := CLANG_FLAGS :=
export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC export ARCH SRCARCH CONFIG_SHELL BASH HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE LD CC
...@@ -747,9 +746,6 @@ endif ...@@ -747,9 +746,6 @@ endif
KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0)
KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races) KBUILD_CFLAGS += $(call cc-option,-fno-allow-store-data-races)
include scripts/Makefile.kcov
include scripts/Makefile.gcc-plugins
ifdef CONFIG_READABLE_ASM ifdef CONFIG_READABLE_ASM
# Disable optimizations that make assembler listings hard to read. # Disable optimizations that make assembler listings hard to read.
# reorder blocks reorders the control in the function # reorder blocks reorders the control in the function
...@@ -764,7 +760,7 @@ ifneq ($(CONFIG_FRAME_WARN),0) ...@@ -764,7 +760,7 @@ ifneq ($(CONFIG_FRAME_WARN),0)
KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN) KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
endif endif
stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector stackp-flags-y := -fno-stack-protector
stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
...@@ -959,10 +955,19 @@ ifdef CONFIG_RETPOLINE ...@@ -959,10 +955,19 @@ ifdef CONFIG_RETPOLINE
KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none)
endif endif
include scripts/Makefile.kasan # include additional Makefiles when needed
include scripts/Makefile.extrawarn include-y := scripts/Makefile.extrawarn
include scripts/Makefile.ubsan include-$(CONFIG_KASAN) += scripts/Makefile.kasan
include scripts/Makefile.kcsan include-$(CONFIG_KCSAN) += scripts/Makefile.kcsan
include-$(CONFIG_UBSAN) += scripts/Makefile.ubsan
include-$(CONFIG_KCOV) += scripts/Makefile.kcov
include-$(CONFIG_GCC_PLUGINS) += scripts/Makefile.gcc-plugins
include $(addprefix $(srctree)/, $(include-y))
# scripts/Makefile.gcc-plugins is intentionally included last.
# Do not add $(call cc-option,...) below this line. When you build the kernel
# from the clean source tree, the GCC plugins do not exist at this point.
# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
KBUILD_CPPFLAGS += $(KCPPFLAGS) KBUILD_CPPFLAGS += $(KCPPFLAGS)
...@@ -1120,7 +1125,6 @@ KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y)) ...@@ -1120,7 +1125,6 @@ KBUILD_VMLINUX_OBJS += $(patsubst %/,%/built-in.a, $(drivers-y))
export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
export LDFLAGS_vmlinux
# used by scripts/Makefile.package # used by scripts/Makefile.package
export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools) export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools)
...@@ -1152,7 +1156,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) ...@@ -1152,7 +1156,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
# Final link of vmlinux with optional arch pass after final link # Final link of vmlinux with optional arch pass after final link
cmd_link-vmlinux = \ cmd_link-vmlinux = \
$(CONFIG_SHELL) $< $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_vmlinux) ; \ $(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
......
...@@ -481,9 +481,6 @@ config HAVE_STACKPROTECTOR ...@@ -481,9 +481,6 @@ config HAVE_STACKPROTECTOR
An arch should select this symbol if: An arch should select this symbol if:
- it has implemented a stack canary (e.g. __stack_chk_guard) - it has implemented a stack canary (e.g. __stack_chk_guard)
config CC_HAS_STACKPROTECTOR_NONE
def_bool $(cc-option,-fno-stack-protector)
config STACKPROTECTOR config STACKPROTECTOR
bool "Stack Protector buffer overflow detection" bool "Stack Protector buffer overflow detection"
depends on HAVE_STACKPROTECTOR depends on HAVE_STACKPROTECTOR
......
...@@ -84,9 +84,8 @@ endif ...@@ -84,9 +84,8 @@ endif
# -fstack-protector-strong triggers protection checks in this code, # -fstack-protector-strong triggers protection checks in this code,
# but it is being used too early to link to meaningful stack_chk logic. # but it is being used too early to link to meaningful stack_chk logic.
nossp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
$(foreach o, $(libfdt_objs) atags_to_fdt.o, \ $(foreach o, $(libfdt_objs) atags_to_fdt.o, \
$(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt $(nossp-flags-y))) $(eval CFLAGS_$(o) := -I $(srctree)/scripts/dtc/libfdt -fno-stack-protector))
# These were previously generated C files. When you are building the kernel # These were previously generated C files. When you are building the kernel
# with O=, make sure to remove the stale files in the output tree. Otherwise, # 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 ...@@ -103,13 +102,9 @@ clean-files += piggy_data lib1funcs.S ashldi3.S bswapsdi2.S hyp-stub.S
KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
ifeq ($(CONFIG_FUNCTION_TRACER),y)
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
endif
ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \ ccflags-y := -fpic $(call cc-option,-mno-single-pic-base,) -fno-builtin \
-I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN) -I$(obj) $(DISABLE_ARM_SSP_PER_TASK_PLUGIN)
ccflags-remove-$(CONFIG_FUNCTION_TRACER) += -pg
asflags-y := -DZIMAGE asflags-y := -DZIMAGE
# Supply kernel BSS size to the decompressor via a linker symbol. # Supply kernel BSS size to the decompressor via a linker symbol.
......
...@@ -35,8 +35,7 @@ cflags-vdso := $(ccflags-vdso) \ ...@@ -35,8 +35,7 @@ cflags-vdso := $(ccflags-vdso) \
-O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \ -O3 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \
-mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \ -mrelax-pic-calls $(call cc-option, -mexplicit-relocs) \
-fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \
$(call cc-option, -fno-asynchronous-unwind-tables) \ $(call cc-option, -fno-asynchronous-unwind-tables)
$(call cc-option, -fno-stack-protector)
aflags-vdso := $(ccflags-vdso) \ aflags-vdso := $(ccflags-vdso) \
-D__ASSEMBLY__ -Wa,-gdwarf-2 -D__ASSEMBLY__ -Wa,-gdwarf-2
......
...@@ -366,6 +366,8 @@ initrd-y := $(patsubst zImage%, zImage.initrd%, \ ...@@ -366,6 +366,8 @@ initrd-y := $(patsubst zImage%, zImage.initrd%, \
$(patsubst treeImage%, treeImage.initrd%, $(image-y))))) $(patsubst treeImage%, treeImage.initrd%, $(image-y)))))
initrd-y := $(filter-out $(image-y), $(initrd-y)) initrd-y := $(filter-out $(image-y), $(initrd-y))
targets += $(image-y) $(initrd-y) targets += $(image-y) $(initrd-y)
targets += $(foreach x, dtbImage uImage cuImage simpleImage treeImage, \
$(patsubst $(x).%, dts/%.dtb, $(filter $(x).%, $(image-y))))
$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz $(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
......
...@@ -16,7 +16,7 @@ CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) ...@@ -16,7 +16,7 @@ CFLAGS_prom_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
CFLAGS_btext.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) CFLAGS_btext.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
CFLAGS_prom_init.o += $(call cc-option, -fno-stack-protector) CFLAGS_prom_init.o += -fno-stack-protector
CFLAGS_prom_init.o += -DDISABLE_BRANCH_PROFILING CFLAGS_prom_init.o += -DDISABLE_BRANCH_PROFILING
CFLAGS_prom_init.o += -ffreestanding CFLAGS_prom_init.o += -ffreestanding
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
CFLAGS_bootx_init.o += -fPIC CFLAGS_bootx_init.o += -fPIC
CFLAGS_bootx_init.o += $(call cc-option, -fno-stack-protector) CFLAGS_bootx_init.o += -fno-stack-protector
KASAN_SANITIZE_bootx_init.o := n KASAN_SANITIZE_bootx_init.o := n
......
...@@ -7,8 +7,7 @@ UBSAN_SANITIZE := n ...@@ -7,8 +7,7 @@ UBSAN_SANITIZE := n
KASAN_SANITIZE := n KASAN_SANITIZE := n
# Disable ftrace for the entire directory # Disable ftrace for the entire directory
ORIG_CFLAGS := $(KBUILD_CFLAGS) ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
ifdef CONFIG_CC_IS_CLANG ifdef CONFIG_CC_IS_CLANG
# clang stores addresses on the stack causing the frame size to blow # clang stores addresses on the stack causing the frame size to blow
......
...@@ -27,7 +27,7 @@ KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 ...@@ -27,7 +27,7 @@ KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2
KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float
KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-option,-ffreestanding) KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member) KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g) KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,)) KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
......
...@@ -28,10 +28,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \ ...@@ -28,10 +28,7 @@ IMAGE_OFFSET := $(shell /bin/bash -c 'printf "0x%08x" \
$(CONFIG_BOOT_LINK_OFFSET)]') $(CONFIG_BOOT_LINK_OFFSET)]')
endif endif
ifeq ($(CONFIG_MCOUNT),y) ccflags-remove-$(CONFIG_MCOUNT) += -pg
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
endif
LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \ LDFLAGS_vmlinux := --oformat $(ld-bfd) -Ttext $(IMAGE_OFFSET) -e startup \
-T $(obj)/../../kernel/vmlinux.lds -T $(obj)/../../kernel/vmlinux.lds
......
...@@ -54,7 +54,7 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE ...@@ -54,7 +54,7 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
# optimize sibling calls. # optimize sibling calls.
# #
CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 \ CFL := $(PROFILING) -mcmodel=medlow -fPIC -O2 -fasynchronous-unwind-tables -m64 \
$(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
-fno-omit-frame-pointer -foptimize-sibling-calls \ -fno-omit-frame-pointer -foptimize-sibling-calls \
-DDISABLE_BRANCH_PROFILING -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
...@@ -93,7 +93,7 @@ KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32)) ...@@ -93,7 +93,7 @@ KBUILD_CFLAGS_32 := $(filter-out -fno-pic,$(KBUILD_CFLAGS_32))
KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
KBUILD_CFLAGS_32 := $(filter-out $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out $(SPARC_REG_CFLAGS),$(KBUILD_CFLAGS_32))
KBUILD_CFLAGS_32 += -m32 -msoft-float -fpic KBUILD_CFLAGS_32 += -m32 -msoft-float -fpic
KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector) KBUILD_CFLAGS_32 += -fno-stack-protector
KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
KBUILD_CFLAGS_32 += -fno-omit-frame-pointer KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
......
...@@ -121,8 +121,7 @@ LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static ...@@ -121,8 +121,7 @@ LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie) LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
$(call cc-option, -fno-stack-protector,) \ -fno-stack-protector $(call cc-option, -fno-stack-protector-all)
$(call cc-option, -fno-stack-protector-all,)
# Options used by linker script # Options used by linker script
export LDS_START := $(START) export LDS_START := $(START)
......
...@@ -36,8 +36,8 @@ REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -DDISABLE_BRANCH_PROFILING \ ...@@ -36,8 +36,8 @@ REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -DDISABLE_BRANCH_PROFILING \
-fno-strict-aliasing -fomit-frame-pointer -fno-pic \ -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
-mno-mmx -mno-sse -mno-mmx -mno-sse
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding) REALMODE_CFLAGS += -ffreestanding
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector) REALMODE_CFLAGS += -fno-stack-protector
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4)) REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
export REALMODE_CFLAGS export REALMODE_CFLAGS
......
...@@ -35,8 +35,8 @@ cflags-$(CONFIG_X86_32) := -march=i386 ...@@ -35,8 +35,8 @@ cflags-$(CONFIG_X86_32) := -march=i386
cflags-$(CONFIG_X86_64) := -mcmodel=small cflags-$(CONFIG_X86_64) := -mcmodel=small
KBUILD_CFLAGS += $(cflags-y) KBUILD_CFLAGS += $(cflags-y)
KBUILD_CFLAGS += -mno-mmx -mno-sse KBUILD_CFLAGS += -mno-mmx -mno-sse
KBUILD_CFLAGS += $(call cc-option,-ffreestanding) KBUILD_CFLAGS += -ffreestanding
KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) KBUILD_CFLAGS += -fno-stack-protector
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
KBUILD_CFLAGS += $(call cc-disable-warning, gnu) KBUILD_CFLAGS += $(call cc-disable-warning, gnu)
KBUILD_CFLAGS += -Wno-pointer-sign KBUILD_CFLAGS += -Wno-pointer-sign
......
...@@ -82,7 +82,7 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE ...@@ -82,7 +82,7 @@ $(obj)/vdso-image-%.c: $(obj)/vdso%.so.dbg $(obj)/vdso%.so $(obj)/vdso2c FORCE
# optimize sibling calls. # optimize sibling calls.
# #
CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
$(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
-fno-omit-frame-pointer -foptimize-sibling-calls \ -fno-omit-frame-pointer -foptimize-sibling-calls \
-DDISABLE_BRANCH_PROFILING -DBUILD_VDSO -DDISABLE_BRANCH_PROFILING -DBUILD_VDSO
...@@ -151,7 +151,7 @@ KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32)) ...@@ -151,7 +151,7 @@ KBUILD_CFLAGS_32 := $(filter-out -mfentry,$(KBUILD_CFLAGS_32))
KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS_32))
KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32)) KBUILD_CFLAGS_32 := $(filter-out $(RETPOLINE_CFLAGS),$(KBUILD_CFLAGS_32))
KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic KBUILD_CFLAGS_32 += -m32 -msoft-float -mregparm=0 -fpic
KBUILD_CFLAGS_32 += $(call cc-option, -fno-stack-protector) KBUILD_CFLAGS_32 += -fno-stack-protector
KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls) KBUILD_CFLAGS_32 += $(call cc-option, -foptimize-sibling-calls)
KBUILD_CFLAGS_32 += -fno-omit-frame-pointer KBUILD_CFLAGS_32 += -fno-omit-frame-pointer
KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING KBUILD_CFLAGS_32 += -DDISABLE_BRANCH_PROFILING
......
...@@ -17,8 +17,7 @@ KCOV_INSTRUMENT_perf_event.o := n ...@@ -17,8 +17,7 @@ KCOV_INSTRUMENT_perf_event.o := n
KCSAN_SANITIZE_common.o := n KCSAN_SANITIZE_common.o := n
# Make sure load_percpu_segment has no stackprotector # Make sure load_percpu_segment has no stackprotector
nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_common.o := -fno-stack-protector
CFLAGS_common.o := $(nostackp)
obj-y := cacheinfo.o scattered.o topology.o obj-y := cacheinfo.o scattered.o topology.o
obj-y += common.o obj-y += common.o
......
...@@ -24,7 +24,7 @@ ifdef CONFIG_FUNCTION_TRACER ...@@ -24,7 +24,7 @@ ifdef CONFIG_FUNCTION_TRACER
CFLAGS_REMOVE_cmdline.o = -pg CFLAGS_REMOVE_cmdline.o = -pg
endif endif
CFLAGS_cmdline.o := $(call cc-option, -fno-stack-protector) CFLAGS_cmdline.o := -fno-stack-protector
endif endif
inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
......
...@@ -22,10 +22,9 @@ obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o mmap.o \ ...@@ -22,10 +22,9 @@ obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o mmap.o \
obj-y += pat/ obj-y += pat/
# Make sure __phys_addr has no stackprotector # Make sure __phys_addr has no stackprotector
nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_physaddr.o := -fno-stack-protector
CFLAGS_physaddr.o := $(nostackp) CFLAGS_setup_nx.o := -fno-stack-protector
CFLAGS_setup_nx.o := $(nostackp) CFLAGS_mem_encrypt_identity.o := -fno-stack-protector
CFLAGS_mem_encrypt_identity.o := $(nostackp)
CFLAGS_fault.o := -I $(srctree)/$(src)/../include/asm/trace CFLAGS_fault.o := -I $(srctree)/$(src)/../include/asm/trace
......
...@@ -3,8 +3,7 @@ OBJECT_FILES_NON_STANDARD_hibernate_asm_$(BITS).o := y ...@@ -3,8 +3,7 @@ OBJECT_FILES_NON_STANDARD_hibernate_asm_$(BITS).o := y
# __restore_processor_state() restores %gs after S3 resume and so should not # __restore_processor_state() restores %gs after S3 resume and so should not
# itself be stack-protected # itself be stack-protected
nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_cpu.o := -fno-stack-protector
CFLAGS_cpu.o := $(nostackp)
obj-$(CONFIG_PM_SLEEP) += cpu.o obj-$(CONFIG_PM_SLEEP) += cpu.o
obj-$(CONFIG_HIBERNATION) += hibernate_$(BITS).o hibernate_asm_$(BITS).o hibernate.o obj-$(CONFIG_HIBERNATION) += hibernate_$(BITS).o hibernate_asm_$(BITS).o hibernate.o
...@@ -34,7 +34,7 @@ KCOV_INSTRUMENT := n ...@@ -34,7 +34,7 @@ KCOV_INSTRUMENT := n
PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss
PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING PURGATORY_CFLAGS += $(DISABLE_STACKLEAK_PLUGIN) -DDISABLE_BRANCH_PROFILING
PURGATORY_CFLAGS += $(call cc-option,-fno-stack-protector) PURGATORY_CFLAGS += -fno-stack-protector
# Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
# in turn leaves some undefined symbols like __fentry__ in purgatory and not # in turn leaves some undefined symbols like __fentry__ in purgatory and not
......
...@@ -42,7 +42,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE ...@@ -42,7 +42,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE
# optimize sibling calls. # optimize sibling calls.
# #
CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \ CFL := $(PROFILING) -mcmodel=small -fPIC -O2 -fasynchronous-unwind-tables -m64 \
$(filter -g%,$(KBUILD_CFLAGS)) $(call cc-option, -fno-stack-protector) \ $(filter -g%,$(KBUILD_CFLAGS)) -fno-stack-protector \
-fno-omit-frame-pointer -foptimize-sibling-calls -fno-omit-frame-pointer -foptimize-sibling-calls
$(vobjs): KBUILD_CFLAGS += $(CFL) $(vobjs): KBUILD_CFLAGS += $(CFL)
......
...@@ -9,9 +9,8 @@ CFLAGS_REMOVE_irq.o = -pg ...@@ -9,9 +9,8 @@ CFLAGS_REMOVE_irq.o = -pg
endif endif
# Make sure early boot has no stackprotector # Make sure early boot has no stackprotector
nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_enlighten_pv.o := -fno-stack-protector
CFLAGS_enlighten_pv.o := $(nostackp) CFLAGS_mmu_pv.o := -fno-stack-protector
CFLAGS_mmu_pv.o := $(nostackp)
obj-y += enlighten.o obj-y += enlighten.o
obj-y += mmu.o obj-y += mmu.o
......
...@@ -26,7 +26,7 @@ $(obj)/Image.o: $(obj)/../vmlinux.bin $(OBJS) ...@@ -26,7 +26,7 @@ $(obj)/Image.o: $(obj)/../vmlinux.bin $(OBJS)
$(OBJS) $@ $(OBJS) $@
$(obj)/../Image.elf: $(obj)/Image.o $(obj)/boot.lds $(obj)/../Image.elf: $(obj)/Image.o $(obj)/boot.lds
$(Q)$(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_vmlinux) \ $(Q)$(LD) $(KBUILD_LDFLAGS) \
-T $(obj)/boot.lds \ -T $(obj)/boot.lds \
--build-id=none \ --build-id=none \
-o $@ $(obj)/Image.o -o $@ $(obj)/Image.o
......
...@@ -28,8 +28,8 @@ cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt ...@@ -28,8 +28,8 @@ cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \ KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
-include $(srctree)/drivers/firmware/efi/libstub/hidden.h \ -include $(srctree)/drivers/firmware/efi/libstub/hidden.h \
-D__NO_FORTIFY \ -D__NO_FORTIFY \
$(call cc-option,-ffreestanding) \ -ffreestanding \
$(call cc-option,-fno-stack-protector) \ -fno-stack-protector \
$(call cc-option,-fno-addrsig) \ $(call cc-option,-fno-addrsig) \
-D__DISABLE_EXPORTS -D__DISABLE_EXPORTS
......
...@@ -5,8 +5,7 @@ obj-y += mem-reservation.o ...@@ -5,8 +5,7 @@ obj-y += mem-reservation.o
obj-y += events/ obj-y += events/
obj-y += xenbus/ obj-y += xenbus/
nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_features.o := -fno-stack-protector
CFLAGS_features.o := $(nostackp)
dom0-$(CONFIG_ARM64) += arm-device.o dom0-$(CONFIG_ARM64) += arm-device.o
dom0-$(CONFIG_PCI) += pci.o dom0-$(CONFIG_PCI) += pci.o
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# Do not instrument the tracer itself: # Do not instrument the tracer itself:
ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
ifdef CONFIG_FUNCTION_TRACER ifdef CONFIG_FUNCTION_TRACER
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
# Avoid recursion due to instrumentation. # Avoid recursion due to instrumentation.
KCSAN_SANITIZE := n KCSAN_SANITIZE := n
......
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
# Makefile for some libs needed in the kernel. # Makefile for some libs needed in the kernel.
# #
ifdef CONFIG_FUNCTION_TRACER ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
ORIG_CFLAGS := $(KBUILD_CFLAGS)
KBUILD_CFLAGS = $(subst $(CC_FLAGS_FTRACE),,$(ORIG_CFLAGS))
endif
# These files are disabled because they produce lots of non-interesting and/or # These files are disabled because they produce lots of non-interesting and/or
# flaky coverage that is not a function of syscall inputs. For example, # flaky coverage that is not a function of syscall inputs. For example,
...@@ -22,7 +19,7 @@ KCOV_INSTRUMENT_fault-inject.o := n ...@@ -22,7 +19,7 @@ KCOV_INSTRUMENT_fault-inject.o := n
ifdef CONFIG_AMD_MEM_ENCRYPT ifdef CONFIG_AMD_MEM_ENCRYPT
KASAN_SANITIZE_string.o := n KASAN_SANITIZE_string.o := n
CFLAGS_string.o := $(call cc-option, -fno-stack-protector) CFLAGS_string.o := -fno-stack-protector
endif endif
# Used by KCSAN while enabled, avoid recursion. # Used by KCSAN while enabled, avoid recursion.
...@@ -324,7 +321,7 @@ endif ...@@ -324,7 +321,7 @@ endif
UBSAN_SANITIZE_ubsan.o := n UBSAN_SANITIZE_ubsan.o := n
KASAN_SANITIZE_ubsan.o := n KASAN_SANITIZE_ubsan.o := n
KCSAN_SANITIZE_ubsan.o := n KCSAN_SANITIZE_ubsan.o := n
CFLAGS_ubsan.o := $(call cc-option, -fno-stack-protector) $(DISABLE_STACKLEAK_PLUGIN) CFLAGS_ubsan.o := -fno-stack-protector $(DISABLE_STACKLEAK_PLUGIN)
obj-$(CONFIG_SBITMAP) += sbitmap.o obj-$(CONFIG_SBITMAP) += sbitmap.o
......
...@@ -12,7 +12,3 @@ obj-$(CONFIG_TEST_LIVEPATCH) += test_klp_atomic_replace.o \ ...@@ -12,7 +12,3 @@ obj-$(CONFIG_TEST_LIVEPATCH) += test_klp_atomic_replace.o \
test_klp_state.o \ test_klp_state.o \
test_klp_state2.o \ test_klp_state2.o \
test_klp_state3.o test_klp_state3.o
# Target modules to be livepatched require CC_FLAGS_FTRACE
CFLAGS_test_klp_callbacks_busy.o += $(CC_FLAGS_FTRACE)
CFLAGS_test_klp_callbacks_mod.o += $(CC_FLAGS_FTRACE)
...@@ -16,7 +16,7 @@ CFLAGS_REMOVE_tags_report.o = $(CC_FLAGS_FTRACE) ...@@ -16,7 +16,7 @@ CFLAGS_REMOVE_tags_report.o = $(CC_FLAGS_FTRACE)
# Function splitter causes unnecessary splits in __asan_load1/__asan_store1 # Function splitter causes unnecessary splits in __asan_load1/__asan_store1
# see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533 # see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63533
CC_FLAGS_KASAN_RUNTIME := $(call cc-option, -fno-conserve-stack) CC_FLAGS_KASAN_RUNTIME := $(call cc-option, -fno-conserve-stack)
CC_FLAGS_KASAN_RUNTIME += $(call cc-option, -fno-stack-protector) CC_FLAGS_KASAN_RUNTIME += -fno-stack-protector
# Disable branch tracing to avoid recursion. # Disable branch tracing to avoid recursion.
CC_FLAGS_KASAN_RUNTIME += -DDISABLE_BRANCH_PROFILING CC_FLAGS_KASAN_RUNTIME += -DDISABLE_BRANCH_PROFILING
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
userprogs := cfag12864b-example userprogs-always-y += cfag12864b-example
always-y := $(userprogs)
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
userprogs := binderfs_example userprogs-always-y += binderfs_example
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_SAMPLE_CONNECTOR) += cn_test.o obj-$(CONFIG_SAMPLE_CONNECTOR) += cn_test.o
userprogs := ucon userprogs-always-$(CONFIG_CC_CAN_LINK) += ucon
always-$(CONFIG_CC_CAN_LINK) := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
userprogs := hid-example userprogs-always-y += hid-example
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2012-2019, Intel Corporation. All rights reserved. # Copyright (c) 2012-2019, Intel Corporation. All rights reserved.
userprogs-always-y += mei-amt-version
userprogs := mei-amt-version
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
usertprogs-always-y += pidfd-metadata
usertprogs := pidfd-metadata
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
userprogs := bpf-fancy dropper bpf-direct user-trap userprogs-always-y += bpf-fancy dropper bpf-direct user-trap
bpf-fancy-objs := bpf-fancy.o bpf-helper.o bpf-fancy-objs := bpf-fancy.o bpf-helper.o
userccflags += -I usr/include userccflags += -I usr/include
always-y := $(userprogs)
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
userprogs := hpet_example userprogs-always-y += hpet_example
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
userprogs := uhid-example userprogs-always-y += uhid-example
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
userprogs := test-fsmount test-statx userprogs-always-y += test-fsmount test-statx
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
userprogs := watch_test userprogs-always-y += watch_test
always-y := $(userprogs)
userccflags += -I usr/include userccflags += -I usr/include
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
userprogs := watchdog-simple userprogs-always-y += watchdog-simple
always-y := $(userprogs)
...@@ -119,25 +119,21 @@ as-instr = $(call try-run,\ ...@@ -119,25 +119,21 @@ as-instr = $(call try-run,\
__cc-option = $(call try-run,\ __cc-option = $(call try-run,\
$(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4))
# Do not attempt to build with gcc plugins during cc-option tests.
# (And this uses delayed resolution so the flags will be up to date.)
CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
# cc-option # cc-option
# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
cc-option = $(call __cc-option, $(CC),\ cc-option = $(call __cc-option, $(CC),\
$(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS),$(1),$(2))
# cc-option-yn # cc-option-yn
# Usage: flag := $(call cc-option-yn,-march=winchip-c6) # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
cc-option-yn = $(call try-run,\ cc-option-yn = $(call try-run,\
$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n)
# cc-disable-warning # cc-disable-warning
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
cc-disable-warning = $(call try-run,\ cc-disable-warning = $(call try-run,\
$(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) $(CC) -Werror $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
# cc-ifversion # cc-ifversion
# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
......
...@@ -3,14 +3,14 @@ ...@@ -3,14 +3,14 @@
# scripts contains sources for various helper programs used throughout # scripts contains sources for various helper programs used throughout
# the kernel for the build process. # the kernel for the build process.
always-$(CONFIG_BUILD_BIN2C) += bin2c hostprogs-always-$(CONFIG_BUILD_BIN2C) += bin2c
always-$(CONFIG_KALLSYMS) += kallsyms hostprogs-always-$(CONFIG_KALLSYMS) += kallsyms
always-$(BUILD_C_RECORDMCOUNT) += recordmcount hostprogs-always-$(BUILD_C_RECORDMCOUNT) += recordmcount
always-$(CONFIG_BUILDTIME_TABLE_SORT) += sorttable hostprogs-always-$(CONFIG_BUILDTIME_TABLE_SORT) += sorttable
always-$(CONFIG_ASN1) += asn1_compiler hostprogs-always-$(CONFIG_ASN1) += asn1_compiler
always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file hostprogs-always-$(CONFIG_MODULE_SIG_FORMAT) += sign-file
always-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert hostprogs-always-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert hostprogs-always-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include HOSTCFLAGS_sorttable.o = -I$(srctree)/tools/include
HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include
...@@ -26,8 +26,6 @@ HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED ...@@ -26,8 +26,6 @@ HOSTCFLAGS_sorttable.o += -DUNWINDER_ORC_ENABLED
HOSTLDLIBS_sorttable = -lpthread HOSTLDLIBS_sorttable = -lpthread
endif endif
hostprogs := $(always-y) $(always-m)
# The following programs are only built on demand # The following programs are only built on demand
hostprogs += unifdef hostprogs += unifdef
......
...@@ -45,12 +45,15 @@ include $(kbuild-file) ...@@ -45,12 +45,15 @@ include $(kbuild-file)
include scripts/Makefile.lib include scripts/Makefile.lib
# Do not include host rules unless needed # Do not include hostprogs rules unless needed.
ifneq ($(hostprogs)$(hostcxxlibs-y)$(hostcxxlibs-m),) # $(sort ...) is used here to remove duplicated words and excessive spaces.
hostprogs := $(sort $(hostprogs))
ifneq ($(hostprogs),)
include scripts/Makefile.host include scripts/Makefile.host
endif endif
# Do not include userprogs rules unless needed. # Do not include userprogs rules unless needed.
# $(sort ...) is used here to remove duplicated words and excessive spaces.
userprogs := $(sort $(userprogs)) userprogs := $(sort $(userprogs))
ifneq ($(userprogs),) ifneq ($(userprogs),)
include scripts/Makefile.userprogs include scripts/Makefile.userprogs
...@@ -252,9 +255,9 @@ cmd_gen_ksymdeps = \ ...@@ -252,9 +255,9 @@ cmd_gen_ksymdeps = \
endif endif
define rule_cc_o_c define rule_cc_o_c
$(call cmd,checksrc)
$(call cmd_and_fixdep,cc_o_c) $(call cmd_and_fixdep,cc_o_c)
$(call cmd,gen_ksymdeps) $(call cmd,gen_ksymdeps)
$(call cmd,checksrc)
$(call cmd,checkdoc) $(call cmd,checkdoc)
$(call cmd,objtool) $(call cmd,objtool)
$(call cmd,modversions_c) $(call cmd,modversions_c)
...@@ -277,8 +280,8 @@ endif ...@@ -277,8 +280,8 @@ endif
# Built-in and composite module parts # Built-in and composite module parts
$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE
$(call cmd,force_checksrc)
$(call if_changed_rule,cc_o_c) $(call if_changed_rule,cc_o_c)
$(call cmd,force_checksrc)
cmd_mod = { \ cmd_mod = { \
echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \ echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \
...@@ -515,15 +518,13 @@ existing-targets := $(wildcard $(sort $(targets))) ...@@ -515,15 +518,13 @@ existing-targets := $(wildcard $(sort $(targets)))
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
ifdef building_out_of_srctree
# Create directories for object files if they do not exist # Create directories for object files if they do not exist
obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) obj-dirs := $(sort $(patsubst %/,%, $(dir $(targets))))
# If targets exist, their directories apparently exist. Skip mkdir. # If targets exist, their directories apparently exist. Skip mkdir.
existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets)))) existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs))) obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs)))
ifneq ($(obj-dirs),) ifneq ($(obj-dirs),)
$(shell mkdir -p $(obj-dirs)) $(shell mkdir -p $(obj-dirs))
endif endif
endif
.PHONY: $(PHONY) .PHONY: $(PHONY)
...@@ -27,10 +27,15 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) ...@@ -27,10 +27,15 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
# build a list of files to remove, usually relative to the current # build a list of files to remove, usually relative to the current
# directory # directory
__clean-files := $(extra-y) $(extra-m) $(extra-) \ __clean-files := \
$(always) $(always-y) $(always-m) $(always-) $(targets) $(clean-files) \ $(clean-files) $(targets) $(hostprogs) $(userprogs) \
$(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-) $(userprogs) \ $(extra-y) $(extra-m) $(extra-) \
$(hostcxxlibs-y) $(hostcxxlibs-m) $(always-y) $(always-m) $(always-) \
$(hostprogs-always-y) $(hostprogs-always-m) $(hostprogs-always-) \
$(userprogs-always-y) $(userprogs-always-m) $(userprogs-always-)
# deprecated
__clean-files += $(always) $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
__clean-files := $(filter-out $(no-clean-files), $(__clean-files)) __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
......
...@@ -38,39 +38,31 @@ $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE ...@@ -38,39 +38,31 @@ $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
# Will compile qconf as a C++ program, and menu as a C program. # Will compile qconf as a C++ program, and menu as a C program.
# They are linked as C++ code to the executable qconf # They are linked as C++ code to the executable qconf
__hostprogs := $(sort $(hostprogs))
host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
# C code # C code
# Executables compiled from a single .c file # Executables compiled from a single .c file
host-csingle := $(foreach m,$(__hostprogs), \ host-csingle := $(foreach m,$(hostprogs), \
$(if $($(m)-objs)$($(m)-cxxobjs),,$(m))) $(if $($(m)-objs)$($(m)-cxxobjs),,$(m)))
# C executables linked based on several .o files # C executables linked based on several .o files
host-cmulti := $(foreach m,$(__hostprogs),\ host-cmulti := $(foreach m,$(hostprogs),\
$(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
# Object (.o) files compiled from .c files # Object (.o) files compiled from .c files
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) host-cobjs := $(sort $(foreach m,$(hostprogs),$($(m)-objs)))
# C++ code # C++ code
# C++ executables compiled from at least one .cc file # C++ executables compiled from at least one .cc file
# and zero or more .c files # and zero or more .c files
host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) host-cxxmulti := $(foreach m,$(hostprogs),$(if $($(m)-cxxobjs),$(m)))
# C++ Object (.o) files compiled from .cc files # C++ Object (.o) files compiled from .cc files
host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
# Object (.o) files used by the shared libaries
host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
host-csingle := $(addprefix $(obj)/,$(host-csingle)) host-csingle := $(addprefix $(obj)/,$(host-csingle))
host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
##### #####
# Handle options to gcc. Support building with separate output directory # Handle options to gcc. Support building with separate output directory
...@@ -136,25 +128,5 @@ quiet_cmd_host-cxxobjs = HOSTCXX $@ ...@@ -136,25 +128,5 @@ quiet_cmd_host-cxxobjs = HOSTCXX $@
$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE $(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
$(call if_changed_dep,host-cxxobjs) $(call if_changed_dep,host-cxxobjs)
# Compile .c file, create position independent .o file targets += $(host-csingle) $(host-cmulti) $(host-cobjs) \
# Note that plugin capable gcc versions can be either C or C++ based $(host-cxxmulti) $(host-cxxobjs)
# therefore plugin source files have to be compilable in both C and C++ mode.
# This is why a C++ compiler is invoked on a .c file.
# host-cxxshobjs -> .o
quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
$(call if_changed_dep,host-cxxshobjs)
# Link a shared library, based on position independent .o files
# *.o -> .so shared library (host-cxxshlib)
quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
cmd_host-cxxshlib = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
$(addprefix $(obj)/, $($(target-stem)-objs)) \
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem).so)
$(host-cxxshlib): FORCE
$(call if_changed,host-cxxshlib)
$(call multi_depend, $(host-cxxshlib), .so, -objs)
targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
$(host-cxxmulti) $(host-cxxobjs) $(host-cxxshlib) $(host-cxxshobjs)
# SPDX-License-Identifier: GPL-2.0-only # SPDX-License-Identifier: GPL-2.0-only
ifdef CONFIG_KCOV
kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc
kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp
kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
export CFLAGS_KCOV := $(kcov-flags-y) export CFLAGS_KCOV := $(kcov-flags-y)
endif
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
ifdef CONFIG_KCSAN
# GCC and Clang accept backend options differently. Do not wrap in cc-option, # GCC and Clang accept backend options differently. Do not wrap in cc-option,
# because Clang accepts "--param" even if it is unused. # because Clang accepts "--param" even if it is unused.
ifdef CONFIG_CC_IS_CLANG ifdef CONFIG_CC_IS_CLANG
...@@ -15,5 +13,3 @@ CFLAGS_KCSAN := -fsanitize=thread \ ...@@ -15,5 +13,3 @@ CFLAGS_KCSAN := -fsanitize=thread \
$(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \ $(call cc-option,$(call cc-param,tsan-instrument-func-entry-exit=0) -fno-optimize-sibling-calls) \
$(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \ $(call cc-option,$(call cc-param,tsan-instrument-read-before-write=1)) \
$(call cc-param,tsan-distinguish-volatile=1) $(call cc-param,tsan-distinguish-volatile=1)
endif # CONFIG_KCSAN
...@@ -68,6 +68,17 @@ real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) ...@@ -68,6 +68,17 @@ real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))
always-y += $(always-m) always-y += $(always-m)
# hostprogs-always-y += foo
# ... is a shorthand for
# hostprogs += foo
# always-y += foo
hostprogs += $(hostprogs-always-y) $(hostprogs-always-m)
always-y += $(hostprogs-always-y) $(hostprogs-always-m)
# userprogs-always-y is likewise.
userprogs += $(userprogs-always-y) $(userprogs-always-m)
always-y += $(userprogs-always-y) $(userprogs-always-m)
# DTB # DTB
# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
extra-y += $(dtb-y) extra-y += $(dtb-y)
...@@ -111,12 +122,14 @@ basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) ...@@ -111,12 +122,14 @@ basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname))
modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile)) modfile_flags = -DKBUILD_MODFILE=$(call stringify,$(modfile))
orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ _c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), \
$(ccflags-y) $(CFLAGS_$(target-stem).o) $(filter-out $(ccflags-remove-y), \
_c_flags = $(filter-out $(CFLAGS_REMOVE_$(target-stem).o), $(orig_c_flags)) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(ccflags-y)) \
orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ $(CFLAGS_$(target-stem).o))
$(asflags-y) $(AFLAGS_$(target-stem).o) _a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), \
_a_flags = $(filter-out $(AFLAGS_REMOVE_$(target-stem).o), $(orig_a_flags)) $(filter-out $(asflags-remove-y), \
$(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(asflags-y)) \
$(AFLAGS_$(target-stem).o))
_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds) _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(target-stem).lds)
# #
...@@ -303,8 +316,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE ...@@ -303,8 +316,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
$(call if_changed,dt_S_dtb) $(call if_changed,dt_S_dtb)
quiet_cmd_dtc = DTC $@ quiet_cmd_dtc = DTC $@
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
$(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \ $(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
-d $(depfile).dtc.tmp $(dtc-tmp) ; \ -d $(depfile).dtc.tmp $(dtc-tmp) ; \
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
ifdef CONFIG_UBSAN
ifdef CONFIG_UBSAN_ALIGNMENT ifdef CONFIG_UBSAN_ALIGNMENT
CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment)
endif endif
...@@ -26,4 +24,3 @@ endif ...@@ -26,4 +24,3 @@ endif
# -fsanitize=* options makes GCC less smart than usual and # -fsanitize=* options makes GCC less smart than usual and
# increase number of 'maybe-uninitialized false-positives # increase number of 'maybe-uninitialized false-positives
CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized) CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized)
endif
...@@ -2,5 +2,4 @@ ...@@ -2,5 +2,4 @@
# #
# fixdep: used to generate dependency information during build process # fixdep: used to generate dependency information during build process
hostprogs := fixdep hostprogs-always-y += fixdep
always-y := $(hostprogs)
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
# scripts/dtc makefile # scripts/dtc makefile
hostprogs := dtc hostprogs-always-$(CONFIG_DTC) += dtc
always-$(CONFIG_DTC) += $(hostprogs) hostprogs-always-$(CHECK_DT_BINDING) += dtc
always-$(CHECK_DT_BINDING) += $(hostprogs)
dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
srcpos.o checks.o util.o srcpos.o checks.o util.o
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti $(obj)/randomize_layout_plugin.so: $(objtree)/$(obj)/randomize_layout_seed.h
HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable -Wno-c++11-compat
HOST_EXTRACXXFLAGS += -Wno-format-diag
$(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
quiet_cmd_create_randomize_layout_seed = GENSEED $@ quiet_cmd_create_randomize_layout_seed = GENSEED $@
cmd_create_randomize_layout_seed = \ cmd_create_randomize_layout_seed = \
$(CONFIG_SHELL) $(srctree)/$(src)/gen-random-seed.sh $@ $(objtree)/include/generated/randomize_layout_hash.h $(CONFIG_SHELL) $(srctree)/$(src)/gen-random-seed.sh $@ $(objtree)/include/generated/randomize_layout_hash.h
$(objtree)/$(obj)/randomize_layout_seed.h: FORCE $(objtree)/$(obj)/randomize_layout_seed.h: FORCE
$(call if_changed,create_randomize_layout_seed) $(call if_changed,create_randomize_layout_seed)
targets = randomize_layout_seed.h randomize_layout_hash.h targets += randomize_layout_seed.h randomize_layout_hash.h
# Build rules for plugins
#
# No extra code is needed for single-file plugins.
# For multi-file plugins, use *-objs syntax to list the objects.
#
# If the plugin foo.so is compiled from foo.c and foo2.c, you can do:
#
# foo-objs := foo.o foo2.o
always-y += $(GCC_PLUGIN)
hostcxxlibs-y := $(GCC_PLUGIN) GCC_PLUGINS_DIR = $(shell $(CC) -print-file-name=plugin)
always-y := $(hostcxxlibs-y)
$(foreach p,$(hostcxxlibs-y:%.so=%),$(eval $(p)-objs := $(p).o)) plugin_cxxflags = -Wp,-MMD,$(depfile) $(KBUILD_HOSTCXXFLAGS) -fPIC \
-I $(GCC_PLUGINS_DIR)/include -I $(obj) -std=gnu++98 \
-fno-rtti -fno-exceptions -fasynchronous-unwind-tables \
-ggdb -Wno-narrowing -Wno-unused-variable -Wno-c++11-compat \
-Wno-format-diag
plugin_ldflags = -shared
plugin-single := $(foreach m, $(GCC_PLUGIN), $(if $($(m:%.so=%-objs)),,$(m)))
plugin-multi := $(filter-out $(plugin-single), $(GCC_PLUGIN))
plugin-objs := $(sort $(foreach m, $(plugin-multi), $($(m:%.so=%-objs))))
targets += $(plugin-single) $(plugin-multi) $(plugin-objs)
clean-files += *.so clean-files += *.so
plugin-single := $(addprefix $(obj)/, $(plugin-single))
plugin-multi := $(addprefix $(obj)/, $(plugin-multi))
plugin-objs := $(addprefix $(obj)/, $(plugin-objs))
quiet_cmd_plugin_cxx_so_c = HOSTCXX $@
cmd_plugin_cxx_so_c = $(HOSTCXX) $(plugin_cxxflags) $(plugin_ldflags) -o $@ $<
$(plugin-single): $(obj)/%.so: $(src)/%.c FORCE
$(call if_changed_dep,plugin_cxx_so_c)
quiet_cmd_plugin_ld_so_o = HOSTLD $@
cmd_plugin_ld_so_o = $(HOSTCXX) $(plugin_ldflags) -o $@ \
$(addprefix $(obj)/, $($(target-stem)-objs))
$(plugin-multi): FORCE
$(call if_changed,plugin_ld_so_o)
$(foreach m, $(notdir $(plugin-multi)), $(eval $(obj)/$m: $(addprefix $(obj)/, $($(m:%.so=%-objs)))))
quiet_cmd_plugin_cxx_o_c = HOSTCXX $@
cmd_plugin_cxx_o_c = $(HOSTCXX) $(plugin_cxxflags) -c -o $@ $<
$(plugin-objs): $(obj)/%.o: $(src)/%.c FORCE
$(call if_changed_dep,plugin_cxx_o_c)
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
hostprogs := genksyms hostprogs-always-y += genksyms
always-y := $(hostprogs)
genksyms-objs := genksyms.o parse.tab.o lex.lex.o genksyms-objs := genksyms.o parse.tab.o lex.lex.o
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
# Error out on error # Error out on error
set -e set -e
LD="$1"
KBUILD_LDFLAGS="$2"
LDFLAGS_vmlinux="$3"
# Nice output in kbuild format # Nice output in kbuild format
# Will be supressed by "make -s" # Will be supressed by "make -s"
info() info()
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
OBJECT_FILES_NON_STANDARD := y OBJECT_FILES_NON_STANDARD := y
hostprogs := modpost mk_elfconfig hostprogs-always-y += modpost mk_elfconfig
always-y := $(hostprogs) empty.o always-y += empty.o
modpost-objs := modpost.o file2alias.o sumversion.o modpost-objs := modpost.o file2alias.o sumversion.o
......
...@@ -53,6 +53,18 @@ rm -rf -- "${tmpdir}" ...@@ -53,6 +53,18 @@ rm -rf -- "${tmpdir}"
mkdir -p -- "${tmpdir}/boot" mkdir -p -- "${tmpdir}/boot"
dirs=boot dirs=boot
#
# Try to install dtbs
#
if grep -q '^CONFIG_OF_EARLY_FLATTREE=y' include/config/auto.conf; then
# Only some architectures with OF support have this target
if [ -d "${srctree}/arch/${SRCARCH}/boot/dts" ]; then
$MAKE ARCH="${ARCH}" -f ${srctree}/Makefile INSTALL_DTBS_PATH="${tmpdir}/boot/dtbs/${KERNELRELEASE}" dtbs_install
fi
fi
# #
# Try to install modules # Try to install modules
# #
......
...@@ -175,7 +175,7 @@ Section: kernel ...@@ -175,7 +175,7 @@ Section: kernel
Priority: optional Priority: optional
Maintainer: $maintainer Maintainer: $maintainer
Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends
Homepage: http://www.kernel.org/ Homepage: https://www.kernel.org/
Package: $packagename Package: $packagename
Architecture: $debarch Architecture: $debarch
......
...@@ -46,7 +46,7 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF ...@@ -46,7 +46,7 @@ sed -e '/^DEL/d' -e 's/^\t*//' <<EOF
License: GPL License: GPL
Group: System Environment/Kernel Group: System Environment/Kernel
Vendor: The Linux Community Vendor: The Linux Community
URL: http://www.kernel.org URL: https://www.kernel.org
$S Source: kernel-$__KERNELRELEASE.tar.gz $S Source: kernel-$__KERNELRELEASE.tar.gz
Provides: $PROVIDES Provides: $PROVIDES
%define __spec_install_post /usr/lib/rpm/brp-compress || : %define __spec_install_post /usr/lib/rpm/brp-compress || :
......
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
hostprogs := genheaders hostprogs-always-y += genheaders
HOST_EXTRACFLAGS += \ HOST_EXTRACFLAGS += \
-I$(srctree)/include/uapi -I$(srctree)/include \ -I$(srctree)/include/uapi -I$(srctree)/include \
-I$(srctree)/security/selinux/include -I$(srctree)/security/selinux/include
always-y := $(hostprogs)
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
hostprogs := mdp hostprogs-always-y += mdp
HOST_EXTRACFLAGS += \ HOST_EXTRACFLAGS += \
-I$(srctree)/include/uapi -I$(srctree)/include \ -I$(srctree)/include/uapi -I$(srctree)/include \
-I$(srctree)/security/selinux/include -I$(objtree)/include -I$(srctree)/security/selinux/include -I$(objtree)/include
always-y := $(hostprogs)
clean-files := policy.* file_contexts clean-files := policy.* file_contexts
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment