diff --git a/core/binary.mk b/core/binary.mk index 954df1f445..a5f46daeec 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -7,6 +7,7 @@ ####################################### include $(BUILD_SYSTEM)/base_rules.mk +include $(BUILD_SYSTEM)/use_lld_setup.mk ####################################### ################################################## @@ -516,7 +517,11 @@ ifeq ($(my_clang),true) my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags) -my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) +ifeq ($(my_use_clang_lld),true) + my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS) +else + my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) +endif # my_use_clang_lld else my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 99833c37d0..6baaf92c51 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -269,6 +269,7 @@ LOCAL_TIDY_FLAGS:= LOCAL_UNINSTALLABLE_MODULE:= LOCAL_UNSTRIPPED_PATH:= LOCAL_USE_AAPT2:=$(USE_AAPT2) +LOCAL_USE_CLANG_LLD:= LOCAL_USE_R8:= LOCAL_USE_VNDK:= LOCAL_VENDOR_MODULE:= diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk index ebbe71c2dd..74e0fa2dee 100644 --- a/core/dynamic_binary.mk +++ b/core/dynamic_binary.mk @@ -67,6 +67,11 @@ ifneq ($(HOST_OS),linux) my_pack_module_relocations := false endif +# Relocation packer does not work with LLD yet. +ifeq ($(my_use_clang_lld),true) + my_pack_module_relocations := false +endif + ifeq (true,$(my_pack_module_relocations)) # Pack relocations $(relocation_packer_output): $(relocation_packer_input) diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 0efda57457..de44569174 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -6,6 +6,8 @@ ## ########################################################### +include $(BUILD_SYSTEM)/use_lld_setup.mk + ifneq ($(LOCAL_PREBUILT_LIBS),) $(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH)) endif @@ -70,6 +72,12 @@ ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) ifeq ($(DISABLE_RELOCATION_PACKER),true) my_pack_module_relocations := false endif + + # Relocation packer does not work with LLD yet. + # my_use_clang_lld might be used befor set up in binary.mk + ifeq ($(my_use_clang_lld),true) + my_pack_module_relocations := false + endif endif ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) diff --git a/core/soong_config.mk b/core/soong_config.mk index 2eb7d25745..8cf5b543a8 100644 --- a/core/soong_config.mk +++ b/core/soong_config.mk @@ -99,6 +99,7 @@ $(call add_json_list, CFIExcludePaths, $(CFI_EXCLUDE_PATHS) $( $(call add_json_list, CFIIncludePaths, $(CFI_INCLUDE_PATHS) $(PRODUCT_CFI_INCLUDE_PATHS)) $(call add_json_list, IntegerOverflowExcludePaths, $(INTEGER_OVERFLOW_EXCLUDE_PATHS) $(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS)) +$(call add_json_bool, UseClangLld, $(filter 1 true,$(USE_CLANG_LLD))) $(call add_json_bool, ClangTidy, $(filter 1 true,$(WITH_TIDY))) $(call add_json_str, TidyChecks, $(WITH_TIDY_CHECKS)) diff --git a/core/use_lld_setup.mk b/core/use_lld_setup.mk new file mode 100644 index 0000000000..69ceddc53d --- /dev/null +++ b/core/use_lld_setup.mk @@ -0,0 +1,14 @@ +############################################################# +## Set up flags based on USE_CLANG_LLD and LOCAL_USE_CLANG_LLD. +## Input variables: USE_CLANG_LLD,LOCAL_USE_CLANG_LLD. +## Output variables: my_use_clang_lld +############################################################# + +# Use LLD only if it's not disabled by LOCAL_USE_CLANG_LLD, +# and enabled by LOCAL_USE_CLANG_LLD or USE_CLANG_LLD. +my_use_clang_lld := false +ifeq (,$(filter 0 false,$(LOCAL_USE_CLANG_LLD))) + ifneq (,$(filter 1 true,$(LOCAL_USE_CLANG_LLD) $(USE_CLANG_LLD))) + my_use_clang_lld := true + endif +endif