UPSTREAM: kbuild: prevent CC_FLAGS_LTO self-bloating on recursive rebuilds

CC_FLAGS_LTO gets initialized only via +=, never with := or =.
When building with CONFIG_TRIM_UNUSED_KSYMS, Kbuild may perform
several kernel rebuilds to satisfy symbol dependencies. In this
case, value of CC_FLAGS_LTO is concatenated each time, which
triggers a full rebuild.
Initialize it with := to fix this.

Fixes: dc5723b02e52 ("kbuild: add support for Clang LTO")
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210121184544.659998-1-alobakin@pm.me
(cherry picked from commit 2b8689520520175075ca97bc4eaf51ff3f7253aa)
Bug: 187129171
Signed-off-by: Connor O'Brien <connoro@google.com>
Change-Id: Id12534c0bfaec21e72b534a5a032161ff4606c73
This commit is contained in:
Alexander Lobakin
2021-01-21 18:45:55 +00:00
committed by Connor O'Brien
parent 631b4dba04
commit e11b323bca

View File

@@ -917,10 +917,10 @@ endif
ifdef CONFIG_LTO_CLANG ifdef CONFIG_LTO_CLANG
ifdef CONFIG_LTO_CLANG_THIN ifdef CONFIG_LTO_CLANG_THIN
CC_FLAGS_LTO += -flto=thin -fsplit-lto-unit CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache
else else
CC_FLAGS_LTO += -flto CC_FLAGS_LTO := -flto
endif endif
ifeq ($(SRCARCH),x86) ifeq ($(SRCARCH),x86)