From 295a97a73ed021a30c842a3fb01906ab981b704b Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Mon, 11 Feb 2019 14:04:46 -0800 Subject: [PATCH] FROMLIST: Makefile: lld: set -O2 linker flag when linking with LLD For arm64: 0.34% size improvement with lld -O2 over lld for vmlinux. 3.3% size improvement with lld -O2 over lld for Image.lz4-dtb. (am from https://lkml.org/lkml/2019/2/11/1949) Change-Id: Ibdc7ecc9861562305b49456d6d37274ce8075e22 Link: https://github.com/ClangBuiltLinux/linux/issues/343 Suggested-by: Rui Ueyama Suggested-by: Nathan Chancellor Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor Signed-off-by: Nick Desaulniers Bug: 63740206 Signed-off-by: Yousef Algadri Signed-off-by: Raphiel Rollerscaperers Signed-off-by: Chenyang Zhong --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 25b94c9f0ac5..5c270404f5fa 100644 --- a/Makefile +++ b/Makefile @@ -915,6 +915,10 @@ KBUILD_CFLAGS += $(call cc-disable-warning, unused-function) KBUILD_CFLAGS += $(call cc-disable-warning, implicit-function-declaration) endif +ifeq ($(ld-name),lld) +KBUILD_LDFLAGS += -O2 +endif + KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) ifdef CONFIG_FRAME_POINTER KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls