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.
Unified · Split
| @@ -895,10 +895,10 @@ endif · 894 unmodified lines | ||
| 895 | 895 | |
| 896 | 896 | ifdef CONFIG_LTO_CLANG |
| 897 | 897 | ifdef CONFIG_LTO_CLANG_THIN |
| 898 | −CC_FLAGS_LTO += -flto=thin -fsplit-lto-unit | |
| 898 | +CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit | |
| 899 | 899 | KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache |
| 900 | 900 | else |
| 901 | −CC_FLAGS_LTO += -flto | |
| 901 | +CC_FLAGS_LTO := -flto | |
| 902 | 902 | endif |
| 903 | 903 | CC_FLAGS_LTO += -fvisibility=hidden |
| 904 | 904 | |