Skip to content

Commit 05e4f88

Browse files
committed
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 parents 8449c98 + 0c5b6c2 commit 05e4f88

File tree

7 files changed

+58
-43
lines changed

7 files changed

+58
-43
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ KBUILD_CFLAGS_MODULE := -DMODULE
472472
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
473473
KBUILD_LDFLAGS :=
474474
GCC_PLUGINS_CFLAGS :=
475+
CLANG_FLAGS :=
475476

476477
export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
477478
export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
@@ -519,7 +520,7 @@ endif
519520

520521
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
521522
ifneq ($(CROSS_COMPILE),)
522-
CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
523+
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
523524
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
524525
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
525526
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)

lib/raid6/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CFLAGS_vpermxor1.o += $(altivec_flags)
6666
CFLAGS_vpermxor2.o += $(altivec_flags)
6767
CFLAGS_vpermxor4.o += $(altivec_flags)
6868
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
7070
$(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE
7171
$(call if_changed,unroll)
7272

scripts/Kconfig.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
2525

2626
# $(cc-option,<flag>)
2727
# 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)
2929

3030
# $(ld-option,<flag>)
3131
# Return y if the linker supports <flag>, n otherwise

scripts/Makefile.modpost

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,39 @@
3838
# symbols in the final module linking stage
3939
# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
4040
# This is solely useful to speed up test compiles
41-
PHONY := _modpost
42-
_modpost: __modpost
41+
42+
PHONY := __modpost
43+
__modpost:
4344

4445
include include/config/auto.conf
4546
include scripts/Kbuild.include
4647

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
73+
4774
# When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info
4875
ifneq ($(KBUILD_EXTMOD),)
4976

@@ -58,50 +85,27 @@ endif
5885

5986
include scripts/Makefile.lib
6087

61-
kernelsymfile := $(objtree)/Module.symvers
62-
modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
63-
6488
modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order
6589

66-
# Step 1), find all modules listed in modules.order
67-
ifdef CONFIG_MODULES
90+
# find all modules listed in modules.order
6891
modules := $(sort $(shell cat $(modorder)))
69-
endif
7092

7193
# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
72-
_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
73-
74-
# Step 2), invoke modpost
75-
# Includes step 3,4
76-
modpost = scripts/mod/modpost \
77-
$(if $(CONFIG_MODVERSIONS),-m) \
78-
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
79-
$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
80-
$(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
81-
$(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \
82-
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
83-
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
84-
$(if $(KBUILD_MODPOST_WARN),-w)
85-
86-
MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))
94+
__modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
95+
@:
8796

88-
# We can go over command line length here, so be careful.
89-
quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
90-
cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(modpost) $(MODPOST_OPT) -s -T -
97+
MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux)
9198

92-
PHONY += __modpost
93-
__modpost: $(modules:.ko=.o) FORCE
94-
$(call cmd,modpost) $(wildcard vmlinux)
95-
96-
quiet_cmd_kernel-mod = MODPOST $@
97-
cmd_kernel-mod = $(modpost) $@
99+
# We can go over command line length here, so be careful.
100+
quiet_cmd_modpost = MODPOST $(words $(modules)) modules
101+
cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(MODPOST)
98102

99-
vmlinux.o: FORCE
100-
$(call cmd,kernel-mod)
103+
PHONY += modules-modpost
104+
modules-modpost:
105+
$(call cmd,modpost)
101106

102107
# Declare generated files as targets for modpost
103-
$(modules:.ko=.mod.c): __modpost ;
104-
108+
$(modules:.ko=.mod.c): modules-modpost
105109

106110
# Step 5), compile all *.mod.c files
107111

@@ -145,10 +149,10 @@ FORCE:
145149
# optimization, we don't need to read them if the target does not
146150
# exist, we will rebuild anyway in that case.
147151

148-
cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
152+
existing-targets := $(wildcard $(sort $(targets)))
153+
154+
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
149155

150-
ifneq ($(cmd_files),)
151-
include $(cmd_files)
152156
endif
153157

154158
.PHONY: $(PHONY)

scripts/headers_install.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ TMPFILE=$OUTFILE.tmp
2323

2424
trap 'rm -f $OUTFILE $TMPFILE' EXIT
2525

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+
2632
sed -E -e '
2733
s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
2834
s/__attribute_const__([[:space:]]|$)/\1/g

scripts/kconfig/confdata.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ int conf_write(const char *name)
848848
const char *str;
849849
char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
850850
char *env;
851+
int i;
851852
bool need_newline = false;
852853

853854
if (!name)
@@ -930,6 +931,9 @@ int conf_write(const char *name)
930931
}
931932
fclose(out);
932933

934+
for_all_symbols(i, sym)
935+
sym->flags &= ~SYMBOL_WRITTEN;
936+
933937
if (*tmpname) {
934938
if (is_same(name, tmpname)) {
935939
conf_message("No change to %s", name);

scripts/link-vmlinux.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ info LD vmlinux.o
210210
modpost_link vmlinux.o
211211

212212
# modpost vmlinux.o to check for section mismatches
213-
${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o
213+
${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
214214

215215
info MODINFO modules.builtin.modinfo
216216
${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo

0 commit comments

Comments
 (0)