mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
kbuild: do not call cc-option before KBUILD_CFLAGS initialization
[ Upstream commit 433dc2ebe7
]
Some $(call cc-option,...) are invoked very early, even before
KBUILD_CFLAGS, etc. are initialized.
The returned string from $(call cc-option,...) depends on
KBUILD_CPPFLAGS, KBUILD_CFLAGS, and GCC_PLUGINS_CFLAGS.
Since they are exported, they are not empty when the top Makefile
is recursively invoked.
The recursion occurs in several places. For example, the top
Makefile invokes itself for silentoldconfig. "make tinyconfig",
"make rpm-pkg" are the cases, too.
In those cases, the second call of cc-option from the same line
runs a different shell command due to non-pristine KBUILD_CFLAGS.
To get the same result all the time, KBUILD_* and GCC_PLUGINS_CFLAGS
must be initialized before any call of cc-option. This avoids
garbage data in the .cache.mk file.
Move all calls of cc-option below the config targets because target
compiler flags are unnecessary for Kconfig.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d7a71904e6
commit
b0c08c89ea
1 changed files with 11 additions and 10 deletions
21
Makefile
21
Makefile
|
@ -373,9 +373,6 @@ LDFLAGS_MODULE =
|
||||||
CFLAGS_KERNEL =
|
CFLAGS_KERNEL =
|
||||||
AFLAGS_KERNEL =
|
AFLAGS_KERNEL =
|
||||||
LDFLAGS_vmlinux =
|
LDFLAGS_vmlinux =
|
||||||
CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,)
|
|
||||||
CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
|
|
||||||
|
|
||||||
|
|
||||||
# Use USERINCLUDE when you must reference the UAPI directories only.
|
# Use USERINCLUDE when you must reference the UAPI directories only.
|
||||||
USERINCLUDE := \
|
USERINCLUDE := \
|
||||||
|
@ -394,21 +391,19 @@ LINUXINCLUDE := \
|
||||||
-I$(objtree)/include \
|
-I$(objtree)/include \
|
||||||
$(USERINCLUDE)
|
$(USERINCLUDE)
|
||||||
|
|
||||||
KBUILD_CPPFLAGS := -D__KERNEL__
|
KBUILD_AFLAGS := -D__ASSEMBLY__
|
||||||
|
|
||||||
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
|
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
|
||||||
-fno-strict-aliasing -fno-common -fshort-wchar \
|
-fno-strict-aliasing -fno-common -fshort-wchar \
|
||||||
-Werror-implicit-function-declaration \
|
-Werror-implicit-function-declaration \
|
||||||
-Wno-format-security \
|
-Wno-format-security \
|
||||||
-std=gnu89 $(call cc-option,-fno-PIE)
|
-std=gnu89
|
||||||
|
KBUILD_CPPFLAGS := -D__KERNEL__
|
||||||
|
|
||||||
KBUILD_AFLAGS_KERNEL :=
|
KBUILD_AFLAGS_KERNEL :=
|
||||||
KBUILD_CFLAGS_KERNEL :=
|
KBUILD_CFLAGS_KERNEL :=
|
||||||
KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
|
|
||||||
KBUILD_AFLAGS_MODULE := -DMODULE
|
KBUILD_AFLAGS_MODULE := -DMODULE
|
||||||
KBUILD_CFLAGS_MODULE := -DMODULE
|
KBUILD_CFLAGS_MODULE := -DMODULE
|
||||||
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
|
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
|
||||||
|
GCC_PLUGINS_CFLAGS :=
|
||||||
|
|
||||||
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
|
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
|
||||||
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
|
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
|
||||||
|
@ -421,7 +416,7 @@ export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
|
||||||
export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
|
export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
|
||||||
|
|
||||||
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
|
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
|
||||||
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV CFLAGS_KCOV CFLAGS_KASAN CFLAGS_UBSAN
|
export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_KASAN CFLAGS_UBSAN
|
||||||
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
|
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
|
||||||
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
|
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
|
||||||
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
|
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
|
||||||
|
@ -622,6 +617,12 @@ endif
|
||||||
# Defaults to vmlinux, but the arch makefile usually adds further targets
|
# Defaults to vmlinux, but the arch makefile usually adds further targets
|
||||||
all: vmlinux
|
all: vmlinux
|
||||||
|
|
||||||
|
KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
|
||||||
|
KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
|
||||||
|
CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,)
|
||||||
|
CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
|
||||||
|
export CFLAGS_GCOV CFLAGS_KCOV
|
||||||
|
|
||||||
# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
|
# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
|
||||||
# values of the respective KBUILD_* variables
|
# values of the respective KBUILD_* variables
|
||||||
ARCH_CPPFLAGS :=
|
ARCH_CPPFLAGS :=
|
||||||
|
|
Loading…
Reference in a new issue