mirror of https://gitee.com/openkylin/linux.git
Kbuild fixes for v5.3 (2nd)
- 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 -----BEGIN PGP SIGNATURE----- iQJSBAABCgA8FiEEbmPs18K1szRHjPqEPYsBB53g2wYFAl1HAdgeHHlhbWFkYS5t YXNhaGlyb0Bzb2Npb25leHQuY29tAAoJED2LAQed4NsGqh8QAKfE9Y/fmxxZzy9m 7VSQDAyFxXrgqcwSenCry7JiWyfWyp7xh3yRHyytIaEsFntkAivvFGLF3QjEb1h1 gTz5tZkJ83fJJJ7jY3GyP0N7MJuZIvckm1qQ8DGWc5prVQF5/9Oe9HnIRqrwqbnj G3YwRihtQZHE3rT4CdlFjdjR7LENTcA7QqnXrWgLkXxc+6nko0I7/hM6oSw135jz XDiaKy4ioUX/HqOUVa8ae8e5XKH8c/OR5r9X71aYR4fsdOCw8zi3KQ8hGHY3YfUB +QnBJbzcly1oXW8KDrj240lNt2LdMoh5vuYEa5kwAMfWYhIG8xSgC+g7MK9PUHHh K66TA+JO8S99OrqMwnnEipiZjHYhyRlJ6nw4yMEhtjEuNh2/H8+4GLXQWFVNKvF5 x3yhaIFOQiiux1HK03UiqrlIzt3vaYmzKr3MoHyzMQ2JrHuaHgabz9cMna0tNrDk s8Vuxkf5Z6nsV5HoP16vPVEVmzd5t03XMgke93+7uIct+UuFdDhL7ktXM+pFaPTQ /u3hdc2CmiPm11On0AFrSIpb708CRpbgAt3yCtfYgXebgCyR+H6g3BT1Za/GoiHq bunPLNnJ9rN34MI5D8TuLZ4MGUvR2xap7NkOIsK0E90LyP7rp2oy+cEhVSOjVNWO wbpxq9PAs+LZaRO7BDdoCzbigY14 =QEIS -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
05e4f88b7d
3
Makefile
3
Makefile
|
@ -472,6 +472,7 @@ KBUILD_CFLAGS_MODULE := -DMODULE
|
||||||
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
|
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
|
||||||
KBUILD_LDFLAGS :=
|
KBUILD_LDFLAGS :=
|
||||||
GCC_PLUGINS_CFLAGS :=
|
GCC_PLUGINS_CFLAGS :=
|
||||||
|
CLANG_FLAGS :=
|
||||||
|
|
||||||
export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
|
export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC
|
||||||
export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
|
export CPP AR NM STRIP OBJCOPY OBJDUMP PAHOLE KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS
|
||||||
|
@ -519,7 +520,7 @@ endif
|
||||||
|
|
||||||
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
|
ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
|
||||||
ifneq ($(CROSS_COMPILE),)
|
ifneq ($(CROSS_COMPILE),)
|
||||||
CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%))
|
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
|
||||||
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
|
GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
|
||||||
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
|
CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)
|
||||||
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
|
GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
|
||||||
|
|
|
@ -66,7 +66,7 @@ CFLAGS_vpermxor1.o += $(altivec_flags)
|
||||||
CFLAGS_vpermxor2.o += $(altivec_flags)
|
CFLAGS_vpermxor2.o += $(altivec_flags)
|
||||||
CFLAGS_vpermxor4.o += $(altivec_flags)
|
CFLAGS_vpermxor4.o += $(altivec_flags)
|
||||||
CFLAGS_vpermxor8.o += $(altivec_flags)
|
CFLAGS_vpermxor8.o += $(altivec_flags)
|
||||||
targets += vpermxor1.o vpermxor2.o vpermxor4.o vpermxor8.o
|
targets += vpermxor1.c vpermxor2.c vpermxor4.c vpermxor8.c
|
||||||
$(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE
|
$(obj)/vpermxor%.c: $(src)/vpermxor.uc $(src)/unroll.awk FORCE
|
||||||
$(call if_changed,unroll)
|
$(call if_changed,unroll)
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ failure = $(if-success,$(1),n,y)
|
||||||
|
|
||||||
# $(cc-option,<flag>)
|
# $(cc-option,<flag>)
|
||||||
# Return y if the compiler supports <flag>, n otherwise
|
# Return y if the compiler supports <flag>, n otherwise
|
||||||
cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
|
cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -E -x c /dev/null -o /dev/null)
|
||||||
|
|
||||||
# $(ld-option,<flag>)
|
# $(ld-option,<flag>)
|
||||||
# Return y if the linker supports <flag>, n otherwise
|
# Return y if the linker supports <flag>, n otherwise
|
||||||
|
|
|
@ -38,12 +38,39 @@
|
||||||
# symbols in the final module linking stage
|
# symbols in the final module linking stage
|
||||||
# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
|
# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
|
||||||
# This is solely useful to speed up test compiles
|
# This is solely useful to speed up test compiles
|
||||||
PHONY := _modpost
|
|
||||||
_modpost: __modpost
|
PHONY := __modpost
|
||||||
|
__modpost:
|
||||||
|
|
||||||
include include/config/auto.conf
|
include include/config/auto.conf
|
||||||
include scripts/Kbuild.include
|
include scripts/Kbuild.include
|
||||||
|
|
||||||
|
kernelsymfile := $(objtree)/Module.symvers
|
||||||
|
modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
|
||||||
|
|
||||||
|
MODPOST = scripts/mod/modpost \
|
||||||
|
$(if $(CONFIG_MODVERSIONS),-m) \
|
||||||
|
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
|
||||||
|
$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
|
||||||
|
$(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
|
||||||
|
$(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \
|
||||||
|
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
|
||||||
|
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
|
||||||
|
$(if $(KBUILD_MODPOST_WARN),-w)
|
||||||
|
|
||||||
|
ifdef MODPOST_VMLINUX
|
||||||
|
|
||||||
|
__modpost: vmlinux.o
|
||||||
|
|
||||||
|
quiet_cmd_modpost = MODPOST $@
|
||||||
|
cmd_modpost = $(MODPOST) $@
|
||||||
|
|
||||||
|
PHONY += vmlinux.o
|
||||||
|
vmlinux.o:
|
||||||
|
$(call cmd,modpost)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
# When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info
|
# When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info
|
||||||
ifneq ($(KBUILD_EXTMOD),)
|
ifneq ($(KBUILD_EXTMOD),)
|
||||||
|
|
||||||
|
@ -58,50 +85,27 @@ endif
|
||||||
|
|
||||||
include scripts/Makefile.lib
|
include scripts/Makefile.lib
|
||||||
|
|
||||||
kernelsymfile := $(objtree)/Module.symvers
|
|
||||||
modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
|
|
||||||
|
|
||||||
modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order
|
modorder := $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)modules.order
|
||||||
|
|
||||||
# Step 1), find all modules listed in modules.order
|
# find all modules listed in modules.order
|
||||||
ifdef CONFIG_MODULES
|
|
||||||
modules := $(sort $(shell cat $(modorder)))
|
modules := $(sort $(shell cat $(modorder)))
|
||||||
endif
|
|
||||||
|
|
||||||
# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
|
# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
|
||||||
_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
|
__modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
|
||||||
|
@:
|
||||||
|
|
||||||
# Step 2), invoke modpost
|
MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux)
|
||||||
# Includes step 3,4
|
|
||||||
modpost = scripts/mod/modpost \
|
|
||||||
$(if $(CONFIG_MODVERSIONS),-m) \
|
|
||||||
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
|
|
||||||
$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
|
|
||||||
$(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
|
|
||||||
$(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \
|
|
||||||
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
|
|
||||||
$(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \
|
|
||||||
$(if $(KBUILD_MODPOST_WARN),-w)
|
|
||||||
|
|
||||||
MODPOST_OPT=$(subst -i,-n,$(filter -i,$(MAKEFLAGS)))
|
|
||||||
|
|
||||||
# We can go over command line length here, so be careful.
|
# We can go over command line length here, so be careful.
|
||||||
quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
|
quiet_cmd_modpost = MODPOST $(words $(modules)) modules
|
||||||
cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(modpost) $(MODPOST_OPT) -s -T -
|
cmd_modpost = sed 's/ko$$/o/' $(modorder) | $(MODPOST)
|
||||||
|
|
||||||
PHONY += __modpost
|
PHONY += modules-modpost
|
||||||
__modpost: $(modules:.ko=.o) FORCE
|
modules-modpost:
|
||||||
$(call cmd,modpost) $(wildcard vmlinux)
|
$(call cmd,modpost)
|
||||||
|
|
||||||
quiet_cmd_kernel-mod = MODPOST $@
|
|
||||||
cmd_kernel-mod = $(modpost) $@
|
|
||||||
|
|
||||||
vmlinux.o: FORCE
|
|
||||||
$(call cmd,kernel-mod)
|
|
||||||
|
|
||||||
# Declare generated files as targets for modpost
|
# Declare generated files as targets for modpost
|
||||||
$(modules:.ko=.mod.c): __modpost ;
|
$(modules:.ko=.mod.c): modules-modpost
|
||||||
|
|
||||||
|
|
||||||
# Step 5), compile all *.mod.c files
|
# Step 5), compile all *.mod.c files
|
||||||
|
|
||||||
|
@ -145,10 +149,10 @@ FORCE:
|
||||||
# optimization, we don't need to read them if the target does not
|
# optimization, we don't need to read them if the target does not
|
||||||
# exist, we will rebuild anyway in that case.
|
# exist, we will rebuild anyway in that case.
|
||||||
|
|
||||||
cmd_files := $(wildcard $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd))
|
existing-targets := $(wildcard $(sort $(targets)))
|
||||||
|
|
||||||
|
-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
|
||||||
|
|
||||||
ifneq ($(cmd_files),)
|
|
||||||
include $(cmd_files)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: $(PHONY)
|
.PHONY: $(PHONY)
|
||||||
|
|
|
@ -23,6 +23,12 @@ TMPFILE=$OUTFILE.tmp
|
||||||
|
|
||||||
trap 'rm -f $OUTFILE $TMPFILE' EXIT
|
trap 'rm -f $OUTFILE $TMPFILE' EXIT
|
||||||
|
|
||||||
|
# SPDX-License-Identifier with GPL variants must have "WITH Linux-syscall-note"
|
||||||
|
if [ -n "$(sed -n -e "/SPDX-License-Identifier:.*GPL-/{/WITH Linux-syscall-note/!p}" $INFILE)" ]; then
|
||||||
|
echo "error: $INFILE: missing \"WITH Linux-syscall-note\" for SPDX-License-Identifier" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
sed -E -e '
|
sed -E -e '
|
||||||
s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
|
s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
|
||||||
s/__attribute_const__([[:space:]]|$)/\1/g
|
s/__attribute_const__([[:space:]]|$)/\1/g
|
||||||
|
|
|
@ -848,6 +848,7 @@ int conf_write(const char *name)
|
||||||
const char *str;
|
const char *str;
|
||||||
char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
|
char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
|
||||||
char *env;
|
char *env;
|
||||||
|
int i;
|
||||||
bool need_newline = false;
|
bool need_newline = false;
|
||||||
|
|
||||||
if (!name)
|
if (!name)
|
||||||
|
@ -930,6 +931,9 @@ int conf_write(const char *name)
|
||||||
}
|
}
|
||||||
fclose(out);
|
fclose(out);
|
||||||
|
|
||||||
|
for_all_symbols(i, sym)
|
||||||
|
sym->flags &= ~SYMBOL_WRITTEN;
|
||||||
|
|
||||||
if (*tmpname) {
|
if (*tmpname) {
|
||||||
if (is_same(name, tmpname)) {
|
if (is_same(name, tmpname)) {
|
||||||
conf_message("No change to %s", name);
|
conf_message("No change to %s", name);
|
||||||
|
|
|
@ -210,7 +210,7 @@ info LD vmlinux.o
|
||||||
modpost_link vmlinux.o
|
modpost_link vmlinux.o
|
||||||
|
|
||||||
# modpost vmlinux.o to check for section mismatches
|
# modpost vmlinux.o to check for section mismatches
|
||||||
${MAKE} -f "${srctree}/scripts/Makefile.modpost" vmlinux.o
|
${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
|
||||||
|
|
||||||
info MODINFO modules.builtin.modinfo
|
info MODINFO modules.builtin.modinfo
|
||||||
${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
|
${OBJCOPY} -j .modinfo -O binary vmlinux.o modules.builtin.modinfo
|
||||||
|
|
Loading…
Reference in New Issue