diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 6c3b24900..9ec3ea890 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -184,7 +184,6 @@ LOCAL_NDK_VERSION:=current LOCAL_NO_CRT:= LOCAL_NO_DEFAULT_COMPILER_FLAGS:= LOCAL_NO_FPIE := -LOCAL_NO_LIBGCC:= LOCAL_NO_LIBCRT_BUILTINS:= LOCAL_NO_NOTICE_FILE:= LOCAL_NO_PIC:= diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk index 6571d99be..a2abb1a32 100644 --- a/core/cxx_stl_setup.mk +++ b/core/cxx_stl_setup.mk @@ -76,17 +76,27 @@ ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),) my_ldflags += -nostdlib++ else my_static_libraries += libc++demangle - ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) - my_static_libraries += libunwind_llvm - my_ldflags += -Wl,--exclude-libs,libunwind_llvm.a - endif ifeq ($(my_link_type),static) my_static_libraries += libm libc + ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) + my_static_libraries += libunwind_llvm + my_ldflags += -Wl,--exclude-libs,libunwind_llvm.a + else + my_static_libraries += libgcc_stripped + my_ldflags += -Wl,--exclude-libs,libgcc_stripped.a + endif endif endif else ifeq ($(my_cxx_stl),ndk) - # Using an NDK STL. Handled in binary.mk. + # Using an NDK STL. Handled in binary.mk, except for the unwinder. + ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) + my_static_libraries += libunwind_llvm + my_ldflags += -Wl,--exclude-libs,libunwind_llvm.a + else + my_static_libraries += libgcc_stripped + my_ldflags += -Wl,--exclude-libs,libgcc_stripped.a + endif else ifeq ($(my_cxx_stl),libstdc++) $(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported) else ifeq ($(my_cxx_stl),none) diff --git a/core/definitions.mk b/core/definitions.mk index 63e609ec0..13698d153 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1717,7 +1717,6 @@ $(hide) $(PRIVATE_CXX_LINK) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ $(PRIVATE_TARGET_LIBCRT_BUILTINS) \ $(PRIVATE_TARGET_LIBATOMIC) \ - $(PRIVATE_TARGET_LIBGCC) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_ALL_SHARED_LIBRARIES) \ @@ -1753,7 +1752,6 @@ $(hide) $(PRIVATE_CXX_LINK) -pie \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ $(PRIVATE_TARGET_LIBCRT_BUILTINS) \ $(PRIVATE_TARGET_LIBATOMIC) \ - $(PRIVATE_TARGET_LIBGCC) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ $(PRIVATE_ALL_SHARED_LIBRARIES) \ @@ -1800,7 +1798,6 @@ $(hide) $(PRIVATE_CXX_LINK) \ $(PRIVATE_TARGET_LIBATOMIC) \ $(filter %libcompiler_rt.a %libcompiler_rt.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(PRIVATE_TARGET_LIBCRT_BUILTINS) \ - $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(PRIVATE_TARGET_CRTEND_O) endef diff --git a/core/executable_internal.mk b/core/executable_internal.mk index a9915aa6e..32e56dd27 100644 --- a/core/executable_internal.mk +++ b/core/executable_internal.mk @@ -41,11 +41,6 @@ my_target_libcrt_builtins := else my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS) endif -ifeq ($(LOCAL_NO_LIBGCC),true) -my_target_libgcc := -else -my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a -endif 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 := @@ -66,7 +61,6 @@ my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static. my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o) endif $(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins) -$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) $(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o) $(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o) @@ -74,11 +68,11 @@ $(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o) $(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) $(my_target_libcrt_builtins) $(my_target_libgcc) $(my_target_libatomic) $(CLANG_CXX) +$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(my_target_libatomic) $(CLANG_CXX) $(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) $(my_target_libcrt_builtins) $(my_target_libgcc) $(my_target_libatomic) $(CLANG_CXX) +$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o) $(my_target_libcrt_builtins) $(my_target_libatomic) $(CLANG_CXX) $(transform-o-to-executable) $(PRIVATE_POST_LINK_CMD) endif diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk index 8ec07f8e6..219772a1e 100644 --- a/core/shared_library_internal.mk +++ b/core/shared_library_internal.mk @@ -39,11 +39,6 @@ my_target_libcrt_builtins := else my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS) endif -ifeq ($(LOCAL_NO_LIBGCC),true) -my_target_libgcc := -else -my_target_libgcc := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcc,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcc.a -endif 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 := @@ -60,7 +55,6 @@ my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o) my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o) endif $(linked_module): PRIVATE_TARGET_LIBCRT_BUILTINS := $(my_target_libcrt_builtins) -$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) $(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o) $(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o) @@ -71,7 +65,6 @@ $(linked_module): \ $(my_target_crtbegin_so_o) \ $(my_target_crtend_so_o) \ $(my_target_libcrt_builtins) \ - $(my_target_libgcc) \ $(my_target_libatomic) \ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(CLANG_CXX) $(transform-o-to-shared-lib)