From 25e20c35c5b638a980cf34aa020bfa87696192b9 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Tue, 19 Feb 2019 16:06:28 -0800 Subject: [PATCH] ANDROID: Makefile: lld: tell clang to use lld This is needed because clang doesn't select which linker to use based on $LD but rather -fuse-ld={bfd,gold,lld,}. This is problematic especially for cc-ldoption, which checks for linker flag support via invoking the compiler, rather than the linker. Select the linker via absolute path from $PATH via `which`. This allows you to build with: $ make LD=ld.lld $ make LD=ld.lld-8 $ make LD=/path/to/ld.lld Add -Qunused-arguments to KBUILD_CPPFLAGS when using LLD, as otherwise Clang likes to complain about -fuse-lld= being unused when compiling but not linking (-c) such as when cc-option is used. Link: ClangBuiltLinux/linux#342 Link: ClangBuiltLinux/linux#366 Link: ClangBuiltLinux/linux#357 Suggested-by: Nathan Chancellor Suggested-by: Masahiro Yamada Signed-off-by: Nick Desaulniers Signed-off-by: Carlos Ayrton Lopez Arroyo <15030201@itcelaya.edu.mx> Signed-off-by: Little-W <1405481963@qq.com> --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0def79b98a56..0e532abe00b4 100644 --- a/Makefile +++ b/Makefile @@ -652,6 +652,13 @@ LLVM_NM := llvm-nm export LLVM_AR LLVM_NM endif +ifeq ($(cc-name),clang) +ifeq ($(ld-name),lld) +KBUILD_CFLAGS += -fuse-ld=lld +endif +KBUILD_CPPFLAGS += -Qunused-arguments +endif + # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default # values of the respective KBUILD_* variables ARCH_CPPFLAGS := @@ -783,7 +790,6 @@ CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) endif KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) -meabi gnu KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) -KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) KBUILD_CFLAGS += $(call cc-disable-warning, gnu) KBUILD_CFLAGS += $(call cc-disable-warning, duplicate-decl-specifier)