diff --git a/Makefile b/Makefile index 86c0ae37e350..ec0ac17ab7e5 100644 --- a/Makefile +++ b/Makefile @@ -663,8 +663,8 @@ endif # use llvm-ar for building symbol tables from IR files, and llvm-dis instead # of objdump for processing symbol versions and exports LLVM_AR := llvm-ar -LLVM_DIS := llvm-dis -export LLVM_AR LLVM_DIS +LLVM_NM := llvm-nm +export LLVM_AR LLVM_NM endif # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default @@ -831,10 +831,16 @@ KBUILD_CFLAGS += $(call cc-option,-fdata-sections,) endif ifdef CONFIG_LTO_CLANG -lto-clang-flags := -flto -fvisibility=hidden +ifdef CONFIG_THINLTO +lto-clang-flags := -flto=thin +LDFLAGS += --thinlto-cache-dir=.thinlto-cache +else +lto-clang-flags := -flto +endif +lto-clang-flags += -fvisibility=default $(call cc-option, -fsplit-lto-unit) # allow disabling only clang LTO where needed -DISABLE_LTO_CLANG := -fno-lto -fvisibility=default +DISABLE_LTO_CLANG := -fno-lto export DISABLE_LTO_CLANG endif @@ -851,7 +857,7 @@ export LDFINAL_vmlinux LDFLAGS_FINAL_vmlinux endif ifdef CONFIG_CFI_CLANG -cfi-clang-flags += -fsanitize=cfi $(call cc-option, -fsplit-lto-unit) +cfi-clang-flags += -fsanitize=cfi DISABLE_CFI_CLANG := -fno-sanitize=cfi ifdef CONFIG_MODULES cfi-clang-flags += -fsanitize-cfi-cross-dso diff --git a/arch/Kconfig b/arch/Kconfig index 784c1fe35583..cb156bb334a8 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -622,6 +622,18 @@ config ARCH_SUPPORTS_LTO_CLANG - compiling inline assembly with clang's integrated assembler, - and linking with either lld or GNU gold w/ LLVMgold. +config ARCH_SUPPORTS_THINLTO + bool + help + An architecture should select this if it supports clang's ThinLTO. + +config THINLTO + bool "Use clang ThinLTO (EXPERIMENTAL)" + depends on LTO_CLANG && ARCH_SUPPORTS_THINLTO + default y + help + Use ThinLTO to speed up Link Time Optimization. + choice prompt "Link-Time Optimization (LTO) (EXPERIMENTAL)" default LTO_NONE diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 48622d8c0e31..392ad77e8423 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -220,7 +220,7 @@ cmd_modversions_c = \ > $(@D)/$(@F).symversions; \ fi; \ else \ - if $(LLVM_DIS) -o=- $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ + if $(LLVM_NM) $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ > $(@D)/$(@F).symversions; \ fi; \ @@ -594,7 +594,7 @@ cmd_export_list = \ $(filter_export_list) \ >>$(ksyms-lds); \ else \ - $(LLVM_DIS) -o=- $$o | \ + $(LLVM_NM) $$o | \ $(filter_export_list) \ >>$(ksyms-lds); \ fi; \