Commit 668c35f6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kbuild-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild updates from Masahiro Yamada:
 "Kbuild core:
   - remove unneeded $(call cc-option,...) switches
   - consolidate Clang compiler flags into CLANG_FLAGS
   - announce the deprecation of SUBDIRS
   - fix single target build for external module
   - simplify the dependencies of 'prepare' stage targets
   - allow fixdep to directly write to .*.cmd files
   - simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS
   - change if_changed_rule to accept multi-line recipe
   - move .SECONDARY special target to scripts/Kbuild.include
   - remove redundant 'set -e'
   - improve parallel execution for CONFIG_HEADERS_CHECK
   - misc cleanups

  Treewide fixes and cleanups
   - set Clang flags correctly for PowerPC boot images
   - fix UML build error with CONFIG_GCC_PLUGINS
   - remove unneeded patterns from .gitignore files
   - refactor firmware/Makefile
   - remove unneeded rules for *offsets.s
   - avoid unneeded regeneration of intermediate .s files
   - clean up ./Kbuild

  Modpost:
   - remove unused -M, -K options
   - fix false positive warnings about section mismatch
   - use simple devtable lookup instead of linker magic
   - misc cleanups

  Coccinelle:
   - relax boolinit.cocci checks for overall consistency
   - fix warning messages of boolinit.cocci

  Other tools:
   - improve -dirty check of scripts/setlocalversion
   - add a tool to generate compile_commands.json from .*.cmd files"

* tag 'kbuild-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (51 commits)
  kbuild: remove unused cmd_gentimeconst
  kbuild: remove $(obj)/ prefixes in ./Kbuild
  treewide: add intermediate .s files to targets
  treewide: remove explicit rules for *offsets.s
  firmware: refactor firmware/Makefile
  firmware: remove unnecessary patterns from .gitignore
  scripts: remove unnecessary ihex2fw and check-lc_ctypes from .gitignore
  um: remove unused filechk_gen_header in Makefile
  scripts: add a tool to produce a compile_commands.json file
  kbuild: add -Werror=implicit-int flag unconditionally
  kbuild: add -Werror=strict-prototypes flag unconditionally
  kbuild: add -fno-PIE flag unconditionally
  scripts: coccinelle: Correct warning message
  scripts: coccinelle: only suggest true/false in files that already use them
  kbuild: handle part-of-module correctly for *.ll and *.symtypes
  kbuild: refactor part-of-module
  kbuild: refactor quiet_modtag
  kbuild: remove redundant quiet_modtag for $(obj-m)
  kbuild: refactor Makefile.asm-generic
  user/Makefile: Fix typo and capitalization in comment section
  ...
parents d8372ba8 dec28d8e
...@@ -81,12 +81,7 @@ KBUILD_EXTMOD ...@@ -81,12 +81,7 @@ KBUILD_EXTMOD
-------------------------------------------------- --------------------------------------------------
Set the directory to look for the kernel source when building external Set the directory to look for the kernel source when building external
modules. modules.
The directory can be specified in several ways: Setting "M=..." takes precedence over KBUILD_EXTMOD.
1) Use "M=..." on the command line
2) Environment variable KBUILD_EXTMOD
3) Environment variable SUBDIRS
The possibilities are listed in the order they take precedence.
Using "M=..." will always override the others.
KBUILD_OUTPUT KBUILD_OUTPUT
-------------------------------------------------- --------------------------------------------------
......
...@@ -16,11 +16,7 @@ bounds-file := include/generated/bounds.h ...@@ -16,11 +16,7 @@ bounds-file := include/generated/bounds.h
always := $(bounds-file) always := $(bounds-file)
targets := kernel/bounds.s targets := kernel/bounds.s
# We use internal kbuild rules to avoid the "is up to date" message from make $(bounds-file): kernel/bounds.s FORCE
kernel/bounds.s: kernel/bounds.c FORCE
$(call if_changed_dep,cc_s_c)
$(obj)/$(bounds-file): kernel/bounds.s FORCE
$(call filechk,offsets,__LINUX_BOUNDS_H__) $(call filechk,offsets,__LINUX_BOUNDS_H__)
##### #####
...@@ -30,15 +26,11 @@ timeconst-file := include/generated/timeconst.h ...@@ -30,15 +26,11 @@ timeconst-file := include/generated/timeconst.h
targets += $(timeconst-file) targets += $(timeconst-file)
quiet_cmd_gentimeconst = GEN $@
define cmd_gentimeconst
(echo $(CONFIG_HZ) | bc -q $< ) > $@
endef
define filechk_gentimeconst define filechk_gentimeconst
(echo $(CONFIG_HZ) | bc -q $< ) (echo $(CONFIG_HZ) | bc -q $< )
endef endef
$(obj)/$(timeconst-file): kernel/time/timeconst.bc FORCE $(timeconst-file): kernel/time/timeconst.bc FORCE
$(call filechk,gentimeconst) $(call filechk,gentimeconst)
##### #####
...@@ -50,12 +42,9 @@ offsets-file := include/generated/asm-offsets.h ...@@ -50,12 +42,9 @@ offsets-file := include/generated/asm-offsets.h
always += $(offsets-file) always += $(offsets-file)
targets += arch/$(SRCARCH)/kernel/asm-offsets.s targets += arch/$(SRCARCH)/kernel/asm-offsets.s
# We use internal kbuild rules to avoid the "is up to date" message from make arch/$(SRCARCH)/kernel/asm-offsets.s: $(timeconst-file) $(bounds-file)
arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
$(obj)/$(timeconst-file) $(obj)/$(bounds-file) FORCE
$(call if_changed_dep,cc_s_c)
$(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE $(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s FORCE
$(call filechk,offsets,__ASM_OFFSETS_H__) $(call filechk,offsets,__ASM_OFFSETS_H__)
##### #####
...@@ -77,7 +66,7 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE ...@@ -77,7 +66,7 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE
extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
build_constants_py: $(obj)/$(timeconst-file) $(obj)/$(bounds-file) build_constants_py: $(timeconst-file) $(bounds-file)
@$(MAKE) $(build)=scripts/gdb/linux $@ @$(MAKE) $(build)=scripts/gdb/linux $@
# Keep these three files during make clean # Keep these three files during make clean
......
...@@ -186,6 +186,10 @@ endif ...@@ -186,6 +186,10 @@ endif
# Old syntax make ... SUBDIRS=$PWD is still supported # Old syntax make ... SUBDIRS=$PWD is still supported
# Setting the environment variable KBUILD_EXTMOD take precedence # Setting the environment variable KBUILD_EXTMOD take precedence
ifdef SUBDIRS ifdef SUBDIRS
$(warning ================= WARNING ================)
$(warning 'SUBDIRS' will be removed after Linux 5.3)
$(warning Please use 'M=' or 'KBUILD_EXTMOD' instead)
$(warning ==========================================)
KBUILD_EXTMOD ?= $(SUBDIRS) KBUILD_EXTMOD ?= $(SUBDIRS)
endif endif
...@@ -422,10 +426,10 @@ LINUXINCLUDE := \ ...@@ -422,10 +426,10 @@ LINUXINCLUDE := \
-I$(objtree)/include \ -I$(objtree)/include \
$(USERINCLUDE) $(USERINCLUDE)
KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common -fshort-wchar \ -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \
-Werror-implicit-function-declaration \ -Werror-implicit-function-declaration -Werror=implicit-int \
-Wno-format-security \ -Wno-format-security \
-std=gnu89 -std=gnu89
KBUILD_CPPFLAGS := -D__KERNEL__ KBUILD_CPPFLAGS := -D__KERNEL__
...@@ -487,18 +491,18 @@ endif ...@@ -487,18 +491,18 @@ endif
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
ifneq ($(CROSS_COMPILE),) ifneq ($(CROSS_COMPILE),)
CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%)) CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD)))
CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR) CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
endif endif
ifneq ($(GCC_TOOLCHAIN),) ifneq ($(GCC_TOOLCHAIN),)
CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN)
endif endif
KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) CLANG_FLAGS += -no-integrated-as
KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) KBUILD_CFLAGS += $(CLANG_FLAGS)
KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) KBUILD_AFLAGS += $(CLANG_FLAGS)
KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) export CLANG_FLAGS
endif endif
RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register
...@@ -510,9 +514,6 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc ...@@ -510,9 +514,6 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc
export RETPOLINE_CFLAGS export RETPOLINE_CFLAGS
export RETPOLINE_VDSO_CFLAGS export RETPOLINE_VDSO_CFLAGS
KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
# check for 'asm goto' # check for 'asm goto'
ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y) ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC) $(KBUILD_CFLAGS)), y)
CC_HAVE_ASM_GOTO := 1 CC_HAVE_ASM_GOTO := 1
...@@ -828,12 +829,6 @@ KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,) ...@@ -828,12 +829,6 @@ KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,)
# conserve stack if available # conserve stack if available
KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
# disallow errors like 'EXPORT_GPL(foo);' with missing header
KBUILD_CFLAGS += $(call cc-option,-Werror=implicit-int)
# require functions to have arguments in prototypes, not empty 'int foo()'
KBUILD_CFLAGS += $(call cc-option,-Werror=strict-prototypes)
# Prohibit date/time macros, which would make the build non-deterministic # Prohibit date/time macros, which would make the build non-deterministic
KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) KBUILD_CFLAGS += $(call cc-option,-Werror=date-time)
...@@ -1026,14 +1021,13 @@ cmd_link-vmlinux = \ ...@@ -1026,14 +1021,13 @@ cmd_link-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
ifdef CONFIG_HEADERS_CHECK
$(Q)$(MAKE) -f $(srctree)/Makefile headers_check
endif
ifdef CONFIG_GDB_SCRIPTS ifdef CONFIG_GDB_SCRIPTS
$(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py)
endif endif
+$(call if_changed,link-vmlinux) +$(call if_changed,link-vmlinux)
targets := vmlinux
# Build samples along the rest of the kernel. This needs headers_install. # Build samples along the rest of the kernel. This needs headers_install.
ifdef CONFIG_SAMPLES ifdef CONFIG_SAMPLES
vmlinux-dirs += samples vmlinux-dirs += samples
...@@ -1051,7 +1045,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ; ...@@ -1051,7 +1045,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
# Error messages still appears in the original language # Error messages still appears in the original language
PHONY += $(vmlinux-dirs) PHONY += $(vmlinux-dirs)
$(vmlinux-dirs): prepare scripts $(vmlinux-dirs): prepare
$(Q)$(MAKE) $(build)=$@ need-builtin=1 $(Q)$(MAKE) $(build)=$@ need-builtin=1
define filechk_kernel.release define filechk_kernel.release
...@@ -1066,7 +1060,7 @@ include/config/kernel.release: $(srctree)/Makefile FORCE ...@@ -1066,7 +1060,7 @@ include/config/kernel.release: $(srctree)/Makefile FORCE
# Carefully list dependencies so we do not try to build scripts twice # Carefully list dependencies so we do not try to build scripts twice
# in parallel # in parallel
PHONY += scripts PHONY += scripts
scripts: scripts_basic scripts_dtc asm-generic gcc-plugins $(autoksyms_h) scripts: scripts_basic scripts_dtc
$(Q)$(MAKE) $(build)=$(@) $(Q)$(MAKE) $(build)=$(@)
# Things we need to do before we recursively start building the kernel # Things we need to do before we recursively start building the kernel
...@@ -1099,22 +1093,23 @@ prepare2: prepare3 outputmakefile asm-generic ...@@ -1099,22 +1093,23 @@ prepare2: prepare3 outputmakefile asm-generic
prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
$(cmd_crmodverdir) $(cmd_crmodverdir)
archprepare: archheaders archscripts prepare1 scripts_basic archprepare: archheaders archscripts prepare1 scripts
prepare0: archprepare gcc-plugins prepare0: archprepare
$(Q)$(MAKE) $(build)=scripts/mod
$(Q)$(MAKE) $(build)=. $(Q)$(MAKE) $(build)=.
# All the preparing.. # All the preparing..
prepare: prepare0 prepare-objtool prepare: prepare0 prepare-objtool
# Support for using generic headers in asm-generic # Support for using generic headers in asm-generic
asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj
PHONY += asm-generic uapi-asm-generic PHONY += asm-generic uapi-asm-generic
asm-generic: uapi-asm-generic asm-generic: uapi-asm-generic
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm
src=asm obj=arch/$(SRCARCH)/include/generated/asm
uapi-asm-generic: uapi-asm-generic:
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm
src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm
PHONY += prepare-objtool PHONY += prepare-objtool
prepare-objtool: $(objtool_target) prepare-objtool: $(objtool_target)
...@@ -1199,6 +1194,10 @@ headers_check: headers_install ...@@ -1199,6 +1194,10 @@ headers_check: headers_install
$(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1 $(Q)$(MAKE) $(hdr-inst)=include/uapi dst=include HDRCHECK=1
$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) HDRCHECK=1 $(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi $(hdr-dst) HDRCHECK=1
ifdef CONFIG_HEADERS_CHECK
all: headers_check
endif
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Kernel selftest # Kernel selftest
...@@ -1283,7 +1282,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin) ...@@ -1283,7 +1282,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
# Target to prepare building external modules # Target to prepare building external modules
PHONY += modules_prepare PHONY += modules_prepare
modules_prepare: prepare scripts modules_prepare: prepare
# Target to install modules # Target to install modules
PHONY += modules_install PHONY += modules_install
...@@ -1551,9 +1550,6 @@ else # KBUILD_EXTMOD ...@@ -1551,9 +1550,6 @@ else # KBUILD_EXTMOD
# We are always building modules # We are always building modules
KBUILD_MODULES := 1 KBUILD_MODULES := 1
PHONY += crmodverdir
crmodverdir:
$(cmd_crmodverdir)
PHONY += $(objtree)/Module.symvers PHONY += $(objtree)/Module.symvers
$(objtree)/Module.symvers: $(objtree)/Module.symvers:
...@@ -1565,7 +1561,7 @@ $(objtree)/Module.symvers: ...@@ -1565,7 +1561,7 @@ $(objtree)/Module.symvers:
module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
PHONY += $(module-dirs) modules PHONY += $(module-dirs) modules
$(module-dirs): crmodverdir $(objtree)/Module.symvers $(module-dirs): prepare $(objtree)/Module.symvers
$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
modules: $(module-dirs) modules: $(module-dirs)
...@@ -1604,10 +1600,9 @@ help: ...@@ -1604,10 +1600,9 @@ help:
@echo ' clean - remove generated files in module directory only' @echo ' clean - remove generated files in module directory only'
@echo '' @echo ''
# Dummies... PHONY += prepare
PHONY += prepare scripts prepare:
prepare: ; $(cmd_crmodverdir)
scripts: ;
endif # KBUILD_EXTMOD endif # KBUILD_EXTMOD
clean: $(clean-dirs) clean: $(clean-dirs)
...@@ -1712,36 +1707,33 @@ else ...@@ -1712,36 +1707,33 @@ else
target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@)) target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
endif endif
%.s: %.c prepare scripts FORCE %.s: %.c prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.i: %.c prepare scripts FORCE %.i: %.c prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.o: %.c prepare scripts FORCE %.o: %.c prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.lst: %.c prepare scripts FORCE %.lst: %.c prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.s: %.S prepare scripts FORCE %.s: %.S prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.o: %.S prepare scripts FORCE %.o: %.S prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.symtypes: %.c prepare scripts FORCE %.symtypes: %.c prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
%.ll: %.c prepare scripts FORCE %.ll: %.c prepare FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@) $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
# Modules # Modules
/: prepare scripts FORCE /: prepare FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(build)=$(build-dir)
# Make sure the latest headers are built for Documentation # Make sure the latest headers are built for Documentation
Documentation/ samples/: headers_install Documentation/ samples/: headers_install
%/: prepare scripts FORCE %/: prepare FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(build)=$(build-dir)
%.ko: prepare scripts FORCE %.ko: prepare FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(@:.ko=.o) $(build)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
...@@ -1765,13 +1757,12 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) ...@@ -1765,13 +1757,12 @@ quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
$(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
# read all saved command lines # read saved command lines for existing targets
cmd_files := $(wildcard .*.cmd) existing-targets := $(wildcard $(sort $(targets)))
ifneq ($(cmd_files),) cmd_files := $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
$(cmd_files): ; # Do not try to update included dependency files $(cmd_files): ; # Do not try to update included dependency files
include $(cmd_files) -include $(cmd_files)
endif
endif # ifeq ($(config-targets),1) endif # ifeq ($(config-targets),1)
endif # ifeq ($(mixed-targets),1) endif # ifeq ($(mixed-targets),1)
......
...@@ -67,4 +67,4 @@ $(src)/sha512-core.S_shipped: $(src)/sha512-armv4.pl ...@@ -67,4 +67,4 @@ $(src)/sha512-core.S_shipped: $(src)/sha512-armv4.pl
$(call cmd,perl) $(call cmd,perl)
endif endif
targets += sha256-core.S sha512-core.S clean-files += sha256-core.S sha512-core.S
...@@ -19,10 +19,9 @@ ifeq ($(CONFIG_PM_DEBUG),y) ...@@ -19,10 +19,9 @@ ifeq ($(CONFIG_PM_DEBUG),y)
CFLAGS_pm.o += -DDEBUG CFLAGS_pm.o += -DDEBUG
endif endif
arch/arm/mach-at91/pm_data-offsets.s: arch/arm/mach-at91/pm_data-offsets.c
$(call if_changed_dep,cc_s_c)
include/generated/at91_pm_data-offsets.h: arch/arm/mach-at91/pm_data-offsets.s FORCE include/generated/at91_pm_data-offsets.h: arch/arm/mach-at91/pm_data-offsets.s FORCE
$(call filechk,offsets,__PM_DATA_OFFSETS_H__) $(call filechk,offsets,__PM_DATA_OFFSETS_H__)
arch/arm/mach-at91/pm_suspend.o: include/generated/at91_pm_data-offsets.h arch/arm/mach-at91/pm_suspend.o: include/generated/at91_pm_data-offsets.h
targets += pm_data-offsets.s
...@@ -236,10 +236,9 @@ obj-y += omap_phy_internal.o ...@@ -236,10 +236,9 @@ obj-y += omap_phy_internal.o
obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o
arch/arm/mach-omap2/pm-asm-offsets.s: arch/arm/mach-omap2/pm-asm-offsets.c
$(call if_changed_dep,cc_s_c)
include/generated/ti-pm-asm-offsets.h: arch/arm/mach-omap2/pm-asm-offsets.s FORCE include/generated/ti-pm-asm-offsets.h: arch/arm/mach-omap2/pm-asm-offsets.s FORCE
$(call filechk,offsets,__TI_PM_ASM_OFFSETS_H__) $(call filechk,offsets,__TI_PM_ASM_OFFSETS_H__)
$(obj)/sleep33xx.o $(obj)/sleep43xx.o: include/generated/ti-pm-asm-offsets.h $(obj)/sleep33xx.o $(obj)/sleep43xx.o: include/generated/ti-pm-asm-offsets.h
targets += pm-asm-offsets.s
...@@ -78,4 +78,4 @@ $(src)/sha512-core.S_shipped: $(src)/sha512-armv8.pl ...@@ -78,4 +78,4 @@ $(src)/sha512-core.S_shipped: $(src)/sha512-armv8.pl
$(call cmd,perlasm) $(call cmd,perlasm)
endif endif
targets += sha256-core.S sha512-core.S clean-files += sha256-core.S sha512-core.S
...@@ -50,10 +50,7 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31 ...@@ -50,10 +50,7 @@ CFLAGS_traps.o += -mfixed-range=f2-f5,f16-f31
# The gate DSO image is built using a special linker script. # The gate DSO image is built using a special linker script.
include $(src)/Makefile.gate include $(src)/Makefile.gate
# We use internal kbuild rules to avoid the "is up to date" message from make
arch/$(SRCARCH)/kernel/nr-irqs.s: arch/$(SRCARCH)/kernel/nr-irqs.c
$(Q)mkdir -p $(dir $@)
$(call if_changed_dep,cc_s_c)
include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE include/generated/nr-irqs.h: arch/$(SRCARCH)/kernel/nr-irqs.s FORCE
$(call filechk,offsets,__ASM_NR_IRQS_H__) $(call filechk,offsets,__ASM_NR_IRQS_H__)
targets += nr-irqs.s
...@@ -55,6 +55,11 @@ BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc ...@@ -55,6 +55,11 @@ BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
BOOTARFLAGS := -cr$(KBUILD_ARFLAGS) BOOTARFLAGS := -cr$(KBUILD_ARFLAGS)
ifdef CONFIG_CC_IS_CLANG
BOOTCFLAGS += $(CLANG_FLAGS)
BOOTAFLAGS += $(CLANG_FLAGS)
endif
ifdef CONFIG_DEBUG_INFO ifdef CONFIG_DEBUG_INFO
BOOTCFLAGS += -g BOOTCFLAGS += -g
endif endif
......
...@@ -23,8 +23,6 @@ OS := $(shell uname -s) ...@@ -23,8 +23,6 @@ OS := $(shell uname -s)
# features. # features.
SHELL := /bin/bash SHELL := /bin/bash
filechk_gen_header = $<
core-y += $(ARCH_DIR)/kernel/ \ core-y += $(ARCH_DIR)/kernel/ \
$(ARCH_DIR)/drivers/ \ $(ARCH_DIR)/drivers/ \
$(ARCH_DIR)/os-$(OS)/ $(ARCH_DIR)/os-$(OS)/
...@@ -116,7 +114,8 @@ endef ...@@ -116,7 +114,8 @@ endef
archheaders: archheaders:
$(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders
archprepare: include/generated/user_constants.h archprepare:
$(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h
LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 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)
...@@ -146,25 +145,4 @@ archclean: ...@@ -146,25 +145,4 @@ archclean:
@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
-o -name '*.gcov' \) -type f -print | xargs rm -f -o -name '*.gcov' \) -type f -print | xargs rm -f
# Generated files
$(HOST_DIR)/um/user-offsets.s: __headers FORCE
$(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@
define filechk_gen-asm-offsets
(set -e; \
echo "/*"; \
echo " * DO NOT MODIFY."; \
echo " *"; \
echo " * This file was generated by arch/$(ARCH)/Makefile"; \
echo " *"; \
echo " */"; \
echo ""; \
sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}" < $<; \
echo ""; )
endef
include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
$(call filechk,gen-asm-offsets)
export HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH export HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH
...@@ -36,9 +36,12 @@ subarch-$(CONFIG_MODULES) += ../kernel/module.o ...@@ -36,9 +36,12 @@ subarch-$(CONFIG_MODULES) += ../kernel/module.o
USER_OBJS := bugs_$(BITS).o ptrace_user.o fault.o USER_OBJS := bugs_$(BITS).o ptrace_user.o fault.o
extra-y += user-offsets.s
$(obj)/user-offsets.s: c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \ $(obj)/user-offsets.s: c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) \
-Iarch/x86/include/generated -Iarch/x86/include/generated
targets += user-offsets.s
include/generated/user_constants.h: $(obj)/user-offsets.s
$(call filechk,offsets,__USER_CONSTANT_H__)
UNPROFILE_OBJS := stub_segv.o UNPROFILE_OBJS := stub_segv.o
CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING) CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
......
drivers/memory/emif-asm-offsets.s: drivers/memory/emif-asm-offsets.c
$(call if_changed_dep,cc_s_c)
include/generated/ti-emif-asm-offsets.h: drivers/memory/emif-asm-offsets.s FORCE include/generated/ti-emif-asm-offsets.h: drivers/memory/emif-asm-offsets.s FORCE
$(call filechk,offsets,__TI_EMIF_ASM_OFFSETS_H__) $(call filechk,offsets,__TI_EMIF_ASM_OFFSETS_H__)
targets += emif-asm-offsets.s
...@@ -216,10 +216,3 @@ static void __exit cleanup_scx200_docflash(void) ...@@ -216,10 +216,3 @@ static void __exit cleanup_scx200_docflash(void)
module_init(init_scx200_docflash); module_init(init_scx200_docflash);
module_exit(cleanup_scx200_docflash); module_exit(cleanup_scx200_docflash);
/*
Local variables:
compile-command: "make -k -C ../../.. SUBDIRS=drivers/mtd/maps modules"
c-basic-offset: 8
End:
*/
...@@ -262,10 +262,3 @@ static void __exit scx200_wdt_cleanup(void) ...@@ -262,10 +262,3 @@ static void __exit scx200_wdt_cleanup(void)
module_init(scx200_wdt_init); module_init(scx200_wdt_init);
module_exit(scx200_wdt_cleanup); module_exit(scx200_wdt_cleanup);
/*
Local variables:
compile-command: "make -k -C ../.. SUBDIRS=drivers/char modules"
c-basic-offset: 8
End:
*/
*.gen.S *.gen.S
*.fw
*.bin
*.csp
*.dsp
ihex2fw
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
#
# kbuild file for firmware/
#
# Create $(fwabs) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a # Create $(fwdir) from $(CONFIG_EXTRA_FIRMWARE_DIR) -- if it doesn't have a
# leading /, it's relative to $(srctree). # leading /, it's relative to $(srctree).
fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR)) fwdir := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE_DIR))
fwabs := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir)) fwdir := $(addprefix $(srctree)/,$(filter-out /%,$(fwdir)))$(filter /%,$(fwdir))
fw-external-y := $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE)) obj-y := $(addsuffix .gen.o, $(subst $(quote),,$(CONFIG_EXTRA_FIRMWARE)))
quiet_cmd_fwbin = MK_FW $@ FWNAME = $(patsubst $(obj)/%.gen.S,%,$@)
cmd_fwbin = FWNAME="$(patsubst firmware/%.gen.S,%,$@)"; \ FWSTR = $(subst /,_,$(subst .,_,$(subst -,_,$(FWNAME))))
FWSTR="$(subst /,_,$(subst .,_,$(subst -,_,$(patsubst \ ASM_WORD = $(if $(CONFIG_64BIT),.quad,.long)
firmware/%.gen.S,%,$@))))"; \ ASM_ALIGN = $(if $(CONFIG_64BIT),3,2)
ASM_WORD=$(if $(CONFIG_64BIT),.quad,.long); \ PROGBITS = $(if $(CONFIG_ARM),%,@)progbits
ASM_ALIGN=$(if $(CONFIG_64BIT),3,2); \
PROGBITS=$(if $(CONFIG_ARM),%,@)progbits; \ filechk_fwbin = { \
echo "/* Generated by firmware/Makefile */" > $@;\ echo "/* Generated by $(src)/Makefile */" ;\
echo " .section .rodata" >>$@;\ echo " .section .rodata" ;\
echo " .p2align $${ASM_ALIGN}" >>$@;\ echo " .p2align $(ASM_ALIGN)" ;\
echo "_fw_$${FWSTR}_bin:" >>$@;\ echo "_fw_$(FWSTR)_bin:" ;\
echo " .incbin \"$(2)\"" >>$@;\ echo " .incbin \"$(fwdir)/$(FWNAME)\"" ;\
echo "_fw_end:" >>$@;\ echo "_fw_end:" ;\
echo " .section .rodata.str,\"aMS\",$${PROGBITS},1" >>$@;\ echo " .section .rodata.str,\"aMS\",$(PROGBITS),1" ;\
echo " .p2align $${ASM_ALIGN}" >>$@;\ echo " .p2align $(ASM_ALIGN)" ;\
echo "_fw_$${FWSTR}_name:" >>$@;\ echo "_fw_$(FWSTR)_name:" ;\
echo " .string \"$$FWNAME\"" >>$@;\ echo " .string \"$(FWNAME)\"" ;\
echo " .section .builtin_fw,\"a\",$${PROGBITS}" >>$@;\ echo " .section .builtin_fw,\"a\",$(PROGBITS)" ;\
echo " .p2align $${ASM_ALIGN}" >>$@;\ echo " .p2align $(ASM_ALIGN)" ;\
echo " $${ASM_WORD} _fw_$${FWSTR}_name" >>$@;\ echo " $(ASM_WORD) _fw_$(FWSTR)_name" ;\
echo " $${ASM_WORD} _fw_$${FWSTR}_bin" >>$@;\ echo " $(ASM_WORD) _fw_$(FWSTR)_bin" ;\
echo " $${ASM_WORD} _fw_end - _fw_$${FWSTR}_bin" >>$@; echo " $(ASM_WORD) _fw_end - _fw_$(FWSTR)_bin" ;\
}
# One of these files will change, or come into existence, whenever
# the configuration changes between 32-bit and 64-bit. The .S files $(obj)/%.gen.S: FORCE
# need to change when that happens. $(call filechk,fwbin)
wordsize_deps := $(wildcard include/config/64bit.h include/config/32bit.h \
include/config/ppc32.h include/config/ppc64.h \
include/config/superh32.h include/config/superh64.h \
include/config/x86_32.h include/config/x86_64.h \
firmware/Makefile)
$(patsubst %,$(obj)/%.gen.S, $(fw-external-y)): %: $(wordsize_deps) \
include/config/extra/firmware/dir.h
$(call cmd,fwbin,$(fwabs)/$(patsubst $(obj)/%.gen.S,%,$@))
# The .o files depend on the binaries directly; the .S files don't. # The .o files depend on the binaries directly; the .S files don't.
$(patsubst %,$(obj)/%.gen.o, $(fw-external-y)): $(obj)/%.gen.o: $(fwdir)/% $(addprefix $(obj)/, $(obj-y)): $(obj)/%.gen.o: $(fwdir)/%
obj-y += $(patsubst %,%.gen.o, $(fw-external-y))
ifeq ($(KBUILD_SRC),)
# Makefile.build only creates subdirectories for O= builds, but external
# firmware might live outside the kernel source tree
_dummy := $(foreach d,$(addprefix $(obj)/,$(dir $(fw-external-y))), $(shell [ -d $(d) ] || mkdir -p $(d)))
endif
targets := $(patsubst $(obj)/%,%, \ targets := $(patsubst $(obj)/%,%, \
$(shell find $(obj) -name \*.gen.S 2>/dev/null)) $(shell find $(obj) -name \*.gen.S 2>/dev/null))
...@@ -59,16 +59,19 @@ __kcrctab_\name: ...@@ -59,16 +59,19 @@ __kcrctab_\name:
.endm .endm
#undef __put #undef __put
#if defined(__KSYM_DEPS__) #if defined(CONFIG_TRIM_UNUSED_KSYMS)
#define __EXPORT_SYMBOL(sym, val, sec) === __KSYM_##sym ===
#elif defined(CONFIG_TRIM_UNUSED_KSYMS)
#include <linux/kconfig.h> #include <linux/kconfig.h>
#include <generated/autoksyms.h> #include <generated/autoksyms.h>
.macro __ksym_marker sym
.section ".discard.ksym","a"
__ksym_marker_\sym:
.previous
.endm
#define __EXPORT_SYMBOL(sym, val, sec) \ #define __EXPORT_SYMBOL(sym, val, sec) \
__ksym_marker sym; \
__cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym)) __cond_export_sym(sym, val, sec, __is_defined(__KSYM_##sym))
#define __cond_export_sym(sym, val, sec, conf) \ #define __cond_export_sym(sym, val, sec, conf) \
___cond_export_sym(sym, val, sec, conf) ___cond_export_sym(sym, val, sec, conf)
......
...@@ -92,22 +92,22 @@ struct kernel_symbol { ...@@ -92,22 +92,22 @@ struct kernel_symbol {
*/ */
#define __EXPORT_SYMBOL(sym, sec) #define __EXPORT_SYMBOL(sym, sec)
#elif defined(__KSYM_DEPS__) #elif defined(CONFIG_TRIM_UNUSED_KSYMS)
#include <generated/autoksyms.h>
/* /*
* For fine grained build dependencies, we want to tell the build system * For fine grained build dependencies, we want to tell the build system
* about each possible exported symbol even if they're not actually exported. * about each possible exported symbol even if they're not actually exported.
* We use a string pattern that is unlikely to be valid code that the build * We use a symbol pattern __ksym_marker_<symbol> that the build system filters
* system filters out from the preprocessor output (see ksym_dep_filter * from the $(NM) output (see scripts/gen_ksymdeps.sh). These symbols are
* in scripts/Kbuild.include). * discarded in the final link stage.
*/ */
#define __EXPORT_SYMBOL(sym, sec) === __KSYM_##sym === #define __ksym_marker(sym) \
static int __ksym_marker_##sym[0] __section(".discard.ksym") __used
#elif defined(CONFIG_TRIM_UNUSED_KSYMS)
#include <generated/autoksyms.h>
#define __EXPORT_SYMBOL(sym, sec) \ #define __EXPORT_SYMBOL(sym, sec) \
__ksym_marker(sym); \
__cond_export_sym(sym, sec, __is_defined(__KSYM_##sym)) __cond_export_sym(sym, sec, __is_defined(__KSYM_##sym))
#define __cond_export_sym(sym, sec, conf) \ #define __cond_export_sym(sym, sec, conf) \
___cond_export_sym(sym, sec, conf) ___cond_export_sym(sym, sec, conf)
......
...@@ -235,12 +235,10 @@ $(LIBBPF): FORCE ...@@ -235,12 +235,10 @@ $(LIBBPF): FORCE
# Fix up variables inherited from Kbuild that tools/ build system won't like # Fix up variables inherited from Kbuild that tools/ build system won't like
$(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O= $(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O=
$(obj)/syscall_nrs.s: $(src)/syscall_nrs.c
$(call if_changed_dep,cc_s_c)
$(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE
$(call filechk,offsets,__SYSCALL_NRS_H__) $(call filechk,offsets,__SYSCALL_NRS_H__)
targets += syscall_nrs.s
clean-files += syscall_nrs.h clean-files += syscall_nrs.h
FORCE: FORCE:
......
...@@ -14,4 +14,4 @@ HOSTCFLAGS_ucon.o += -I$(objtree)/usr/include ...@@ -14,4 +14,4 @@ HOSTCFLAGS_ucon.o += -I$(objtree)/usr/include
all: modules all: modules
modules clean: modules clean:
$(MAKE) -C ../.. SUBDIRS=$(CURDIR) $@ $(MAKE) -C ../.. M=$(CURDIR) $@
...@@ -6,9 +6,7 @@ conmakehash ...@@ -6,9 +6,7 @@ conmakehash
kallsyms kallsyms
pnmtologo pnmtologo
unifdef unifdef
ihex2fw
recordmcount recordmcount
check-lc_ctype
sortextable sortextable
asn1_compiler asn1_compiler
extract-cert extract-cert
......
...@@ -213,7 +213,7 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\ ...@@ -213,7 +213,7 @@ echo-cmd = $(if $($(quiet)cmd_$(1)),\
echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
# printing commands # printing commands
cmd = @$(echo-cmd) $(cmd_$(1)) cmd = @set -e; $(echo-cmd) $(cmd_$(1))
# Add $(obj)/ for paths that are not absolute # Add $(obj)/ for paths that are not absolute
objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
...@@ -249,56 +249,21 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) ...@@ -249,56 +249,21 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
# Execute command if command has changed or prerequisite(s) are updated. # Execute command if command has changed or prerequisite(s) are updated.
if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
@set -e; \ $(cmd); \
$(echo-cmd) $(cmd_$(1)); \
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
# Execute the command and also postprocess generated .d dependencies file. # Execute the command and also postprocess generated .d dependencies file.
if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ if_changed_dep = $(if $(strip $(any-prereq) $(arg-check)),$(cmd_and_fixdep),@:)
@set -e; \
$(cmd_and_fixdep), @:)
ifndef CONFIG_TRIM_UNUSED_KSYMS
cmd_and_fixdep = \ cmd_and_fixdep = \
$(echo-cmd) $(cmd_$(1)); \ $(cmd); \
scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).tmp;\ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\
rm -f $(depfile); \ rm -f $(depfile)
mv -f $(dot-target).tmp $(dot-target).cmd;
else
# Filter out exported kernel symbol names from the preprocessor output.
# See also __KSYM_DEPS__ in include/linux/export.h.
# We disable the depfile generation here, so as not to overwrite the existing
# depfile while fixdep is parsing it.
flags_nodeps = $(filter-out -Wp$(comma)-M%, $($(1)))
ksym_dep_filter = \
case "$(1)" in \
cc_*_c|cpp_i_c) \
$(CPP) $(call flags_nodeps,c_flags) -D__KSYM_DEPS__ $< ;; \
as_*_S|cpp_s_S) \
$(CPP) $(call flags_nodeps,a_flags) -D__KSYM_DEPS__ $< ;; \
boot*|build*|cpp_its_S|*cpp_lds_S|dtc|host*|vdso*) : ;; \
*) echo "Don't know how to preprocess $(1)" >&2; false ;; \
esac | tr ";" "\n" | sed -n 's/^.*=== __KSYM_\(.*\) ===.*$$/_\1/p'
cmd_and_fixdep = \
$(echo-cmd) $(cmd_$(1)); \
$(ksym_dep_filter) | \
scripts/basic/fixdep -e $(depfile) $@ '$(make-cmd)' \
> $(dot-target).tmp; \
rm -f $(depfile); \
mv -f $(dot-target).tmp $(dot-target).cmd;
endif
# Usage: $(call if_changed_rule,foo) # Usage: $(call if_changed_rule,foo)
# Will check if $(cmd_foo) or any of the prerequisites changed, # Will check if $(cmd_foo) or any of the prerequisites changed,
# and if so will execute $(rule_foo). # and if so will execute $(rule_foo).
if_changed_rule = $(if $(strip $(any-prereq) $(arg-check) ), \ if_changed_rule = $(if $(strip $(any-prereq) $(arg-check)),$(rule_$(1)),@:)
@set -e; \
$(rule_$(1)), @:)
### ###
# why - tell why a target got built # why - tell why a target got built
...@@ -391,3 +356,6 @@ endef ...@@ -391,3 +356,6 @@ endef
# delete partially updated (i.e. corrupted) files on error # delete partially updated (i.e. corrupted) files on error
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
# do not delete intermediate files automatically
.SECONDARY:
...@@ -36,10 +36,10 @@ PHONY += build_unifdef ...@@ -36,10 +36,10 @@ PHONY += build_unifdef
build_unifdef: $(obj)/unifdef build_unifdef: $(obj)/unifdef
@: @:
subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins
subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_MODVERSIONS) += genksyms
subdir-y += mod
subdir-$(CONFIG_SECURITY_SELINUX) += selinux subdir-$(CONFIG_SECURITY_SELINUX) += selinux
subdir-$(CONFIG_GDB_SCRIPTS) += gdb subdir-$(CONFIG_GDB_SCRIPTS) += gdb
# Let clean descend into subdirs # Let clean descend into subdirs
subdir- += basic dtc kconfig package gcc-plugins subdir- += basic dtc kconfig mod package
...@@ -2,41 +2,42 @@ ...@@ -2,41 +2,42 @@
# include/asm-generic contains a lot of files that are used # include/asm-generic contains a lot of files that are used
# verbatim by several architectures. # verbatim by several architectures.
# #
# This Makefile reads the file arch/$(SRCARCH)/include/$(src)/Kbuild # This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild
# and for each file listed in this file with generic-y creates # and for each file listed in this file with generic-y creates
# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/$(src)) # a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm.
PHONY := all PHONY := all
all: all:
kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild src := $(subst /generated,,$(obj))
-include $(kbuild-file) -include $(src)/Kbuild
include scripts/Kbuild.include include scripts/Kbuild.include
# Create output directory if not already present generic-y := $(addprefix $(obj)/, $(generic-y))
_dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) generated-y := $(addprefix $(obj)/, $(generated-y))
# Stale wrappers when the corresponding files are removed from generic-y # Remove stale wrappers when the corresponding files are removed from generic-y
# need removing. old-headers := $(wildcard $(obj)/*.h)
generated-y := $(generic-y) $(generated-y) unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers))
all-files := $(patsubst %, $(obj)/%, $(generated-y))
old-headers := $(wildcard $(obj)/*.h)
unwanted := $(filter-out $(all-files),$(old-headers))
quiet_cmd_wrap = WRAP $@ quiet_cmd_wrap = WRAP $@
cmd_wrap = echo "\#include <asm-generic/$*.h>" >$@ cmd_wrap = echo "\#include <asm-generic/$*.h>" > $@
quiet_cmd_remove = REMOVE $(unwanted) quiet_cmd_remove = REMOVE $(unwanted)
cmd_remove = rm -f $(unwanted) cmd_remove = rm -f $(unwanted)
all: $(patsubst %, $(obj)/%, $(generic-y)) FORCE all: $(generic-y)
$(if $(unwanted),$(call cmd,remove),) $(if $(unwanted),$(call cmd,remove))
@: @:
$(obj)/%.h: $(obj)/%.h:
$(call cmd,wrap) $(call cmd,wrap)
PHONY += FORCE # Create output directory. Skip it if at least one old header exists
# since we know the output directory already exists.
ifeq ($(old-headers),)
$(shell mkdir -p $(obj))
endif
.PHONY: $(PHONY) .PHONY: $(PHONY)
FORCE: ;
...@@ -75,14 +75,14 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ ...@@ -75,14 +75,14 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
# Linus' kernel sanity checking tool # Linus' kernel sanity checking tool
ifeq ($(KBUILD_CHECKSRC),1) ifeq ($(KBUILD_CHECKSRC),1)
quiet_cmd_checksrc = CHECK $< quiet_cmd_checksrc = CHECK $<
cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
else ifeq ($(KBUILD_CHECKSRC),2) else ifeq ($(KBUILD_CHECKSRC),2)
quiet_cmd_force_checksrc = CHECK $< quiet_cmd_force_checksrc = CHECK $<
cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $<
endif endif
ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ; cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
endif endif
# Do section mismatch analysis for each module/built-in.a # Do section mismatch analysis for each module/built-in.a
...@@ -94,23 +94,14 @@ endif ...@@ -94,23 +94,14 @@ endif
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Default is built-in, unless we know otherwise # Default is built-in, unless we know otherwise
$(foreach x, i ll lst o s symtypes, $(patsubst %.o,%.$(x),$(real-obj-m))): \
part-of-module := y
modkern_cflags = \ modkern_cflags = \
$(if $(part-of-module), \ $(if $(part-of-module), \
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
quiet_modtag := $(empty) $(empty) quiet_modtag = $(if $(part-of-module),[M], )
$(real-obj-m) : part-of-module := y
$(real-obj-m:.o=.i) : part-of-module := y
$(real-obj-m:.o=.s) : part-of-module := y
$(real-obj-m:.o=.lst): part-of-module := y
$(real-obj-m) : quiet_modtag := [M]
$(real-obj-m:.o=.i) : quiet_modtag := [M]
$(real-obj-m:.o=.s) : quiet_modtag := [M]
$(real-obj-m:.o=.lst): quiet_modtag := [M]
$(obj-m) : quiet_modtag := [M]
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
...@@ -134,7 +125,6 @@ cmd_gensymtypes_c = \ ...@@ -134,7 +125,6 @@ cmd_gensymtypes_c = \
quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
cmd_cc_symtypes_c = \ cmd_cc_symtypes_c = \
set -e; \
$(call cmd_gensymtypes_c,true,$@) >/dev/null; \ $(call cmd_gensymtypes_c,true,$@) >/dev/null; \
test -s $@ || rm -f $@ test -s $@ || rm -f $@
...@@ -154,36 +144,31 @@ $(obj)/%.ll: $(src)/%.c FORCE ...@@ -154,36 +144,31 @@ $(obj)/%.ll: $(src)/%.c FORCE
# (See cmd_cc_o_c + relevant part of rule_cc_o_c) # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
ifndef CONFIG_MODVERSIONS ifdef CONFIG_MODVERSIONS
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
else
# When module versioning is enabled the following steps are executed: # When module versioning is enabled the following steps are executed:
# o compile a .tmp_<file>.o from <file>.c # o compile a <file>.o from <file>.c
# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does # o if <file>.o doesn't contain a __ksymtab version, i.e. does
# not export symbols, we just rename .tmp_<file>.o to <file>.o and # not export symbols, it's done.
# are done.
# o otherwise, we calculate symbol versions using the good old # o otherwise, we calculate symbol versions using the good old
# genksyms on the preprocessed source and postprocess them in a way # genksyms on the preprocessed source and postprocess them in a way
# that they are usable as a linker script # that they are usable as a linker script
# o generate <file>.o from .tmp_<file>.o using the linker to # o generate .tmp_<file>.o from <file>.o using the linker to
# replace the unresolved symbols __crc_exported_symbol with # replace the unresolved symbols __crc_exported_symbol with
# the actual value of the checksum generated by genksyms # the actual value of the checksum generated by genksyms
# o remove .tmp_<file>.o to <file>.o
cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
cmd_modversions_c = \ cmd_modversions_c = \
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> $(@D)/.tmp_$(@F:.o=.ver); \ > $(@D)/.tmp_$(@F:.o=.ver); \
\ \
$(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
-T $(@D)/.tmp_$(@F:.o=.ver); \ -T $(@D)/.tmp_$(@F:.o=.ver); \
rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
else \
mv -f $(@D)/.tmp_$(@F) $@; \ mv -f $(@D)/.tmp_$(@F) $@; \
fi; rm -f $(@D)/.tmp_$(@F:.o=.ver); \
fi
endif endif
ifdef CONFIG_FTRACE_MCOUNT_RECORD ifdef CONFIG_FTRACE_MCOUNT_RECORD
...@@ -204,7 +189,7 @@ sub_cmd_record_mcount = \ ...@@ -204,7 +189,7 @@ sub_cmd_record_mcount = \
recordmcount_source := $(srctree)/scripts/recordmcount.c \ recordmcount_source := $(srctree)/scripts/recordmcount.c \
$(srctree)/scripts/recordmcount.h $(srctree)/scripts/recordmcount.h
else else
sub_cmd_record_mcount = set -e ; perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \
"$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \
"$(if $(CONFIG_64BIT),64,32)" \ "$(if $(CONFIG_64BIT),64,32)" \
"$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)" \ "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)" \
...@@ -216,7 +201,7 @@ cmd_record_mcount = \ ...@@ -216,7 +201,7 @@ cmd_record_mcount = \
if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \ if [ "$(findstring $(CC_FLAGS_FTRACE),$(_c_flags))" = \
"$(CC_FLAGS_FTRACE)" ]; then \ "$(CC_FLAGS_FTRACE)" ]; then \
$(sub_cmd_record_mcount) \ $(sub_cmd_record_mcount) \
fi; fi
endif # CC_USING_RECORD_MCOUNT endif # CC_USING_RECORD_MCOUNT
endif # CONFIG_FTRACE_MCOUNT_RECORD endif # CONFIG_FTRACE_MCOUNT_RECORD
...@@ -239,19 +224,12 @@ ifdef CONFIG_RETPOLINE ...@@ -239,19 +224,12 @@ ifdef CONFIG_RETPOLINE
objtool_args += --retpoline objtool_args += --retpoline
endif endif
ifdef CONFIG_MODVERSIONS
objtool_o = $(@D)/.tmp_$(@F)
else
objtool_o = $(@)
endif
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory # 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file # 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file # 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
cmd_objtool = $(if $(patsubst y%,, \ cmd_objtool = $(if $(patsubst y%,, \
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
$(__objtool_obj) $(objtool_args) "$(objtool_o)";) $(__objtool_obj) $(objtool_args) $@)
objtool_obj = $(if $(patsubst y%,, \ objtool_obj = $(if $(patsubst y%,, \
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
$(__objtool_obj)) $(__objtool_obj))
...@@ -264,19 +242,26 @@ objtool_dep = $(objtool_obj) \ ...@@ -264,19 +242,26 @@ objtool_dep = $(objtool_obj) \
$(wildcard include/config/orc/unwinder.h \ $(wildcard include/config/orc/unwinder.h \
include/config/stack/validation.h) include/config/stack/validation.h)
ifdef CONFIG_TRIM_UNUSED_KSYMS
cmd_gen_ksymdeps = \
$(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd
endif
define rule_cc_o_c define rule_cc_o_c
$(call echo-cmd,checksrc) $(cmd_checksrc) \ $(call cmd,checksrc)
$(call cmd_and_fixdep,cc_o_c) \ $(call cmd_and_fixdep,cc_o_c)
$(cmd_checkdoc) \ $(call cmd,gen_ksymdeps)
$(call echo-cmd,objtool) $(cmd_objtool) \ $(call cmd,checkdoc)
$(cmd_modversions_c) \ $(call cmd,objtool)
$(call echo-cmd,record_mcount) $(cmd_record_mcount) $(call cmd,modversions_c)
$(call cmd,record_mcount)
endef endef
define rule_as_o_S define rule_as_o_S
$(call cmd_and_fixdep,as_o_S) \ $(call cmd_and_fixdep,as_o_S)
$(call echo-cmd,objtool) $(cmd_objtool) \ $(call cmd,gen_ksymdeps)
$(cmd_modversions_S) $(call cmd,objtool)
$(call cmd,modversions_S)
endef endef
# List module undefined symbols (or empty line if not enabled) # List module undefined symbols (or empty line if not enabled)
...@@ -340,7 +325,6 @@ cmd_gensymtypes_S = \ ...@@ -340,7 +325,6 @@ cmd_gensymtypes_S = \
quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@
cmd_cc_symtypes_S = \ cmd_cc_symtypes_S = \
set -e; \
$(call cmd_gensymtypes_S,true,$@) >/dev/null; \ $(call cmd_gensymtypes_S,true,$@) >/dev/null; \
test -s $@ || rm -f $@ test -s $@ || rm -f $@
...@@ -355,35 +339,27 @@ $(obj)/%.s: $(src)/%.S FORCE ...@@ -355,35 +339,27 @@ $(obj)/%.s: $(src)/%.S FORCE
$(call if_changed_dep,cpp_s_S) $(call if_changed_dep,cpp_s_S)
quiet_cmd_as_o_S = AS $(quiet_modtag) $@ quiet_cmd_as_o_S = AS $(quiet_modtag) $@
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
ifndef CONFIG_MODVERSIONS ifdef CONFIG_MODVERSIONS
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
else
ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
ifeq ($(ASM_PROTOTYPES),) ifneq ($(ASM_PROTOTYPES),)
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
else
# versioning matches the C process described above, with difference that # versioning matches the C process described above, with difference that
# we parse asm-prototypes.h C header to get function definitions. # we parse asm-prototypes.h C header to get function definitions.
cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $<
cmd_modversions_S = \ cmd_modversions_S = \
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
$(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
> $(@D)/.tmp_$(@F:.o=.ver); \ > $(@D)/.tmp_$(@F:.o=.ver); \
\ \
$(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
-T $(@D)/.tmp_$(@F:.o=.ver); \ -T $(@D)/.tmp_$(@F:.o=.ver); \
rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
else \
mv -f $(@D)/.tmp_$(@F) $@; \ mv -f $(@D)/.tmp_$(@F) $@; \
fi; rm -f $(@D)/.tmp_$(@F:.o=.ver); \
fi
endif endif
endif endif
...@@ -527,25 +503,19 @@ FORCE: ...@@ -527,25 +503,19 @@ FORCE:
# optimization, we don't need to read them if the target does not # optimization, we don't need to read them if the target does not
# exist, we will rebuild anyway in that case. # exist, we will rebuild anyway in that case.
cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) existing-targets := $(wildcard $(sort $(targets)))
ifneq ($(cmd_files),) -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
include $(cmd_files)
endif
ifneq ($(KBUILD_SRC),) ifneq ($(KBUILD_SRC),)
# 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 $(obj) $(patsubst %/,%, $(dir $(targets))))
# If cmd_files exist, their directories apparently exist. Skip mkdir. # If targets exist, their directories apparently exist. Skip mkdir.
exist-dirs := $(sort $(patsubst %/,%, $(dir $(cmd_files)))) existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets))))
obj-dirs := $(strip $(filter-out $(exist-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 endif
# Some files contained in $(targets) are intermediate artifacts.
# We never want them to be removed automatically.
.SECONDARY: $(targets)
.PHONY: $(PHONY) .PHONY: $(PHONY)
...@@ -55,11 +55,3 @@ KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) ...@@ -55,11 +55,3 @@ KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
# All enabled GCC plugins are collected here for building below. # All enabled GCC plugins are collected here for building below.
GCC_PLUGIN := $(gcc-plugin-y) GCC_PLUGIN := $(gcc-plugin-y)
export GCC_PLUGIN export GCC_PLUGIN
# Actually do the build, if requested.
PHONY += gcc-plugins
gcc-plugins: scripts_basic
ifdef CONFIG_GCC_PLUGINS
$(Q)$(MAKE) $(build)=scripts/gcc-plugins
endif
@:
...@@ -44,7 +44,6 @@ kbuild-file := $(srctree)/$(obj)/Kbuild ...@@ -44,7 +44,6 @@ kbuild-file := $(srctree)/$(obj)/Kbuild
installdir := $(INSTALL_HDR_PATH)/$(dst) installdir := $(INSTALL_HDR_PATH)/$(dst)
gendir := $(objtree)/$(subst include/,include/generated/,$(obj)) gendir := $(objtree)/$(subst include/,include/generated/,$(obj))
header-files := $(notdir $(wildcard $(srcdir)/*.h)) header-files := $(notdir $(wildcard $(srcdir)/*.h))
header-files += $(notdir $(wildcard $(srcdir)/*.agh))
header-files := $(filter-out $(no-export-headers), $(header-files)) header-files := $(filter-out $(no-export-headers), $(header-files))
genhdr-files := $(notdir $(wildcard $(gendir)/*.h)) genhdr-files := $(notdir $(wildcard $(gendir)/*.h))
genhdr-files := $(filter-out $(header-files), $(genhdr-files)) genhdr-files := $(filter-out $(header-files), $(genhdr-files))
......
...@@ -426,7 +426,7 @@ endef ...@@ -426,7 +426,7 @@ endef
# Use filechk to avoid rebuilds when a header changes, but the resulting file # Use filechk to avoid rebuilds when a header changes, but the resulting file
# does not # does not
define filechk_offsets define filechk_offsets
(set -e; \ ( \
echo "#ifndef $2"; \ echo "#ifndef $2"; \
echo "#define $2"; \ echo "#define $2"; \
echo "/*"; \ echo "/*"; \
......
...@@ -105,8 +105,7 @@ ...@@ -105,8 +105,7 @@
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "Usage: fixdep [-e] <depfile> <target> <cmdline>\n"); fprintf(stderr, "Usage: fixdep <depfile> <target> <cmdline>\n");
fprintf(stderr, " -e insert extra dependencies given on stdin\n");
exit(1); exit(1);
} }
...@@ -131,21 +130,6 @@ static void print_dep(const char *m, int slen, const char *dir) ...@@ -131,21 +130,6 @@ static void print_dep(const char *m, int slen, const char *dir)
printf(".h) \\\n"); printf(".h) \\\n");
} }
static void do_extra_deps(void)
{
char buf[80];
while (fgets(buf, sizeof(buf), stdin)) {
int len = strlen(buf);
if (len < 2 || buf[len - 1] != '\n') {
fprintf(stderr, "fixdep: bad data on stdin\n");
exit(1);
}
print_dep(buf, len - 1, "include/ksym");
}
}
struct item { struct item {
struct item *next; struct item *next;
unsigned int len; unsigned int len;
...@@ -293,7 +277,7 @@ static int is_ignored_file(const char *s, int len) ...@@ -293,7 +277,7 @@ static int is_ignored_file(const char *s, int len)
* assignments are parsed not only by make, but also by the rather simple * assignments are parsed not only by make, but also by the rather simple
* parser in scripts/mod/sumversion.c. * parser in scripts/mod/sumversion.c.
*/ */
static void parse_dep_file(char *m, const char *target, int insert_extra_deps) static void parse_dep_file(char *m, const char *target)
{ {
char *p; char *p;
int is_last, is_target; int is_last, is_target;
...@@ -369,9 +353,6 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps) ...@@ -369,9 +353,6 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps)
exit(1); exit(1);
} }
if (insert_extra_deps)
do_extra_deps();
printf("\n%s: $(deps_%s)\n\n", target, target); printf("\n%s: $(deps_%s)\n\n", target, target);
printf("$(deps_%s):\n", target); printf("$(deps_%s):\n", target);
} }
...@@ -379,13 +360,9 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps) ...@@ -379,13 +360,9 @@ static void parse_dep_file(char *m, const char *target, int insert_extra_deps)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
const char *depfile, *target, *cmdline; const char *depfile, *target, *cmdline;
int insert_extra_deps = 0;
void *buf; void *buf;
if (argc == 5 && !strcmp(argv[1], "-e")) { if (argc != 4)
insert_extra_deps = 1;
argv++;
} else if (argc != 4)
usage(); usage();
depfile = argv[1]; depfile = argv[1];
...@@ -395,7 +372,7 @@ int main(int argc, char *argv[]) ...@@ -395,7 +372,7 @@ int main(int argc, char *argv[])
printf("cmd_%s := %s\n\n", target, cmdline); printf("cmd_%s := %s\n\n", target, cmdline);
buf = read_file(depfile); buf = read_file(depfile);
parse_dep_file(buf, target, insert_extra_deps); parse_dep_file(buf, target);
free(buf); free(buf);
return 0; return 0;
......
...@@ -13,10 +13,17 @@ virtual context ...@@ -13,10 +13,17 @@ virtual context
virtual org virtual org
virtual report virtual report
@boolok@
symbol true,false;
@@
(
true
|
false
)
@depends on patch@ @depends on patch@
bool t; bool t;
symbol true;
symbol false;
@@ @@
( (
...@@ -63,7 +70,7 @@ bool t; ...@@ -63,7 +70,7 @@ bool t;
+ t + t
) )
@depends on patch@ @depends on patch && boolok@
bool b; bool b;
@@ @@
( (
...@@ -116,19 +123,23 @@ position p; ...@@ -116,19 +123,23 @@ position p;
* t@p != 0 * t@p != 0
) )
@r3 depends on !patch@ @r3 depends on !patch && boolok@
bool b; bool b;
position p1,p2; position p1;
constant c;
@@ @@
( (
*b@p1 = 0 *b@p1 = 0
| |
*b@p1 = 1 *b@p1 = 1
|
*b@p2 = c
) )
@r4 depends on !patch@
bool b;
position p2;
constant c != {0,1};
@@
*b@p2 = c
@script:python depends on org@ @script:python depends on org@
p << r1.p; p << r1.p;
@@ @@
...@@ -139,19 +150,19 @@ cocci.print_main("WARNING: Comparison to bool",p) ...@@ -139,19 +150,19 @@ cocci.print_main("WARNING: Comparison to bool",p)
p << r2.p; p << r2.p;
@@ @@
cocci.print_main("WARNING: Comparison of bool to 0/1",p) cocci.print_main("WARNING: Comparison of 0/1 to bool variable",p)
@script:python depends on org@ @script:python depends on org@
p1 << r3.p1; p1 << r3.p1;
@@ @@
cocci.print_main("WARNING: Assignment of bool to 0/1",p1) cocci.print_main("WARNING: Assignment of 0/1 to bool variable",p1)
@script:python depends on org@ @script:python depends on org@
p2 << r3.p2; p2 << r4.p2;
@@ @@
cocci.print_main("ERROR: Assignment of bool to non-0/1 constant",p2) cocci.print_main("ERROR: Assignment of non-0/1 constant to bool variable",p2)
@script:python depends on report@ @script:python depends on report@
p << r1.p; p << r1.p;
...@@ -163,16 +174,16 @@ coccilib.report.print_report(p[0],"WARNING: Comparison to bool") ...@@ -163,16 +174,16 @@ coccilib.report.print_report(p[0],"WARNING: Comparison to bool")
p << r2.p; p << r2.p;
@@ @@
coccilib.report.print_report(p[0],"WARNING: Comparison of bool to 0/1") coccilib.report.print_report(p[0],"WARNING: Comparison of 0/1 to bool variable")
@script:python depends on report@ @script:python depends on report@
p1 << r3.p1; p1 << r3.p1;
@@ @@
coccilib.report.print_report(p1[0],"WARNING: Assignment of bool to 0/1") coccilib.report.print_report(p1[0],"WARNING: Assignment of 0/1 to bool variable")
@script:python depends on report@ @script:python depends on report@
p2 << r3.p2; p2 << r4.p2;
@@ @@
coccilib.report.print_report(p2[0],"ERROR: Assignment of bool to non-0/1 constant") coccilib.report.print_report(p2[0],"ERROR: Assignment of non-0/1 constant to bool variable")
#!/usr/bin/env python
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) Google LLC, 2018
#
# Author: Tom Roeder <tmroeder@google.com>
#
"""A tool for generating compile_commands.json in the Linux kernel."""
import argparse
import json
import logging
import os
import re
_DEFAULT_OUTPUT = 'compile_commands.json'
_DEFAULT_LOG_LEVEL = 'WARNING'
_FILENAME_PATTERN = r'^\..*\.cmd$'
_LINE_PATTERN = r'^cmd_[^ ]*\.o := (.* )([^ ]*\.c)$'
_VALID_LOG_LEVELS = ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']
# A kernel build generally has over 2000 entries in its compile_commands.json
# database. If this code finds 500 or fewer, then warn the user that they might
# not have all the .cmd files, and they might need to compile the kernel.
_LOW_COUNT_THRESHOLD = 500
def parse_arguments():
"""Sets up and parses command-line arguments.
Returns:
log_level: A logging level to filter log output.
directory: The directory to search for .cmd files.
output: Where to write the compile-commands JSON file.
"""
usage = 'Creates a compile_commands.json database from kernel .cmd files'
parser = argparse.ArgumentParser(description=usage)
directory_help = ('Path to the kernel source directory to search '
'(defaults to the working directory)')
parser.add_argument('-d', '--directory', type=str, help=directory_help)
output_help = ('The location to write compile_commands.json (defaults to '
'compile_commands.json in the search directory)')
parser.add_argument('-o', '--output', type=str, help=output_help)
log_level_help = ('The level of log messages to produce (one of ' +
', '.join(_VALID_LOG_LEVELS) + '; defaults to ' +
_DEFAULT_LOG_LEVEL + ')')
parser.add_argument(
'--log_level', type=str, default=_DEFAULT_LOG_LEVEL,
help=log_level_help)
args = parser.parse_args()
log_level = args.log_level
if log_level not in _VALID_LOG_LEVELS:
raise ValueError('%s is not a valid log level' % log_level)
directory = args.directory or os.getcwd()
output = args.output or os.path.join(directory, _DEFAULT_OUTPUT)
directory = os.path.abspath(directory)
return log_level, directory, output
def process_line(root_directory, file_directory, command_prefix, relative_path):
"""Extracts information from a .cmd line and creates an entry from it.
Args:
root_directory: The directory that was searched for .cmd files. Usually
used directly in the "directory" entry in compile_commands.json.
file_directory: The path to the directory the .cmd file was found in.
command_prefix: The extracted command line, up to the last element.
relative_path: The .c file from the end of the extracted command.
Usually relative to root_directory, but sometimes relative to
file_directory and sometimes neither.
Returns:
An entry to append to compile_commands.
Raises:
ValueError: Could not find the extracted file based on relative_path and
root_directory or file_directory.
"""
# The .cmd files are intended to be included directly by Make, so they
# escape the pound sign '#', either as '\#' or '$(pound)' (depending on the
# kernel version). The compile_commands.json file is not interepreted
# by Make, so this code replaces the escaped version with '#'.
prefix = command_prefix.replace('\#', '#').replace('$(pound)', '#')
cur_dir = root_directory
expected_path = os.path.join(cur_dir, relative_path)
if not os.path.exists(expected_path):
# Try using file_directory instead. Some of the tools have a different
# style of .cmd file than the kernel.
cur_dir = file_directory
expected_path = os.path.join(cur_dir, relative_path)
if not os.path.exists(expected_path):
raise ValueError('File %s not in %s or %s' %
(relative_path, root_directory, file_directory))
return {
'directory': cur_dir,
'file': relative_path,
'command': prefix + relative_path,
}
def main():
"""Walks through the directory and finds and parses .cmd files."""
log_level, directory, output = parse_arguments()
level = getattr(logging, log_level)
logging.basicConfig(format='%(levelname)s: %(message)s', level=level)
filename_matcher = re.compile(_FILENAME_PATTERN)
line_matcher = re.compile(_LINE_PATTERN)
compile_commands = []
for dirpath, _, filenames in os.walk(directory):
for filename in filenames:
if not filename_matcher.match(filename):
continue
filepath = os.path.join(dirpath, filename)
with open(filepath, 'rt') as f:
for line in f:
result = line_matcher.match(line)
if not result:
continue
try:
entry = process_line(directory, dirpath,
result.group(1), result.group(2))
compile_commands.append(entry)
except ValueError as err:
logging.info('Could not add line from %s: %s',
filepath, err)
with open(output, 'wt') as f:
json.dump(compile_commands, f, indent=2, sort_keys=True)
count = len(compile_commands)
if count < _LOW_COUNT_THRESHOLD:
logging.warning(
'Found %s entries. Have you compiled the kernel?', count)
if __name__ == '__main__':
main()
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
set -e
# List of exported symbols
ksyms=$($NM $1 | sed -n 's/.*__ksym_marker_\(.*\)/\1/p' | tr A-Z a-z)
if [ -z "$ksyms" ]; then
exit 0
fi
echo
echo "ksymdeps_$1 := \\"
for s in $ksyms
do
echo $s | sed -e 's:^_*: $(wildcard include/ksym/:' \
-e 's:__*:/:g' -e 's/$/.h) \\/'
done
echo
echo "$1: \$(ksymdeps_$1)"
echo
echo "\$(ksymdeps_$1):"
This diff is collapsed.
...@@ -1163,6 +1163,14 @@ static const struct sectioncheck *section_mismatch( ...@@ -1163,6 +1163,14 @@ static const struct sectioncheck *section_mismatch(
* fromsec = text section * fromsec = text section
* refsymname = *.constprop.* * refsymname = *.constprop.*
* *
* Pattern 6:
* Hide section mismatch warnings for ELF local symbols. The goal
* is to eliminate false positive modpost warnings caused by
* compiler-generated ELF local symbol names such as ".LANCHOR1".
* Autogenerated symbol names bypass modpost's "Pattern 2"
* whitelisting, which relies on pattern-matching against symbol
* names to work. (One situation where gcc can autogenerate ELF
* local symbols is when "-fsection-anchors" is used.)
**/ **/
static int secref_whitelist(const struct sectioncheck *mismatch, static int secref_whitelist(const struct sectioncheck *mismatch,
const char *fromsec, const char *fromsym, const char *fromsec, const char *fromsym,
...@@ -1201,9 +1209,37 @@ static int secref_whitelist(const struct sectioncheck *mismatch, ...@@ -1201,9 +1209,37 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
match(fromsym, optim_symbols)) match(fromsym, optim_symbols))
return 0; return 0;
/* Check for pattern 6 */
if (strstarts(fromsym, ".L"))
return 0;
return 1; return 1;
} }
static inline int is_arm_mapping_symbol(const char *str)
{
return str[0] == '$' && strchr("axtd", str[1])
&& (str[2] == '\0' || str[2] == '.');
}
/*
* If there's no name there, ignore it; likewise, ignore it if it's
* one of the magic symbols emitted used by current ARM tools.
*
* Otherwise if find_symbols_between() returns those symbols, they'll
* fail the whitelist tests and cause lots of false alarms ... fixable
* only by merging __exit and __init sections into __text, bloating
* the kernel (which is especially evil on embedded platforms).
*/
static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
{
const char *name = elf->strtab + sym->st_name;
if (!name || !strlen(name))
return 0;
return !is_arm_mapping_symbol(name);
}
/** /**
* Find symbol based on relocation record info. * Find symbol based on relocation record info.
* In some cases the symbol supplied is a valid symbol so * In some cases the symbol supplied is a valid symbol so
...@@ -1229,6 +1265,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, ...@@ -1229,6 +1265,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
continue; continue;
if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
continue; continue;
if (!is_valid_name(elf, sym))
continue;
if (sym->st_value == addr) if (sym->st_value == addr)
return sym; return sym;
/* Find a symbol nearby - addr are maybe negative */ /* Find a symbol nearby - addr are maybe negative */
...@@ -1247,30 +1285,6 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, ...@@ -1247,30 +1285,6 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
return NULL; return NULL;
} }
static inline int is_arm_mapping_symbol(const char *str)
{
return str[0] == '$' && strchr("axtd", str[1])
&& (str[2] == '\0' || str[2] == '.');
}
/*
* If there's no name there, ignore it; likewise, ignore it if it's
* one of the magic symbols emitted used by current ARM tools.
*
* Otherwise if find_symbols_between() returns those symbols, they'll
* fail the whitelist tests and cause lots of false alarms ... fixable
* only by merging __exit and __init sections into __text, bloating
* the kernel (which is especially evil on embedded platforms).
*/
static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
{
const char *name = elf->strtab + sym->st_name;
if (!name || !strlen(name))
return 0;
return !is_arm_mapping_symbol(name);
}
/* /*
* Find symbols before or equal addr and after addr - in the section sec. * Find symbols before or equal addr and after addr - in the section sec.
* If we find two symbols with equal offset prefer one with a valid name. * If we find two symbols with equal offset prefer one with a valid name.
...@@ -2083,15 +2097,27 @@ static void check_for_unused(enum export exp, const char *m, const char *s) ...@@ -2083,15 +2097,27 @@ static void check_for_unused(enum export exp, const char *m, const char *s)
} }
} }
static void check_exports(struct module *mod) static int check_exports(struct module *mod)
{ {
struct symbol *s, *exp; struct symbol *s, *exp;
int err = 0;
for (s = mod->unres; s; s = s->next) { for (s = mod->unres; s; s = s->next) {
const char *basename; const char *basename;
exp = find_symbol(s->name); exp = find_symbol(s->name);
if (!exp || exp->module == mod) if (!exp || exp->module == mod) {
if (have_vmlinux && !s->weak) {
if (warn_unresolved) {
warn("\"%s\" [%s.ko] undefined!\n",
s->name, mod->name);
} else {
merror("\"%s\" [%s.ko] undefined!\n",
s->name, mod->name);
err = 1;
}
}
continue; continue;
}
basename = strrchr(mod->name, '/'); basename = strrchr(mod->name, '/');
if (basename) if (basename)
basename++; basename++;
...@@ -2101,6 +2127,8 @@ static void check_exports(struct module *mod) ...@@ -2101,6 +2127,8 @@ static void check_exports(struct module *mod)
check_for_gpl_usage(exp->export, basename, exp->name); check_for_gpl_usage(exp->export, basename, exp->name);
check_for_unused(exp->export, basename, exp->name); check_for_unused(exp->export, basename, exp->name);
} }
return err;
} }
static int check_modname_len(struct module *mod) static int check_modname_len(struct module *mod)
...@@ -2178,19 +2206,8 @@ static int add_versions(struct buffer *b, struct module *mod) ...@@ -2178,19 +2206,8 @@ static int add_versions(struct buffer *b, struct module *mod)
for (s = mod->unres; s; s = s->next) { for (s = mod->unres; s; s = s->next) {
exp = find_symbol(s->name); exp = find_symbol(s->name);
if (!exp || exp->module == mod) { if (!exp || exp->module == mod)
if (have_vmlinux && !s->weak) {
if (warn_unresolved) {
warn("\"%s\" [%s.ko] undefined!\n",
s->name, mod->name);
} else {
merror("\"%s\" [%s.ko] undefined!\n",
s->name, mod->name);
err = 1;
}
}
continue; continue;
}
s->module = exp->module; s->module = exp->module;
s->crc_valid = exp->crc_valid; s->crc_valid = exp->crc_valid;
s->crc = exp->crc; s->crc = exp->crc;
...@@ -2227,15 +2244,15 @@ static int add_versions(struct buffer *b, struct module *mod) ...@@ -2227,15 +2244,15 @@ static int add_versions(struct buffer *b, struct module *mod)
return err; return err;
} }
static void add_depends(struct buffer *b, struct module *mod, static void add_depends(struct buffer *b, struct module *mod)
struct module *modules)
{ {
struct symbol *s; struct symbol *s;
struct module *m;
int first = 1; int first = 1;
for (m = modules; m; m = m->next) /* Clear ->seen flag of modules that own symbols needed by this. */
m->seen = is_vmlinux(m->name); for (s = mod->unres; s; s = s->next)
if (s->module)
s->module->seen = is_vmlinux(s->module->name);
buf_printf(b, "\n"); buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n"); buf_printf(b, "static const char __module_depends[]\n");
...@@ -2416,7 +2433,7 @@ int main(int argc, char **argv) ...@@ -2416,7 +2433,7 @@ int main(int argc, char **argv)
struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_iter;
struct ext_sym_list *extsym_start = NULL; struct ext_sym_list *extsym_start = NULL;
while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:E")) != -1) { while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awE")) != -1) {
switch (opt) { switch (opt) {
case 'i': case 'i':
kernel_read = optarg; kernel_read = optarg;
...@@ -2482,12 +2499,6 @@ int main(int argc, char **argv) ...@@ -2482,12 +2499,6 @@ int main(int argc, char **argv)
if (files_source) if (files_source)
read_symbols_from_files(files_source); read_symbols_from_files(files_source);
for (mod = modules; mod; mod = mod->next) {
if (mod->skip)
continue;
check_exports(mod);
}
err = 0; err = 0;
for (mod = modules; mod; mod = mod->next) { for (mod = modules; mod; mod = mod->next) {
...@@ -2499,12 +2510,13 @@ int main(int argc, char **argv) ...@@ -2499,12 +2510,13 @@ int main(int argc, char **argv)
buf.pos = 0; buf.pos = 0;
err |= check_modname_len(mod); err |= check_modname_len(mod);
err |= check_exports(mod);
add_header(&buf, mod); add_header(&buf, mod);
add_intree_flag(&buf, !external_module); add_intree_flag(&buf, !external_module);
add_retpoline(&buf); add_retpoline(&buf);
add_staging_flag(&buf, mod->name); add_staging_flag(&buf, mod->name);
err |= add_versions(&buf, mod); err |= add_versions(&buf, mod);
add_depends(&buf, mod, modules); add_depends(&buf, mod);
add_moddevtable(&buf, mod); add_moddevtable(&buf, mod);
add_srcversion(&buf, mod); add_srcversion(&buf, mod);
......
...@@ -33,7 +33,6 @@ MKSPEC := $(srctree)/scripts/package/mkspec ...@@ -33,7 +33,6 @@ MKSPEC := $(srctree)/scripts/package/mkspec
quiet_cmd_src_tar = TAR $(2).tar.gz quiet_cmd_src_tar = TAR $(2).tar.gz
cmd_src_tar = \ cmd_src_tar = \
set -e; \
if test "$(objtree)" != "$(srctree)"; then \ if test "$(objtree)" != "$(srctree)"; then \
echo >&2; \ echo >&2; \
echo >&2 " ERROR:"; \ echo >&2 " ERROR:"; \
......
...@@ -73,8 +73,16 @@ scm_version() ...@@ -73,8 +73,16 @@ scm_version()
printf -- '-svn%s' "`git svn find-rev $head`" printf -- '-svn%s' "`git svn find-rev $head`"
fi fi
# Check for uncommitted changes # Check for uncommitted changes.
if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then # First, with git-status, but --no-optional-locks is only
# supported in git >= 2.14, so fall back to git-diff-index if
# it fails. Note that git-diff-index does not refresh the
# index, so it may give misleading results. See
# git-update-index(1), git-diff-index(1), and git-status(1).
if {
git --no-optional-locks status -uno --porcelain 2>/dev/null ||
git diff-index --name-only HEAD
} | grep -qvE '^(.. )?scripts/package'; then
printf '%s' -dirty printf '%s' -dirty
fi fi
......
...@@ -49,10 +49,10 @@ $(deps_initramfs): ; ...@@ -49,10 +49,10 @@ $(deps_initramfs): ;
$(deps_initramfs): klibcdirs $(deps_initramfs): klibcdirs
# We rebuild initramfs_data.cpio if: # We rebuild initramfs_data.cpio if:
# 1) Any included file is newer then initramfs_data.cpio # 1) Any included file is newer than initramfs_data.cpio
# 2) There are changes in which files are included (added or deleted) # 2) There are changes in which files are included (added or deleted)
# 3) If gen_init_cpio are newer than initramfs_data.cpio # 3) If gen_init_cpio are newer than initramfs_data.cpio
# 4) arguments to gen_initramfs.sh changes # 4) Arguments to gen_initramfs.sh changes
$(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs $(obj)/$(datafile_y): $(obj)/gen_init_cpio $(deps_initramfs) klibcdirs
$(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y) $(Q)$(initramfs) -l $(ramfs-input) > $(obj)/$(datafile_d_y)
$(call if_changed,initfs) $(call if_changed,initfs)
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