Merge tag 'kbuild-fixes-v5.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

- detect missing missing "WITH Linux-syscall-note" for uapi headers

- fix needless rebuild when using Clang

- fix false-positive cc-option in Kconfig when using Clang

- avoid including corrupted .*.cmd files in the modpost stage

- fix warning of 'make vmlinux'

- fix {m,n,x,g}config to not generate the broken .config on the second
save operation.

- some trivial Makefile fixes

* tag 'kbuild-fixes-v5.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
kconfig: Clear "written" flag to avoid data loss
kbuild: Check for unknown options with cc-option usage in Kconfig and clang
lib/raid6: fix unnecessary rebuild of vpermxor*.c
kbuild: modpost: do not parse unnecessary rules for vmlinux modpost
kbuild: modpost: remove unnecessary dependency for __modpost
kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules
kbuild: modpost: include .*.cmd files only when targets exist
kbuild: initialize CLANG_FLAGS correctly in the top Makefile
kbuild: detect missing "WITH Linux-syscall-note" for uapi headers

+2 -1
Makefile
··· 472 472 KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds 473 473 KBUILD_LDFLAGS := 474 474 GCC_PLUGINS_CFLAGS := 475 + CLANG_FLAGS := 475 476 476 477 export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC 477 478 export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS ··· 520 519 521 520 ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) 522 521 ifneq ($(CROSS_COMPILE),) 523 - CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) 522 + CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) 524 523 GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) 525 524 CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) 526 525 GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
+1 -1
lib/raid6/Makefile
··· 66 66 CFLAGS_vpermxor2.o += $(altivec_flags) 67 67 CFLAGS_vpermxor4.o += $(altivec_flags) 68 68 CFLAGS_vpermxor8.o += $(altivec_flags) 69 - targets += vpermxor1.o vpermxor2.o vpermxor4.o vpermxor8.o 69 + targets += vpermxor1.c vpermxor2.c vpermxor4.c vpermxor8.c 70 70 $(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE 71 71 $(call if_changed,unroll) 72 72
+1 -1
scripts/Kconfig.include
··· 25 25 26 26 # $(cc-option,<flag>) 27 27 # Return y if the compiler supports <flag>, n otherwise 28 - cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null) 28 + cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null) 29 29 30 30 # $(ld-option,<flag>) 31 31 # Return y if the linker supports <flag>, n otherwise
+42 -38
scripts/Makefile.modpost
··· 38 38 # symbols in the final module linking stage 39 39 # KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. 40 40 # This is solely useful to speed up test compiles 41 - PHONY := _modpost 42 - _modpost: __modpost 41 + 42 + PHONY := __modpost 43 + __modpost: 43 44 44 45 include include/config/auto.conf 45 46 include scripts/Kbuild.include 47 + 48 + kernelsymfile := $(objtree)/Module.symvers 49 + modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers 50 + 51 + MODPOST = scripts/mod/modpost \ 52 + $(if $(CONFIG_MODVERSIONS),-m) \ 53 + $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ 54 + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ 55 + $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ 56 + $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ 57 + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ 58 + $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ 59 + $(if $(KBUILD_MODPOST_WARN),-w) 60 + 61 + ifdef MODPOST_VMLINUX 62 + 63 + __modpost: vmlinux.o 64 + 65 + quiet_cmd_modpost = MODPOST $@ 66 + cmd_modpost = $(MODPOST) $@ 67 + 68 + PHONY += vmlinux.o 69 + vmlinux.o: 70 + $(call cmd,modpost) 71 + 72 + else 46 73 47 74 # When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info 48 75 ifneq ($(KBUILD_EXTMOD),) ··· 85 58 86 59 include scripts/Makefile.lib 87 60 88 - kernelsymfile := $(objtree)/Module.symvers 89 - modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers 90 - 91 61 modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order 92 62 93 - # Step 1), find all modules listed in modules.order 94 - ifdef CONFIG_MODULES 63 + # find all modules listed in modules.order 95 64 modules := $(sort $(shell cat $(modorder))) 96 - endif 97 65 98 66 # Stop after building .o files if NOFINAL is set. Makes compile tests quicker 99 - _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) 67 + __modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) 68 + @: 100 69 101 - # Step 2), invoke modpost 102 - # Includes step 3,4 103 - modpost = scripts/mod/modpost \ 104 - $(if $(CONFIG_MODVERSIONS),-m) \ 105 - $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ 106 - $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ 107 - $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ 108 - $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ 109 - $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ 110 - $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ 111 - $(if $(KBUILD_MODPOST_WARN),-w) 112 - 113 - MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS))) 70 + MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux) 114 71 115 72 # We can go over command line length here, so be careful. 116 - quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules 117 - cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(modpost) $(MODPOST_OPT) -s -T - 73 + quiet_cmd_modpost = MODPOST $(words $(modules)) modules 74 + cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(MODPOST) 118 75 119 - PHONY += __modpost 120 - __modpost: $(modules:.ko=.o) FORCE 121 - $(call cmd,modpost) $(wildcard vmlinux) 122 - 123 - quiet_cmd_kernel-mod = MODPOST $@ 124 - cmd_kernel-mod = $(modpost) $@ 125 - 126 - vmlinux.o: FORCE 127 - $(call cmd,kernel-mod) 76 + PHONY += modules-modpost 77 + modules-modpost: 78 + $(call cmd,modpost) 128 79 129 80 # Declare generated files as targets for modpost 130 - $(modules:.ko=.mod.c): __modpost ; 131 - 81 + $(modules:.ko=.mod.c): modules-modpost 132 82 133 83 # Step 5), compile all *.mod.c files 134 84 ··· 149 145 # optimization, we don't need to read them if the target does not 150 146 # exist, we will rebuild anyway in that case. 151 147 152 - cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) 148 + existing-targets := $(wildcard $(sort $(targets))) 153 149 154 - ifneq ($(cmd_files),) 155 - include $(cmd_files) 150 + -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 151 + 156 152 endif 157 153 158 154 .PHONY: $(PHONY)
+6
scripts/headers_install.sh
··· 23 23 24 24 trap 'rm -f $OUTFILE $TMPFILE' EXIT 25 25 26 + # SPDX-License-Identifier with GPL variants must have "WITH Linux-syscall-note" 27 + if [ -n "$(sed -n -e "/SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/!p}" $INFILE)" ]; then 28 + echo "error: $INFILE: missing \"WITH Linux-syscall-note\" for SPDX-License-Identifier" >&2 29 + exit 1 30 + fi 31 + 26 32 sed -E -e ' 27 33 s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g 28 34 s/__attribute_const__([[:space:]]|$)/\1/g
+4
scripts/kconfig/confdata.c
··· 848 848 const char *str; 849 849 char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1]; 850 850 char *env; 851 + int i; 851 852 bool need_newline = false; 852 853 853 854 if (!name) ··· 930 929 } 931 930 } 932 931 fclose(out); 932 + 933 + for_all_symbols(i, sym) 934 + sym->flags &= ~SYMBOL_WRITTEN; 933 935 934 936 if (*tmpname) { 935 937 if (is_same(name, tmpname)) {