summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-10-12 05:22:25 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2017-11-13 08:54:24 -0500
commit433dc2ebe7d17dd21cba7ad5c362d37323592236 (patch)
tree00de5ce2e441f801d2991c8ef5897a0e11674c6c /Makefile
parent4e56207130eda9a27df116623e2fce7cca2c6764 (diff)
kbuild: do not call cc-option before KBUILD_CFLAGS initialization
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>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile21
1 files changed, 11 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index d3e6fccfad9b..a7476e6934f1 100644
--- a/Makefile
+++ b/Makefile
@@ -392,9 +392,6 @@ LDFLAGS_MODULE =
392CFLAGS_KERNEL = 392CFLAGS_KERNEL =
393AFLAGS_KERNEL = 393AFLAGS_KERNEL =
394LDFLAGS_vmlinux = 394LDFLAGS_vmlinux =
395CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,)
396CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
397
398 395
399# Use USERINCLUDE when you must reference the UAPI directories only. 396# Use USERINCLUDE when you must reference the UAPI directories only.
400USERINCLUDE := \ 397USERINCLUDE := \
@@ -413,21 +410,19 @@ LINUXINCLUDE := \
413 -I$(objtree)/include \ 410 -I$(objtree)/include \
414 $(USERINCLUDE) 411 $(USERINCLUDE)
415 412
416KBUILD_CPPFLAGS := -D__KERNEL__ 413KBUILD_AFLAGS := -D__ASSEMBLY__
417
418KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 414KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
419 -fno-strict-aliasing -fno-common -fshort-wchar \ 415 -fno-strict-aliasing -fno-common -fshort-wchar \
420 -Werror-implicit-function-declaration \ 416 -Werror-implicit-function-declaration \
421 -Wno-format-security \ 417 -Wno-format-security \
422 -std=gnu89 $(call cc-option,-fno-PIE) 418 -std=gnu89
423 419KBUILD_CPPFLAGS := -D__KERNEL__
424
425KBUILD_AFLAGS_KERNEL := 420KBUILD_AFLAGS_KERNEL :=
426KBUILD_CFLAGS_KERNEL := 421KBUILD_CFLAGS_KERNEL :=
427KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
428KBUILD_AFLAGS_MODULE := -DMODULE 422KBUILD_AFLAGS_MODULE := -DMODULE
429KBUILD_CFLAGS_MODULE := -DMODULE 423KBUILD_CFLAGS_MODULE := -DMODULE
430KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds 424KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
425GCC_PLUGINS_CFLAGS :=
431 426
432export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC 427export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
433export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES 428export CPP AR NM STRIP OBJCOPY OBJDUMP HOSTLDFLAGS HOST_LOADLIBES
@@ -435,7 +430,7 @@ export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
435export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 430export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
436 431
437export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS 432export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
438export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV CFLAGS_KCOV CFLAGS_KASAN CFLAGS_UBSAN 433export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_KASAN CFLAGS_UBSAN
439export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE 434export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
440export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE 435export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
441export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL 436export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
@@ -607,6 +602,12 @@ endif
607# Defaults to vmlinux, but the arch makefile usually adds further targets 602# Defaults to vmlinux, but the arch makefile usually adds further targets
608all: vmlinux 603all: vmlinux
609 604
605KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
606KBUILD_AFLAGS += $(call cc-option,-fno-PIE)
607CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,)
608CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,)
609export CFLAGS_GCOV CFLAGS_KCOV
610
610# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default 611# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
611# values of the respective KBUILD_* variables 612# values of the respective KBUILD_* variables
612ARCH_CPPFLAGS := 613ARCH_CPPFLAGS :=