From 80ffbaa5b1bd98e80e3239a3b8cfda2da433009a Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 3 Sep 2018 06:09:34 -0600 Subject: [PATCH 01/19] kallsyms: reduce size a little on 64-bit Both kallsyms_num_syms and kallsyms_markers[] don't really need to use unsigned long as their (base) types; unsigned int fully suffices. Signed-off-by: Jan Beulich Signed-off-by: Masahiro Yamada --- kernel/kallsyms.c | 4 ++-- scripts/kallsyms.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 02a0b01380d8..f3a04994e063 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -37,7 +37,7 @@ extern const u8 kallsyms_names[] __weak; * Tell the compiler that the count isn't in the small data section if the arch * has one (eg: FRV). */ -extern const unsigned long kallsyms_num_syms +extern const unsigned int kallsyms_num_syms __attribute__((weak, section(".rodata"))); extern const unsigned long kallsyms_relative_base @@ -46,7 +46,7 @@ __attribute__((weak, section(".rodata"))); extern const u8 kallsyms_token_table[] __weak; extern const u16 kallsyms_token_index[] __weak; -extern const unsigned long kallsyms_markers[] __weak; +extern const unsigned int kallsyms_markers[] __weak; /* * Expand a compressed symbol data into the resulting uncompressed string, diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index a9186a98a37d..085b6a584fe0 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -405,7 +405,7 @@ static void write_src(void) } output_label("kallsyms_num_syms"); - printf("\tPTR\t%u\n", table_cnt); + printf("\t.long\t%u\n", table_cnt); printf("\n"); /* table of offset markers, that give the offset in the compressed stream @@ -434,7 +434,7 @@ static void write_src(void) output_label("kallsyms_markers"); for (i = 0; i < ((table_cnt + 255) >> 8); i++) - printf("\tPTR\t%d\n", markers[i]); + printf("\t.long\t%u\n", markers[i]); printf("\n"); free(markers); From 36f546a1bdb5d268aec97b2fe4800c91a4f5596a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Sep 2018 09:42:24 +0900 Subject: [PATCH 02/19] kallsyms: remove left-over Blackfin code These symbols were added by commit 028f042613c3 ("kallsyms: support kernel symbols in Blackfin on-chip memory") for Blackfin. The Blackfin support was removed by commit 4ba66a976072 ("arch: remove blackfin port"). Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 085b6a584fe0..109a1af7e444 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -48,8 +48,6 @@ static unsigned long long relative_base; static struct addr_range text_ranges[] = { { "_stext", "_etext" }, { "_sinittext", "_einittext" }, - { "_stext_l1", "_etext_l1" }, /* Blackfin on-chip L1 inst SRAM */ - { "_stext_l2", "_etext_l2" }, /* Blackfin on-chip L2 SRAM */ }; #define text_range_text (&text_ranges[0]) #define text_range_inittext (&text_ranges[1]) From 487c7c7702ab12cfe6cd0b5a10364eefa1d2128f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 13:52:54 +0900 Subject: [PATCH 03/19] kbuild: prefix Makefile.dtbinst path with $(srctree) unconditionally $(srctree) always points to the top of the source tree whether KBUILD_SRC is set or not. Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index ce53639a864a..46cc43e38866 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -193,7 +193,7 @@ modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= # Usage: # $(Q)$(MAKE) $(dtbinst)=dir -dtbinst := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.dtbinst obj +dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj ### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= From 0d91bf584fe55349193afa96a2f36d288f65b218 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 15:18:02 +0900 Subject: [PATCH 04/19] kbuild: remove old check for CFLAGS use This check has been here for more than a decade since commit 0c53c8e6eb45 ("kbuild: check for wrong use of CFLAGS"). Enough time for migration has passed. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 5a2d1c9578a0..cb0377427f94 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -36,21 +36,11 @@ subdir-ccflags-y := include scripts/Kbuild.include -# For backward compatibility check that these variables do not change -save-cflags := $(CFLAGS) - # The filename Kbuild has precedence over Makefile kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) include $(kbuild-file) -# If the save-* variables changed error out -ifeq ($(KBUILD_NOPEDANTIC),) - ifneq ("$(save-cflags)","$(CFLAGS)") - $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y) - endif -endif - include scripts/Makefile.lib # Do not include host rules unless needed From 25815cf5ffecfb8b54314ee1b7cf14c78681fbb6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 15:43:29 +0900 Subject: [PATCH 05/19] 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(-) 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 From 00d78ab2ba756af7b9a4dacd437b7a882bd18a4b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 12 Sep 2018 15:43:30 +0900 Subject: [PATCH 06/19] 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(-) 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 From 80463f1b7bf9f822fd3495139bcf3ef254fdca10 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 14 Sep 2018 15:33:23 +0900 Subject: [PATCH 07/19] 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(-) 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 From 77ec0c20c7e012b5ebb22197c8a329611458cdf8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:51 +0900 Subject: [PATCH 08/19] 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(-) 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))) From 74bc0c09b2da005f028510b1ad21140c9d6c9b44 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:52 +0900 Subject: [PATCH 09/19] kbuild: remove user ID check in scripts/mkmakefile This line was added by commit fd5f0cd6b0ce ("kbuild: Do not overwrite makefile as anohter user"). Its commit description says the intention was to prevent $(objtree)/Makefile from being owned by root when e.g. running 'make install'. However, as commit 19514fc665ff ("arm, kbuild: make "make install" not depend on vmlinux") stated, installation targets must not modify the source tree in the first place. If they do, we are already screwed up. We must fix the root cause. Installation targets should just copy files verbatim, hence we never expect $(objtree)/Makefile is touched by root. The user ID check in scripts/mkmakefile is unneeded. Signed-off-by: Masahiro Yamada --- scripts/mkmakefile | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/mkmakefile b/scripts/mkmakefile index e21064445085..24354284d4ad 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -8,7 +8,6 @@ # $1 - Kernel src directory # $2 - Output directory -test ! -r $2/Makefile -o -O $2/Makefile || exit 0 # Only overwrite automatically generated Makefiles # (so we do not overwrite kernel Makefile) if test -e $2/Makefile && ! grep -q Automatically $2/Makefile From 4fd61277f66278d7ce4a77accb662d00e800cce7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:53 +0900 Subject: [PATCH 10/19] 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(-) 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)) From 80d0dda3a4e5ba00ae6a45fa840096dc9633aad7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Sep 2018 17:45:54 +0900 Subject: [PATCH 11/19] kbuild: simplify command line creation in scripts/mkmakefile Assuming we never invoke the generated Makefile from outside of the $(objtree) directory, $(CURDIR) points to the absolute path of $(objtree). BTW, 'lastword' is natively supported by GNU Make 3.81+, which is the current requirement for building the kernel. Signed-off-by: Masahiro Yamada --- scripts/mkmakefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 85995f90e5c8..412f13fdff52 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -20,9 +20,6 @@ fi cat << EOF > Makefile # Automatically generated by $0: don't edit -lastword = \$(word \$(words \$(1)),\$(1)) -makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) - ifeq ("\$(origin V)", "command line") VERBOSE := \$(V) endif @@ -30,15 +27,12 @@ ifneq (\$(VERBOSE),1) Q := @ endif -MAKEARGS := -C $1 -MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) - MAKEFLAGS += --no-print-directory .PHONY: __sub-make \$(MAKECMDGOALS) __sub-make: - \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS) + \$(Q)\$(MAKE) -C $1 O=\$(CURDIR) \$(MAKECMDGOALS) \$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make @: From 153e04b373dd5a4fdb841a727e47c40b1ad10ffc Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 28 Sep 2018 15:21:55 +0900 Subject: [PATCH 12/19] modpost: remove leftover symbol prefix handling for module device table Blackfin and metag were the only architectures that prefix symbols with an underscore. They were removed by commit 4ba66a976072 ("arch: remove blackfin port"), commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively. It is no longer necessary to handle part of module device table symbols. Signed-off-by: Masahiro Yamada --- scripts/mod/file2alias.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 7be43697ff84..ba4ebc4b346e 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1415,11 +1415,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) return; - /* All our symbols are of form __mod____device_table. */ - name = strstr(symname, "__mod_"); - if (!name) + /* All our symbols are of form __mod____device_table. */ + if (strncmp(symname, "__mod_", strlen("__mod_"))) return; - name += strlen("__mod_"); + name = symname + strlen("__mod_"); namelen = strlen(name); if (namelen < strlen("_device_table")) return; From fb073a4b473e5b854312dc819c66ded9d103e824 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Oct 2018 18:44:36 +0900 Subject: [PATCH 13/19] 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(-) 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) From a33e7ae295d5bc20568c48ac217d07f011091c32 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 1 Oct 2018 18:44:37 +0900 Subject: [PATCH 14/19] 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(-) 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 From 9df3e7a7d7d6d92df7c58fb17f900fdc2d8b5031 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 2 Oct 2018 10:32:23 +0900 Subject: [PATCH 15/19] 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(-) 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) From 69ea912fda74a673d330d23595385e5b73e3a2b9 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 4 Oct 2018 13:25:19 +0900 Subject: [PATCH 16/19] kbuild: remove unneeded link_multi_deps Since commit c8589d1e9e01 ("kbuild: handle multi-objs dependency appropriately"), $^ really represents all the prerequisite of the composite object being built. Hence, $(filter %.o,$^) contains all the objects to link together, which is much simpler than link_multi_deps calculation. Please note $(filter-out FORCE,$^) does not work here. When a single object module is turned into a multi object module, $^ will contain header files that were previously included for building the single object, and recorded in the .*.cmd file. To filter out such headers, $(filter %.o,$^) should be used here. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index cb0377427f94..f21b48d4a8f2 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -485,28 +485,12 @@ targets += $(obj)/lib-ksyms.o endif -# -# Rule to link composite objects -# -# Composite objects are specified in kbuild makefile as follows: -# -objs := -# or -# -y := -# or -# -m := -# The -m syntax only works if is a module -link_multi_deps = \ -$(filter $(addprefix $(obj)/, \ -$($(subst $(obj)/,,$(@:.o=-objs))) \ -$($(subst $(obj)/,,$(@:.o=-y))) \ -$($(subst $(obj)/,,$(@:.o=-m)))), $^) - quiet_cmd_link_multi-m = LD [M] $@ -cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) +cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) $(multi-used-m): FORCE $(call if_changed,link_multi-m) - @{ echo $(@:.o=.ko); echo $(link_multi_deps); \ + @{ echo $(@:.o=.ko); echo $(filter %.o,$^); \ $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) $(call multi_depend, $(multi-used-m), .o, -objs -y -m) From 7d0ea2524202db5cb3f5bde9c0cdd6dea61bc0e3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 10 Oct 2018 00:05:39 +0900 Subject: [PATCH 17/19] kbuild: use 'else ifeq' for checksrc to improve readability 'ifeq ... else ifeq ... endif' notation is supported by GNU Make 3.81 or later, which is the requirement for building the kernel since commit 37d69ee30808 ("docs: bump minimal GNU Make version to 3.81"). Use it to improve the readability. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index f21b48d4a8f2..7d884d8f37ff 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -73,14 +73,12 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ @: # Linus' kernel sanity checking tool -ifneq ($(KBUILD_CHECKSRC),0) - ifeq ($(KBUILD_CHECKSRC),2) - quiet_cmd_force_checksrc = CHECK $< - cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; - else - quiet_cmd_checksrc = CHECK $< - cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; - endif +ifeq ($(KBUILD_CHECKSRC),1) + quiet_cmd_checksrc = CHECK $< + cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; +else ifeq ($(KBUILD_CHECKSRC),2) + quiet_cmd_force_checksrc = CHECK $< + cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; endif ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) From 9e1e8194332fa4c453bcbad434b5da17c1c7e4c5 Mon Sep 17 00:00:00 2001 From: Leonardo Bras Date: Wed, 24 Oct 2018 01:03:51 -0300 Subject: [PATCH 18/19] ASN.1: Remove unnecessary shadowed local variable Remove an unnecessary shadowed local variable (start). It was used only once, with the same value it was started before the if block. Signed-off-by: Leonardo Bras Signed-off-by: Masahiro Yamada --- scripts/asn1_compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c index c146020fc783..1b28787028d3 100644 --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c @@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end) /* Handle string tokens */ if (isalpha(*p)) { - const char **dir, *start = p; + const char **dir; /* Can be a directive, type name or element * name. Find the end of the name. From c2b1a9226fe7c1cee8f0ae42496f3eb282d73ebb Mon Sep 17 00:00:00 2001 From: Leonardo Bras Date: Wed, 24 Oct 2018 01:03:52 -0300 Subject: [PATCH 19/19] modpost: Create macro to avoid variable shadowing Create DEF_FIELD_ADDR_VAR as a more generic version of the DEF_FIELD_ADD macro, allowing usage of a variable name other than the struct element name. Also, sets DEF_FIELD_ADDR as a specific usage of DEF_FILD_ADDR_VAR in which the var name is the same as the struct element name. Then, makes use of DEF_FIELD_ADDR_VAR to create a variable of another name, in order to avoid variable shadowing. Signed-off-by: Leonardo Bras Signed-off-by: Masahiro Yamada --- scripts/mod/file2alias.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index ba4ebc4b346e..28a61665bb9c 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -95,12 +95,20 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; */ #define DEF_FIELD(m, devid, f) \ typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) + +/* Define a variable v that holds the address of field f of struct devid + * based at address m. Due to the way typeof works, for a field of type + * T[N] the variable has type T(*)[N], _not_ T*. + */ +#define DEF_FIELD_ADDR_VAR(m, devid, f, v) \ + typeof(((struct devid *)0)->f) *v = ((m) + OFF_##devid##_##f) + /* Define a variable f that holds the address of field f of struct devid * based at address m. Due to the way typeof works, for a field of type * T[N] the variable has type T(*)[N], _not_ T*. */ #define DEF_FIELD_ADDR(m, devid, f) \ - typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f) + DEF_FIELD_ADDR_VAR(m, devid, f, f) /* Add a table entry. We test function type matches while we're here. */ #define ADD_TO_DEVTABLE(device_id, type, function) \ @@ -644,7 +652,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size, for (i = 0; i < count; i++) { unsigned int j; - DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, devs); + DEF_FIELD_ADDR(symval + i * id_size, pnp_card_device_id, devs); for (j = 0; j < PNP_MAX_DEVICES; j++) { const char *id = (char *)(*devs)[j].id; @@ -656,10 +664,13 @@ static void do_pnp_card_entries(void *symval, unsigned long size, /* find duplicate, already added value */ for (i2 = 0; i2 < i && !dup; i2++) { - DEF_FIELD_ADDR(symval + i2*id_size, pnp_card_device_id, devs); + DEF_FIELD_ADDR_VAR(symval + i2 * id_size, + pnp_card_device_id, + devs, devs_dup); for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { - const char *id2 = (char *)(*devs)[j2].id; + const char *id2 = + (char *)(*devs_dup)[j2].id; if (!id2[0]) break;