From 1476fee5c53e24e06cfc436110cdefbc1868e8c1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 25 Apr 2021 16:07:12 +0900 Subject: kbuild: add a script to remove stale generated files We maintain .gitignore and Makefiles so build artifacts are properly ignored by Git, and cleaned up by 'make clean'. However, the code is always changing; generated files are often moved to another directory, or removed when they become unnecessary. Such garbage files tend to be left over in the source tree because people usually git-pull without cleaning the tree. This is not only the noise for 'git status', but also a build issue in some cases. One solution is to remove a stale file like commit 223c24a7dba9 ("kbuild: Automatically remove stale file") did. Such workaround should be removed after a while, but we forget about that if we scatter the workaround code in random places. So, this commit adds a new script to collect cleanings of stale files. As a start point, move the code in arch/arm/boot/compressed/Makefile into this script. Signed-off-by: Masahiro Yamada --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6eafedd7efc6..9f5a3cac63e7 100644 --- a/Makefile +++ b/Makefile @@ -1225,7 +1225,7 @@ PHONY += prepare archprepare archprepare: outputmakefile archheaders archscripts scripts include/config/kernel.release \ asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ - include/generated/autoconf.h + include/generated/autoconf.h remove-stale-files prepare0: archprepare $(Q)$(MAKE) $(build)=scripts/mod @@ -1234,6 +1234,10 @@ prepare0: archprepare # All the preparing.. prepare: prepare0 prepare-objtool prepare-resolve_btfids +PHONY += remove-stale-files +remove-stale-files: + $(Q)$(srctree)/scripts/remove-stale-files + # Support for using generic headers in asm-generic asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj -- cgit v1.2.3 From 885480b084696331bea61a4f7eba10652999a9c1 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 28 Apr 2021 18:23:50 -0700 Subject: Makefile: Move -Wno-unused-but-set-variable out of GCC only block Currently, -Wunused-but-set-variable is only supported by GCC so it is disabled unconditionally in a GCC only block (it is enabled with W=1). clang currently has its implementation for this warning in review so preemptively move this statement out of the GCC only block and wrap it with cc-disable-warning so that both compilers function the same. Cc: stable@vger.kernel.org Link: https://reviews.llvm.org/D100581 Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers Signed-off-by: Masahiro Yamada --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9f5a3cac63e7..3597fd75d5b5 100644 --- a/Makefile +++ b/Makefile @@ -792,16 +792,16 @@ KBUILD_CFLAGS += -Wno-gnu KBUILD_CFLAGS += -mno-global-merge else -# These warnings generated too much noise in a regular build. -# Use make W=1 to enable them (see scripts/Makefile.extrawarn) -KBUILD_CFLAGS += -Wno-unused-but-set-variable - # Warn about unmarked fall-throughs in switch statement. # Disabled for clang while comment to attribute conversion happens and # https://github.com/ClangBuiltLinux/linux/issues/636 is discussed. KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,) endif +# These warnings generated too much noise in a regular build. +# Use make W=1 to enable them (see scripts/Makefile.extrawarn) +KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) + KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -- cgit v1.2.3 From 45799491a92174ff78d9c46de55d614814bdd3e1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 2 May 2021 02:24:35 +0900 Subject: kbuild: remove ARCH=sh64 support from top Makefile Commit 37744feebc08 ("sh: remove sh5 support") removed the SUPERH64 support entirely. Remove the left-over code from the top Makefile. Signed-off-by: Masahiro Yamada Acked-by: Arnd Bergmann --- Makefile | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3597fd75d5b5..cbf4b18cf51c 100644 --- a/Makefile +++ b/Makefile @@ -399,11 +399,6 @@ ifeq ($(ARCH),sparc64) SRCARCH := sparc endif -# Additional ARCH settings for sh -ifeq ($(ARCH),sh64) - SRCARCH := sh -endif - export cross_compiling := ifneq ($(SRCARCH),$(SUBARCH)) cross_compiling := 1 -- cgit v1.2.3 From 19c8d912837e45e99b2991228adfc4419ffff248 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 May 2021 19:10:56 +0900 Subject: kbuild: make distclean work against $(objtree) instead of $(srctree) This reverts the old commit [1], which seems questionable to me. It claimed 'make distclean' could not remove editor backup files, but I believe KBUILD_OUTPUT or O= was set. When O= is given, Kbuild should always work against $(objtree). If O= is not given, $(objtree) and $(srctree) are the same, therefore $(srctree) is cleaned up. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/history/history.git/commit/?id=dd47df980c02eb33833b2690b033c34fba2fa80d Signed-off-by: Masahiro Yamada --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index cbf4b18cf51c..560408808c33 100644 --- a/Makefile +++ b/Makefile @@ -1546,7 +1546,7 @@ PHONY += distclean distclean: mrproper $(call cmd,rmfiles) - @find $(srctree) $(RCS_FIND_IGNORE) \ + @find . $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '*%' \ -o -name 'core' \) \ -- cgit v1.2.3 From 7a02cec523a90fec78634c655e2470f72d2fdcbf Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 May 2021 19:10:57 +0900 Subject: kbuild: make distclean remove tag files in sub-directories 'make tags' and friends create tag files in the top directory, but people may manually create tag files in sub-directories. Signed-off-by: Masahiro Yamada --- Makefile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 560408808c33..2cbf68dc40b7 100644 --- a/Makefile +++ b/Makefile @@ -1511,9 +1511,6 @@ MRPROPER_FILES += include/config include/generated \ signing_key.x509.signer vmlinux-gdb.py \ *.spec -# Directories & files removed with 'make distclean' -DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS - # clean - Delete most, but leave enough to build external modules # clean: rm-files := $(CLEAN_FILES) @@ -1540,16 +1537,14 @@ mrproper: clean $(mrproper-dirs) # distclean # -distclean: rm-files := $(wildcard $(DISTCLEAN_FILES)) - PHONY += distclean distclean: mrproper - $(call cmd,rmfiles) @find . $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '*%' \ - -o -name 'core' \) \ + -o -name 'core' -o -name tags -o -name TAGS -o -name 'cscope*' \ + -o -name GPATH -o -name GRTAGS -o -name GSYMS -o -name GTAGS \) \ -type f -print | xargs rm -f -- cgit v1.2.3 From 11122b860bc52a09c779c3de9415436794fb5605 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 May 2021 19:10:58 +0900 Subject: kbuild: remove the unneeded comments for external module builds The supported targets for external modules are listed in the help target a few lines below. Let's not have duplicated information in two places. Signed-off-by: Masahiro Yamada --- Makefile | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2cbf68dc40b7..9b9a003bd88f 100644 --- a/Makefile +++ b/Makefile @@ -1711,17 +1711,7 @@ else # KBUILD_EXTMOD # When building external modules the kernel used as basis is considered # read-only, and no consistency checks are made and the make # system is not used on the basis kernel. If updates are required -# in the basis kernel ordinary make commands (without M=...) must -# be used. -# -# The following are the only valid targets when building external -# modules. -# make M=dir clean Delete all automatically generated files -# make M=dir modules Make all modules in specified dir -# make M=dir Same as 'make M=dir modules' -# make M=dir modules_install -# Install the modules built in the module directory -# Assumes install directory is already created +# in the basis kernel ordinary make commands (without M=...) must be used. # We are always building only modules. KBUILD_BUILTIN := -- cgit v1.2.3