From 125d059b624180b2c441181c797e41354bfe0649 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 11 Aug 2019 00:53:02 +0900 Subject: kbuild: do not descend to ./Kbuild when cleaning 'make clean' descends into ./Kbuild, but does not clean anything since everything is added to no-clean-files. There is no need to descend to ./Kbuild in the first place. We can drop the no-clean-files assignment. With this, there is no more user of no-clean-files. I will keep it for a while to see whether a new user will appear. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 6 ------ 1 file changed, 6 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index f4f0f7ffde2b..54e56a4368f3 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -787,12 +787,6 @@ This will delete the directory debian in the toplevel directory, including all subdirectories. To exclude certain files from make clean, use the $(no-clean-files) variable. -This is only a special case used in the top level Kbuild file: - - Example:: - - #Kbuild - no-clean-files := $(bounds-file) $(offsets-file) Usually kbuild descends down in subdirectories due to "obj-* := dir/", but in the architecture makefiles where the kbuild infrastructure -- cgit v1.2.3 From 888f0c346ff01d544d1cb9da6395a7b3def7fe87 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 15 Aug 2019 01:06:21 +0900 Subject: kbuild: move KBUILD_LDS, KBUILD_VMLINUX_{OBJS,LIBS} to makefiles.rst These three variables are not intended to be tweaked by users. Move them from kbuild.rst to makefiles.rst. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/kbuild.rst | 14 -------------- Documentation/kbuild/makefiles.rst | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index 61b2181ed3ea..62f9d86c082c 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -258,17 +258,3 @@ KBUILD_BUILD_USER, KBUILD_BUILD_HOST These two variables allow to override the user@host string displayed during boot and in /proc/version. The default value is the output of the commands whoami and host, respectively. - -KBUILD_LDS ----------- -The linker script with full path. Assigned by the top-level Makefile. - -KBUILD_VMLINUX_OBJS -------------------- -All object files for vmlinux. They are linked to vmlinux in the same -order as listed in KBUILD_VMLINUX_OBJS. - -KBUILD_VMLINUX_LIBS -------------------- -All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS -together specify all the object files used to link vmlinux. diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index 54e56a4368f3..88c384da592e 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -989,6 +989,20 @@ When kbuild executes, the following steps are followed (roughly): top-level Makefile has set any other flags. This provides a means for an architecture to override the defaults. + KBUILD_LDS + + The linker script with full path. Assigned by the top-level Makefile. + + KBUILD_VMLINUX_OBJS + + All object files for vmlinux. They are linked to vmlinux in the same + order as listed in KBUILD_VMLINUX_OBJS. + + KBUILD_VMLINUX_LIBS + + All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and + KBUILD_VMLINUX_LIBS together specify all the object files used to + link vmlinux. 6.2 Add prerequisites to archheaders ------------------------------------ -- cgit v1.2.3 From 10df063855822fcea3c0f51dbf534ad643d3cb1b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 15 Aug 2019 01:06:22 +0900 Subject: kbuild: rebuild modules when module linker scripts are updated Currently, the timestamp of module linker scripts are not checked. Add them to the dependency of modules so they are correctly rebuilt. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 5 +++++ Makefile | 3 ++- arch/arm/Makefile | 2 +- arch/arm64/Makefile | 2 +- arch/ia64/Makefile | 2 +- arch/m68k/Makefile | 2 +- arch/parisc/Makefile | 2 +- arch/powerpc/Makefile | 2 +- arch/riscv/Makefile | 2 +- scripts/Makefile.modpost | 5 +++-- 10 files changed, 17 insertions(+), 10 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index 88c384da592e..68ed20ef37dd 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -993,6 +993,11 @@ When kbuild executes, the following steps are followed (roughly): The linker script with full path. Assigned by the top-level Makefile. + KBUILD_LDS_MODULE + + The module linker script with full path. Assigned by the top-level + Makefile and additionally by the arch Makefile. + KBUILD_VMLINUX_OBJS All object files for vmlinux. They are linked to vmlinux in the same diff --git a/Makefile b/Makefile index 68e7ac654f4c..9c524950f4b3 100644 --- a/Makefile +++ b/Makefile @@ -482,7 +482,8 @@ KBUILD_AFLAGS_KERNEL := KBUILD_CFLAGS_KERNEL := KBUILD_AFLAGS_MODULE := -DMODULE KBUILD_CFLAGS_MODULE := -DMODULE -KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds +KBUILD_LDFLAGS_MODULE := +export KBUILD_LDS_MODULE := $(srctree)/scripts/module-common.lds KBUILD_LDFLAGS := GCC_PLUGINS_CFLAGS := CLANG_FLAGS := diff --git a/arch/arm/Makefile b/arch/arm/Makefile index c3624ca6c0bc..fbe50eec8f34 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -17,7 +17,7 @@ KBUILD_LDFLAGS_MODULE += --be8 endif ifeq ($(CONFIG_ARM_MODULE_PLTS),y) -KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm/kernel/module.lds +KBUILD_LDS_MODULE += $(srctree)/arch/arm/kernel/module.lds endif GZFLAGS :=-9 diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 61de992bbea3..d4ed1869e536 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -101,7 +101,7 @@ endif CHECKFLAGS += -D__aarch64__ ifeq ($(CONFIG_ARM64_MODULE_PLTS),y) -KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds +KBUILD_LDS_MODULE += $(srctree)/arch/arm64/kernel/module.lds endif # Default value diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index 171290f9f1de..5c3bcaee5980 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -20,7 +20,7 @@ CHECKFLAGS += -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__ OBJCOPYFLAGS := --strip-all LDFLAGS_vmlinux := -static -KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds +KBUILD_LDS_MODULE += $(srctree)/arch/ia64/module.lds KBUILD_AFLAGS_KERNEL := -mconstant-gp EXTRA := diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index 482513b9af2c..5d9288384096 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile @@ -73,7 +73,7 @@ KBUILD_AFLAGS += -D__uClinux__ endif KBUILD_LDFLAGS := -m m68kelf -KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds +KBUILD_LDS_MODULE += $(srctree)/arch/m68k/kernel/module.lds ifdef CONFIG_SUN3 LDFLAGS_vmlinux = -N diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile index 3b77d729057f..36b834f1c933 100644 --- a/arch/parisc/Makefile +++ b/arch/parisc/Makefile @@ -60,7 +60,7 @@ KBUILD_CFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY=1 \ -DFTRACE_PATCHABLE_FUNCTION_SIZE=$(NOP_COUNT) CC_FLAGS_FTRACE := -fpatchable-function-entry=$(NOP_COUNT),$(shell echo $$(($(NOP_COUNT)-1))) -KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/parisc/kernel/module.lds +KBUILD_LDS_MODULE += $(srctree)/arch/parisc/kernel/module.lds endif OBJCOPY_FLAGS =-O binary -R .note -R .comment -S diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index c345b79414a9..b2227855de20 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -67,7 +67,7 @@ UTS_MACHINE := $(subst $(space),,$(machine-y)) ifdef CONFIG_PPC32 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o else -KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds +KBUILD_LDS_MODULE += $(srctree)/arch/powerpc/kernel/module.lds ifeq ($(call ld-ifversion, -ge, 225000000, y),y) # Have the linker provide sfpr if possible. # There is a corresponding test in arch/powerpc/lib/Makefile diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile index 7a117be8297c..426d989125a8 100644 --- a/arch/riscv/Makefile +++ b/arch/riscv/Makefile @@ -52,7 +52,7 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y) KBUILD_CFLAGS += -mcmodel=medany endif ifeq ($(CONFIG_MODULE_SECTIONS),y) - KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/riscv/kernel/module.lds + KBUILD_LDS_MODULE += $(srctree)/arch/riscv/kernel/module.lds endif KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index bf15818f6947..905db30d6622 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -126,10 +126,11 @@ quiet_cmd_ld_ko_o = LD [M] $@ cmd_ld_ko_o = \ $(LD) -r $(KBUILD_LDFLAGS) \ $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ - -o $@ $(real-prereqs) ; \ + $(addprefix -T , $(KBUILD_LDS_MODULE)) \ + -o $@ $(filter %.o, $^); \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) -$(modules): %.ko :%.o %.mod.o FORCE +$(modules): %.ko :%.o %.mod.o $(KBUILD_LDS_MODULE) FORCE +$(call if_changed,ld_ko_o) targets += $(modules) -- cgit v1.2.3 From 4fef9dece5785f4ca522a13600de1014943d1fba Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 14 Aug 2019 19:53:59 +0900 Subject: docs: kbuild: fix invalid ReST syntax I see the following warnings when I open this document with a ReST viewer, retext: /home/masahiro/ref/linux/Documentation/kbuild/makefiles.rst:1142: (WARNING/2) Inline emphasis start-string without end-string. /home/masahiro/ref/linux/Documentation/kbuild/makefiles.rst:1152: (WARNING/2) Inline emphasis start-string without end-string. /home/masahiro/ref/linux/Documentation/kbuild/makefiles.rst:1154: (WARNING/2) Inline emphasis start-string without end-string. These hunks were added by commit e846f0dc57f4 ("kbuild: add support for ensuring headers are self-contained") and commit 1e21cbfada87 ("kbuild: support header-test-pattern-y"), respectively. They were written not for ReST but for the plain text, and merged via the kbuild tree. In the same development cycle, this document was converted to ReST by commit cd238effefa2 ("docs: kbuild: convert docs to ReST and rename to *.rst"), and merged via the doc sub-system. Merging them together into Linus' tree resulted in the current situation. To fix the syntax, surround the asterisks with back-quotes, and use :: for the code sample. Fixes: 39ceda5ce1b0 ("Merge tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild") Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index 68ed20ef37dd..492d88f37d8a 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -1152,7 +1152,7 @@ When kbuild executes, the following steps are followed (roughly): header-test-y - header-test-y specifies headers (*.h) in the current directory that + header-test-y specifies headers (`*.h`) in the current directory that should be compile tested to ensure they are self-contained, i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, this builds them as part of extra-y. @@ -1160,11 +1160,11 @@ When kbuild executes, the following steps are followed (roughly): header-test-pattern-y This works as a weaker version of header-test-y, and accepts wildcard - patterns. The typical usage is: + patterns. The typical usage is:: - header-test-pattern-y += *.h + header-test-pattern-y += *.h - This specifies all the files that matches to '*.h' in the current + This specifies all the files that matches to `*.h` in the current directory, but the files in 'header-test-' are excluded. 6.7 Commands useful for building a boot image -- cgit v1.2.3 From d20558d1de4e2d5bec236a8f0e99d5f1efdd39b8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 14 Aug 2019 19:54:00 +0900 Subject: docs: kbuild: remove cc-ldoption from document again Commit 055efab3120b ("kbuild: drop support for cc-ldoption") correctly removed the cc-ldoption from Documentation/kbuild/makefiles.txt, but commit cd238effefa2 ("docs: kbuild: convert docs to ReST and rename to *.rst") revived it. I guess it was a rebase mistake. Remove it again. Fixes: cd238effefa2 ("docs: kbuild: convert docs to ReST and rename to *.rst") Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index 492d88f37d8a..9fb2de94c3e2 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -471,21 +471,6 @@ more details, with real examples. The second argument is optional, and if supplied will be used if first argument is not supported. - cc-ldoption - cc-ldoption is used to check if $(CC) when used to link object files - supports the given option. An optional second option may be - specified if first option are not supported. - - Example:: - - #arch/x86/kernel/Makefile - vsyscall-flags += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv) - - In the above example, vsyscall-flags will be assigned the option - -Wl$(comma)--hash-style=sysv if it is supported by $(CC). - The second argument is optional, and if supplied will be used - if first argument is not supported. - as-instr as-instr checks if the assembler reports a specific instruction and then outputs either option1 or option2 -- cgit v1.2.3 From 1634f2bfdb846ed0a8b73131a9dff7c420fb3fe1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Aug 2019 10:31:27 +0900 Subject: kbuild: remove clean-dirs syntax The only the difference between clean-files and clean-dirs is the -r option passed to the 'rm' command. You can always pass -r, and then remove the clean-dirs syntax. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 16 ++++------------ scripts/Makefile.clean | 16 ++-------------- scripts/kconfig/Makefile | 2 +- usr/include/Makefile | 4 +--- 4 files changed, 8 insertions(+), 30 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index 9fb2de94c3e2..e9ffdffa3641 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -750,7 +750,8 @@ Files matching the patterns "*.[oas]", "*.ko", plus some additional files generated by kbuild are deleted all over the kernel src tree when "make clean" is executed. -Additional files can be specified in kbuild makefiles by use of $(clean-files). +Additional files or directories can be specified in kbuild makefiles by use of +$(clean-files). Example:: @@ -761,17 +762,8 @@ When executing "make clean", the file "crc32table.h" will be deleted. Kbuild will assume files to be in the same relative directory as the Makefile, except if prefixed with $(objtree). -To delete a directory hierarchy use: - - Example:: - - #scripts/package/Makefile - clean-dirs := $(objtree)/debian/ - -This will delete the directory debian in the toplevel directory, including all -subdirectories. - -To exclude certain files from make clean, use the $(no-clean-files) variable. +To exclude certain files or directories from make clean, use the +$(no-clean-files) variable. Usually kbuild descends down in subdirectories due to "obj-* := dir/", but in the architecture makefiles where the kbuild infrastructure diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 0b80e3207b20..cbfbe13dc87d 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -52,26 +52,14 @@ __clean-files := $(wildcard \ $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \ $(filter $(objtree)/%, $(__clean-files))) -# same as clean-files - -__clean-dirs := $(wildcard \ - $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \ - $(filter $(objtree)/%, $(clean-dirs))) - # ========================================================================== -quiet_cmd_clean = CLEAN $(obj) - cmd_clean = rm -f $(__clean-files) -quiet_cmd_cleandir = CLEAN $(__clean-dirs) - cmd_cleandir = rm -rf $(__clean-dirs) - +quiet_cmd_clean = CLEAN $(obj) + cmd_clean = rm -rf $(__clean-files) __clean: $(subdir-ymn) ifneq ($(strip $(__clean-files)),) +$(call cmd,clean) -endif -ifneq ($(strip $(__clean-dirs)),) - +$(call cmd,cleandir) endif @: diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 7656e1137b6b..bed7a5a2fbe9 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -114,7 +114,7 @@ testconfig: $(obj)/conf $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ -o cache_dir=$(abspath $(obj)/tests/.cache) \ $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) -clean-dirs += tests/.cache +clean-files += tests/.cache # Help text used by make help help: diff --git a/usr/include/Makefile b/usr/include/Makefile index 1fb6abe29b2f..05c71ef42f51 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -115,6 +115,4 @@ header-test-y += $(filter-out $(header-test-), \ $(patsubst $(obj)/%,%, $(wildcard \ $(addprefix $(obj)/, *.h */*.h */*/*.h */*/*/*.h)))) -# For GNU Make <= 4.2.1, $(wildcard $(obj)/*/) matches to not only directories -# but also regular files. Use $(filter %/, ...) just in case. -clean-dirs += $(patsubst $(obj)/%/,%,$(filter %/, $(wildcard $(obj)/*/))) +clean-files += $(filter-out Makefile, $(notdir $(wildcard $(obj)/*))) -- cgit v1.2.3 From 8cc7af751443f7c82d12c7e5061fd2fa2e08a3d4 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 21 Aug 2019 02:09:41 +0900 Subject: kbuild: remove ARCH_{CPP,A,C}FLAGS These flags were added by commit 61754c18752f ("kbuild: Allow arch Makefiles to override {cpp,ld,c}flags") to allow ARC to override -O2. We did not see any other usage after all. Now that ARC switched to CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3, there is no more user of these variables. Signed-off-by: Masahiro Yamada --- Documentation/kbuild/makefiles.rst | 7 ------- Makefile | 14 ++++---------- 2 files changed, 4 insertions(+), 17 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst index e9ffdffa3641..6ba9d5365ff3 100644 --- a/Documentation/kbuild/makefiles.rst +++ b/Documentation/kbuild/makefiles.rst @@ -959,13 +959,6 @@ When kbuild executes, the following steps are followed (roughly): $(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic mode) if this option is supported by $(AR). - ARCH_CPPFLAGS, ARCH_AFLAGS, ARCH_CFLAGS Overrides the kbuild defaults - - These variables are appended to the KBUILD_CPPFLAGS, - KBUILD_AFLAGS, and KBUILD_CFLAGS, respectively, after the - top-level Makefile has set any other flags. This provides a - means for an architecture to override the defaults. - KBUILD_LDS The linker script with full path. Assigned by the top-level Makefile. diff --git a/Makefile b/Makefile index c27bc98ad28b..db5706ceecad 100644 --- a/Makefile +++ b/Makefile @@ -668,11 +668,6 @@ RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc export RETPOLINE_CFLAGS export RETPOLINE_VDSO_CFLAGS -# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default -# values of the respective KBUILD_* variables -ARCH_CPPFLAGS := -ARCH_AFLAGS := -ARCH_CFLAGS := include arch/$(SRCARCH)/Makefile ifdef need-config @@ -927,11 +922,10 @@ include scripts/Makefile.kasan include scripts/Makefile.extrawarn include scripts/Makefile.ubsan -# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the -# last assignments -KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) -KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) -KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS) +# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments +KBUILD_CPPFLAGS += $(KCPPFLAGS) +KBUILD_AFLAGS += $(KAFLAGS) +KBUILD_CFLAGS += $(KCFLAGS) KBUILD_LDFLAGS_MODULE += --build-id LDFLAGS_vmlinux += --build-id -- cgit v1.2.3 From e27128db62834c5b906585c2d97f0ddd431fa28f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 1 Sep 2019 01:25:55 +0900 Subject: kbuild: rename KBUILD_ENABLE_EXTRA_GCC_CHECKS to KBUILD_EXTRA_WARN KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning options for GCC, but now it is a historical misnomer since we use it also for Clang, DTC, and even kernel-doc. Rename it to more sensible, shorter KBUILD_EXTRA_WARN. For the backward compatibility, KBUILD_ENABLE_EXTRA_GCC_CHECKS is still supported (but not advertised in the documentation). I also fixed up 'make help', and updated the documentation. Signed-off-by: Masahiro Yamada Reviewed-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Reviewed-by: Sedat Dilek --- Documentation/kbuild/kbuild.rst | 14 +++++++++----- Makefile | 2 +- scripts/Makefile.build | 2 +- scripts/Makefile.extrawarn | 13 +++++++++---- scripts/Makefile.lib | 4 ++-- scripts/genksyms/Makefile | 2 +- 6 files changed, 23 insertions(+), 14 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/kbuild.rst b/Documentation/kbuild/kbuild.rst index 62f9d86c082c..f1e5dce86af7 100644 --- a/Documentation/kbuild/kbuild.rst +++ b/Documentation/kbuild/kbuild.rst @@ -105,6 +105,15 @@ The output directory can also be specified using "O=...". Setting "O=..." takes precedence over KBUILD_OUTPUT. +KBUILD_EXTRA_WARN +----------------- +Specify the extra build checks. The same value can be assigned by passing +W=... from the command line. + +See `make help` for the list of the supported values. + +Setting "W=..." takes precedence over KBUILD_EXTRA_WARN. + KBUILD_DEBARCH -------------- For the deb-pkg target, allows overriding the normal heuristics deployed by @@ -241,11 +250,6 @@ To get all available archs you can also specify all. E.g.:: $ make ALLSOURCE_ARCHS=all tags -KBUILD_ENABLE_EXTRA_GCC_CHECKS ------------------------------- -If enabled over the make command line with "W=1", it turns on additional -gcc -W... options for more extensive build-time checking. - KBUILD_BUILD_TIMESTAMP ---------------------- Setting this to a date string overrides the timestamp used in the diff --git a/Makefile b/Makefile index 06e1e21c0f45..adc0cabe2382 100644 --- a/Makefile +++ b/Makefile @@ -1538,7 +1538,7 @@ help: @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)' @echo ' make C=2 [targets] Force check of all c source with $$CHECK' @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' - @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' + @echo ' make W=n [targets] Enable extra build checks, n=1,2,3 where' @echo ' 1: warnings which may be relevant and do not occur too often' @echo ' 2: warnings which occur quite often but may still be relevant' @echo ' 3: more obscure warnings, can most likely be ignored' diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2a21ca86b720..f72aba64d611 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -85,7 +85,7 @@ else ifeq ($(KBUILD_CHECKSRC),2) cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< endif -ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) +ifneq ($(KBUILD_EXTRA_WARN),) cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< endif diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index d226c5fb13e2..53eb7e0c6a5a 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -8,14 +8,19 @@ KBUILD_CFLAGS += $(call cc-disable-warning, packed-not-aligned) +# backward compatibility +KBUILD_EXTRA_WARN ?= $(KBUILD_ENABLE_EXTRA_GCC_CHECKS) + ifeq ("$(origin W)", "command line") - export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W) + KBUILD_EXTRA_WARN := $(W) endif +export KBUILD_EXTRA_WARN + # # W=1 - warnings which may be relevant and do not occur too often # -ifneq ($(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +ifneq ($(findstring 1, $(KBUILD_EXTRA_WARN)),) KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter KBUILD_CFLAGS += -Wmissing-declarations @@ -48,7 +53,7 @@ endif # # W=2 - warnings which occur quite often but may still be relevant # -ifneq ($(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +ifneq ($(findstring 2, $(KBUILD_EXTRA_WARN)),) KBUILD_CFLAGS += -Wcast-align KBUILD_CFLAGS += -Wdisabled-optimization @@ -65,7 +70,7 @@ endif # # W=3 - more obscure warnings, can most likely be ignored # -ifneq ($(findstring 3, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +ifneq ($(findstring 3, $(KBUILD_EXTRA_WARN)),) KBUILD_CFLAGS += -Wbad-function-cast KBUILD_CFLAGS += -Wcast-qual diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 380a7d11a573..4a0cdd6f5909 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -251,7 +251,7 @@ quiet_cmd_gzip = GZIP $@ DTC ?= $(objtree)/scripts/dtc/dtc # Disable noisy checks by default -ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) DTC_FLAGS += -Wno-unit_address_vs_reg \ -Wno-unit_address_format \ -Wno-avoid_unnecessary_addr_size \ @@ -262,7 +262,7 @@ DTC_FLAGS += -Wno-unit_address_vs_reg \ -Wno-pci_device_reg endif -ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) DTC_FLAGS += -Wnode_name_chars_strict \ -Wproperty_name_chars_strict endif diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile index baf44ed0a93a..78629f515e78 100644 --- a/scripts/genksyms/Makefile +++ b/scripts/genksyms/Makefile @@ -12,7 +12,7 @@ genksyms-objs := genksyms.o parse.tab.o lex.lex.o # # Just in case, run "$(YACC) --version" without suppressing stderr # so that 'bison: not found' will be displayed if it is missing. -ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) quiet_cmd_bison_no_warn = $(quiet_cmd_bison) cmd_bison_no_warn = $(YACC) --version >/dev/null; \ -- cgit v1.2.3