From db16dd23841cf9cdb62420eb3ab1eca71a9e102b Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Mon, 16 May 2016 14:41:49 -0700 Subject: [PATCH] Remove TARGET_LIBGCC/LIBATOMIC/LIBGCOV Instead, use the libgcc/libatomic/libgcov from the static libraries dir, which is provided by Soong. Copy the libraries using the Soong script if Soong is disabled - this can be removed once USE_SOONG is removed. Change-Id: Iad2ad20ad5c3cfc48bf1e46e594a482609098d7a --- core/binary.mk | 2 +- core/combo/TARGET_linux-arm.mk | 14 -------------- core/combo/TARGET_linux-arm64.mk | 7 ------- core/combo/TARGET_linux-mips.mk | 18 ------------------ core/combo/TARGET_linux-mips64.mk | 18 ------------------ core/combo/TARGET_linux-x86.mk | 9 --------- core/combo/TARGET_linux-x86_64.mk | 9 --------- core/definitions.mk | 29 +++++++++++++++++++++++++++++ core/executable_internal.mk | 8 ++++---- core/main.mk | 6 ++++++ core/shared_library_internal.mk | 6 ++++-- 11 files changed, 44 insertions(+), 82 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index 4736f0608..ca589bf90 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -410,7 +410,7 @@ endif ifeq ($(my_clang),true) my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT) else - my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV) + my_coverage_lib := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcov,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcov.a endif $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib) diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index 9be6c735d..e2d42cc26 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -146,20 +146,6 @@ $(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \ libc_root := bionic/libc - -## on some hosts, the target cross-compiler is not available so do not run this command -ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),) -# We compile with the global cflags to ensure that -# any flags which affect libgcc are correctly taken -# into account. -$(combo_2nd_arch_prefix)TARGET_LIBGCC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \ - $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name) -$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \ - $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a) -$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \ - $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcov.a) -endif - KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_$(combo_2nd_arch_prefix)ARCH) diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk index 61028c4fe..c02711373 100644 --- a/core/combo/TARGET_linux-arm64.mk +++ b/core/combo/TARGET_linux-arm64.mk @@ -126,13 +126,6 @@ TARGET_RELEASE_CFLAGS := \ libc_root := bionic/libc -TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ - -print-libgcc-file-name) -TARGET_LIBATOMIC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ - -print-file-name=libatomic.a) -TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ - -print-file-name=libgcov.a) - KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH) diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk index fcf4c9d17..d872a4a15 100644 --- a/core/combo/TARGET_linux-mips.mk +++ b/core/combo/TARGET_linux-mips.mk @@ -127,24 +127,6 @@ $(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \ libc_root := bionic/libc - -## on some hosts, the target cross-compiler is not available so do not run this command -ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),) -# We compile with the global cflags to ensure that -# any flags which affect libgcc are correctly taken -# into account. -$(combo_2nd_arch_prefix)TARGET_LIBGCC := \ - $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a) -$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \ - $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a) -LIBGCC_EH := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a) -ifneq ($(LIBGCC_EH),libgcc_eh.a) - $(combo_2nd_arch_prefix)TARGET_LIBGCC += $(LIBGCC_EH) -endif -$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ - --print-file-name=libgcov.a) -endif - KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-mips # mips covers both mips and mips64. diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk index f869317a5..32128b212 100644 --- a/core/combo/TARGET_linux-mips64.mk +++ b/core/combo/TARGET_linux-mips64.mk @@ -133,24 +133,6 @@ TARGET_RELEASE_CFLAGS := \ libc_root := bionic/libc - -## on some hosts, the target cross-compiler is not available so do not run this command -ifneq ($(wildcard $(TARGET_CC)),) -# We compile with the global cflags to ensure that -# any flags which affect libgcc are correctly taken -# into account. -TARGET_LIBGCC := \ - $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a) -TARGET_LIBATOMIC := \ - $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a) -LIBGCC_EH := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a) -ifneq ($(LIBGCC_EH),libgcc_eh.a) - TARGET_LIBGCC += $(LIBGCC_EH) -endif -TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ - --print-file-name=libgcov.a) -endif - KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-mips diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk index 800a1dd7b..1f2750254 100644 --- a/core/combo/TARGET_linux-x86.mk +++ b/core/combo/TARGET_linux-x86.mk @@ -62,15 +62,6 @@ define $(combo_var_prefix)transform-shared-lib-to-toc $(call _gen_toc_command_for_elf,$(1),$(2)) endef -ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),) -$(combo_2nd_arch_prefix)TARGET_LIBGCC := \ - $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcc.a) -$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \ - $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libatomic.a) -$(combo_2nd_arch_prefix)TARGET_LIBGCOV := \ - $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcov.a) -endif - $(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined libc_root := bionic/libc diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk index bf31334b1..ea6550b78 100644 --- a/core/combo/TARGET_linux-x86_64.mk +++ b/core/combo/TARGET_linux-x86_64.mk @@ -62,15 +62,6 @@ define $(combo_var_prefix)transform-shared-lib-to-toc $(call _gen_toc_command_for_elf,$(1),$(2)) endef -ifneq ($(wildcard $(TARGET_CC)),) -TARGET_LIBGCC := \ - $(shell $(TARGET_CC) -m64 -print-file-name=libgcc.a) -TARGET_LIBATOMIC := \ - $(shell $(TARGET_CC) -m64 -print-file-name=libatomic.a) -TARGET_LIBGCOV := \ - $(shell $(TARGET_CC) -m64 -print-file-name=libgcov.a) -endif - TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined libc_root := bionic/libc diff --git a/core/definitions.mk b/core/definitions.mk index 57aa7b6b1..abc6209c0 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -2602,6 +2602,35 @@ endef ########################################################### +## Commands to copy toolchain libraries +########################################################### +ifneq ($(USE_SOONG),true) +# Used when Soong isn't defining our toolchain libraries +# $(1): Name of library (libgcc, etc) +define copy-toolchain-library +$(call copy-toolchain-library-internal,\ + $(call intermediates-dir-for,STATIC_LIBRARIES,$(1))/$(1).a,,$(1)) +ifdef TARGET_2ND_ARCH +$(call copy-toolchain-library-internal,\ + $(call intermediates-dir-for,STATIC_LIBRARIES,$(1),,,2ND_)/$(1).a,2ND_,$(1)) +endif +endef + +# $(1): the intermediates library path +# $(2): whether this is the 2nd target architecture +# $(3): the name of the library without the extension +define copy-toolchain-library-internal +$(1): build/soong/scripts/copygcclib.sh $($(2)TARGET_CC) + @echo "Toolchain library: $(3)" + @mkdir -p $$(dir $$@) + $$(hide) rm -f $$@ + $$(hide) build/soong/scripts/copygcclib.sh $$@ $($(2)TARGET_CC) $($(2)TARGET_GLOBAL_CFLAGS) -print-file-name=$(3).a + +$(call include-depfile,$(1).d,$(1)) +endef +endif + +########################################################### ## Commands to call Proguard ########################################################### define transform-jar-to-proguard diff --git a/core/executable_internal.mk b/core/executable_internal.mk index febea98f6..38084129d 100644 --- a/core/executable_internal.mk +++ b/core/executable_internal.mk @@ -38,9 +38,9 @@ my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) ifeq ($(LOCAL_NO_LIBGCC),true) my_target_libgcc := else -my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) +my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a endif -my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) +my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a ifeq ($(LOCAL_NO_CRT),true) my_target_crtbegin_dynamic_o := my_target_crtbegin_static_o := @@ -73,11 +73,11 @@ $(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(LOCAL_2ND_ARC $(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD) ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) -$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) +$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libgcc) $(my_target_libatomic) $(transform-o-to-static-executable) $(PRIVATE_POST_LINK_CMD) else -$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) +$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libgcc) $(my_target_libatomic) $(transform-o-to-executable) $(PRIVATE_POST_LINK_CMD) endif diff --git a/core/main.mk b/core/main.mk index 3309981a8..83c60e50e 100644 --- a/core/main.mk +++ b/core/main.mk @@ -291,6 +291,12 @@ endif # Bring in standard build system definitions. include $(BUILD_SYSTEM)/definitions.mk +ifneq ($(USE_SOONG),true) +$(eval $(call copy-toolchain-library,libgcc)) +$(eval $(call copy-toolchain-library,libatomic)) +$(eval $(call copy-toolchain-library,libgcov)) +endif + # Bring in dex_preopt.mk include $(BUILD_SYSTEM)/dex_preopt.mk diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk index 6fec4607d..cf35b5e5c 100644 --- a/core/shared_library_internal.mk +++ b/core/shared_library_internal.mk @@ -43,9 +43,9 @@ my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) ifeq ($(LOCAL_NO_LIBGCC),true) my_target_libgcc := else -my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) +my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a endif -my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) +my_target_libatomic := $(call intermediates-dir-for,STATIC_LIBRARIES,libatomic,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libatomic.a ifeq ($(LOCAL_NO_CRT),true) my_target_crtbegin_so_o := my_target_crtend_so_o := @@ -76,6 +76,8 @@ $(linked_module): \ $(all_libraries) \ $(my_target_crtbegin_so_o) \ $(my_target_crtend_so_o) \ + $(my_target_libgcc) \ + $(my_target_libatomic) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(transform-o-to-shared-lib) -- 2.11.0