ANDROID: Makefile: Add '-fsplit-lto-unit' to cfi-clang-flags
After r350949 in clang, linking an CONFIG_CFI_CLANG kernel fails with
the following error:
aarch64-linux-gnu-ld.gold: fatal error: LLVM gold plugin: linking
module flags 'EnableSplitLTOUnit': IDs have conflicting values
-fsplit-lto-unit is needed when using -fsanitize-cfi so add the flag if
it is supported by the compiler. CONFIG_CFI_CLANG works as expected with
a tip of tree LLVM toolchain after this commit.
Change-Id: I358ff024204c7abcef57b43a583ae960b89113f7
Link: https://github.com/ClangBuiltLinux/linux/issues/406
Link: https://github.com/llvm/llvm-project/commit/84cecfcb3db7c3275ae2d64c419a752d9f5311d6
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
diff --git a/Makefile b/Makefile
index 885b2d8..97d6ad4 100644
--- a/Makefile
+++ b/Makefile
@@ -694,7 +694,7 @@
endif
ifdef CONFIG_CFI_CLANG
-cfi-clang-flags += -fsanitize=cfi
+cfi-clang-flags += -fsanitize=cfi $(call cc-option, -fsplit-lto-unit)
DISABLE_CFI_CLANG := -fno-sanitize=cfi
ifdef CONFIG_MODULES
cfi-clang-flags += -fsanitize-cfi-cross-dso