From 25815cf5ffecfb8b54314ee1b7cf14c78681fbb6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 15:43:29 +0900 Subject: kbuild: hide most of targets when running config or mixed targets When mixed/config targets are being processed, the top Makefile does not need to parse the rest of targets. Signed-off-by: Masahiro Yamada --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4d5c883a98e5..4b76e225fdae 100644 --- a/Makefile +++ b/Makefile @@ -1615,9 +1615,6 @@ namespacecheck: export_report: $(PERL) $(srctree)/scripts/export_report.pl -endif #ifeq ($(config-targets),1) -endif #ifeq ($(mixed-targets),1) - PHONY += checkstack kernelrelease kernelversion image_name # UML needs a little special treatment here. It wants to use the host @@ -1732,6 +1729,8 @@ ifneq ($(cmd_files),) include $(cmd_files) endif +endif # ifeq ($(config-targets),1) +endif # ifeq ($(mixed-targets),1) endif # skip-makefile PHONY += FORCE -- cgit v1.2.3 From 00d78ab2ba756af7b9a4dacd437b7a882bd18a4b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 15:43:30 +0900 Subject: kbuild: remove dead code in cmd_files calculation in top Makefile Nobody sets 'targets' in the top-level Makefile or arch/*/Makefile, hence $(targets) is empty. $(wildcard .*.cmd) will do for including the .vmlinux.cmd file. Signed-off-by: Masahiro Yamada --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4b76e225fdae..8f6dbfce1e7e 100644 --- a/Makefile +++ b/Makefile @@ -1721,8 +1721,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) # read all saved command lines - -cmd_files := $(wildcard .*.cmd $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) +cmd_files := $(wildcard .*.cmd) ifneq ($(cmd_files),) $(cmd_files): ; # Do not try to update included dependency files -- cgit v1.2.3 From 80463f1b7bf9f822fd3495139bcf3ef254fdca10 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 14 Sep 2018 15:33:23 +0900 Subject: kbuild: add --include-dir flag only for out-of-tree build The --include-dir flag is used to include check-in Makefiles from $(objtree) without $(srctree)/ prefix. Obviously, this is unneeded for in-tree build. Add the flag just before changing the working directory. This becomes effective after invoking sub-make. Add a little bit comments about it. Signed-off-by: Masahiro Yamada --- Makefile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8f6dbfce1e7e..2087e797c954 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,9 @@ NAME = Merciless Moray PHONY := _all _all: -# o Do not use make's built-in rules and variables -# (this increases performance and avoids hard-to-debug behaviour); -# o Look for make include files relative to root of kernel src -MAKEFLAGS += -rR --include-dir=$(CURDIR) +# Do not use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour) +MAKEFLAGS += -rR # Avoid funny character set dependencies unexport LC_ALL @@ -136,6 +135,13 @@ KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ $(if $(KBUILD_OUTPUT),, \ $(error failed to create output directory "$(saved-output)")) +# Look for make include files relative to root of kernel src +# +# This does not become effective immediately because MAKEFLAGS is re-parsed +# once after the Makefile is read. It is OK since we are going to invoke +# 'sub-make' below. +MAKEFLAGS += --include-dir=$(CURDIR) + PHONY += $(MAKECMDGOALS) sub-make $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make -- cgit v1.2.3 From 77ec0c20c7e012b5ebb22197c8a329611458cdf8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:51 +0900 Subject: kbuild: remove VERSION and PATCHLEVEL from $(objtree)/Makefile Neither VERSION nor PATCHLEVEL is used in any useful way. Signed-off-by: Masahiro Yamada --- Makefile | 3 +-- scripts/mkmakefile | 6 ------ 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2087e797c954..182172c72441 100644 --- a/Makefile +++ b/Makefile @@ -494,8 +494,7 @@ PHONY += outputmakefile outputmakefile: ifneq ($(KBUILD_SRC),) $(Q)ln -fsn $(srctree) source - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ - $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) $(objtree) endif ifeq ($(cc-name),clang) diff --git a/scripts/mkmakefile b/scripts/mkmakefile index e19d6565f245..e21064445085 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -7,9 +7,6 @@ # Usage # $1 - Kernel src directory # $2 - Output directory -# $3 - version -# $4 - patchlevel - test ! -r $2/Makefile -o -O $2/Makefile || exit 0 # Only overwrite automatically generated Makefiles @@ -25,9 +22,6 @@ fi cat << EOF > $2/Makefile # Automatically generated by $0: don't edit -VERSION = $3 -PATCHLEVEL = $4 - lastword = \$(word \$(words \$(1)),\$(1)) makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) -- cgit v1.2.3 From 4fd61277f66278d7ce4a77accb662d00e800cce7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:53 +0900 Subject: kbuild: do not pass $(objtree) to scripts/mkmakefile Since $(objtree) is always '.', it is not useful to pass it to scripts/mkmakefile. I assume nobody wants to run this script directly. Signed-off-by: Masahiro Yamada --- Makefile | 2 +- scripts/mkmakefile | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 182172c72441..d2de86c2eba3 100644 --- a/Makefile +++ b/Makefile @@ -494,7 +494,7 @@ PHONY += outputmakefile outputmakefile: ifneq ($(KBUILD_SRC),) $(Q)ln -fsn $(srctree) source - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) $(objtree) + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) endif ifeq ($(cc-name),clang) diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 24354284d4ad..85995f90e5c8 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -6,19 +6,18 @@ # Usage # $1 - Kernel src directory -# $2 - Output directory # Only overwrite automatically generated Makefiles # (so we do not overwrite kernel Makefile) -if test -e $2/Makefile && ! grep -q Automatically $2/Makefile +if test -e Makefile && ! grep -q Automatically Makefile then exit 0 fi if [ "${quiet}" != "silent_" ]; then - echo " GEN $2/Makefile" + echo " GEN Makefile" fi -cat << EOF > $2/Makefile +cat << EOF > Makefile # Automatically generated by $0: don't edit lastword = \$(word \$(words \$(1)),\$(1)) -- cgit v1.2.3 From fb073a4b473e5b854312dc819c66ded9d103e824 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Oct 2018 18:44:36 +0900 Subject: kbuild: add -Wno-pointer-sign flag unconditionally We have raised the compiler requirement from time to time. With commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6"), the minimum for GCC is 4.6 now. The -Wno-pointer-sign has been here since the pre-git era. It is documented in the GCC 4.6 manual, and it is recognized by Clang and ICC as well. Let's rip off the cc-disable-warning switch, and see if somebody complains about it. Signed-off-by: Masahiro Yamada Tested-by: Nick Desaulniers --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d2de86c2eba3..9e41e4563a99 100644 --- a/Makefile +++ b/Makefile @@ -810,7 +810,7 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) # disable pointer signed / unsigned warnings in gcc 4.0 -KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) +KBUILD_CFLAGS += -Wno-pointer-sign # disable stringop warnings in gcc 8+ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) -- cgit v1.2.3 From a33e7ae295d5bc20568c48ac217d07f011091c32 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Oct 2018 18:44:37 +0900 Subject: kbuild: add -Wdeclaration-after-statement flag unconditionally We have raised the compiler requirement from time to time. With commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6"), the minimum for GCC is 4.6 now. This flag has been here since the pre-git era. It is documented in the GCC 4.6 manual, and it is recognized by Clang and ICC as well. Let's rip off the cc-option switch, and see if somebody complains about it. Signed-off-by: Masahiro Yamada Tested-by: Nick Desaulniers --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 9e41e4563a99..d4343739490f 100644 --- a/Makefile +++ b/Makefile @@ -807,7 +807,7 @@ endif NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) # warn about C99 declaration after statement -KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) +KBUILD_CFLAGS += -Wdeclaration-after-statement # disable pointer signed / unsigned warnings in gcc 4.0 KBUILD_CFLAGS += -Wno-pointer-sign -- cgit v1.2.3 From 9df3e7a7d7d6d92df7c58fb17f900fdc2d8b5031 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 2 Oct 2018 10:32:23 +0900 Subject: kbuild: add -Wno-unused-but-set-variable flag unconditionally We have raised the compiler requirement from time to time. With commit cafa0010cd51 ("Raise the minimum required gcc version to 4.6"), the minimum for GCC is 4.6 now. This flag was added by GCC 4.6, and it is recognized by ICC as well. It is true that Clang does not support this flag but this commit is just touching the else part of the "ifeq ($(cc-name),clang)" check. Hence, Clang build is not affected. Let's rip off the cc-disable-warning switch, and see if somebody complains about it. Signed-off-by: Masahiro Yamada Reviewed-by: Nick Desaulniers --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d4343739490f..6523ab53f178 100644 --- a/Makefile +++ b/Makefile @@ -723,7 +723,7 @@ else # 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 += -Wno-unused-but-set-variable endif KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) -- cgit v1.2.3