From 95fd9d171de6cb0260f274b10f97466cb125e671 Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Fri, 12 Oct 2018 16:58:57 -0700 Subject: [PATCH] Move libgcc to libcrt.builtins libgcc is kept behind libcrt.builtins to provide unwinder symbols and any other missing symbols. Bug: 29275768 Bug: 119007754 Test: m checkbuild Change-Id: Ifb16ed87afc3391f8830d771971315515f929235 Merged-In: Ifb16ed87afc3391f8830d771971315515f929235 (cherry picked from commit b9d89322791c84ad7a76513c6373a5ac5d0de026) --- core/aux_toolchain.mk | 1 - core/binary.mk | 7 ------- core/clang/HOST_CROSS_x86.mk | 1 + core/clang/HOST_CROSS_x86_64.mk | 1 + core/clang/HOST_x86.mk | 1 + core/clang/HOST_x86_64.mk | 1 + core/clang/TARGET_arm.mk | 1 + core/clang/TARGET_arm64.mk | 1 + core/clang/TARGET_x86.mk | 1 + core/clang/TARGET_x86_64.mk | 1 + core/clang/config.mk | 4 ---- core/clear_vars.mk | 1 - core/definitions.mk | 3 +++ core/executable_internal.mk | 6 ++++-- core/shared_library_internal.mk | 3 +++ 15 files changed, 18 insertions(+), 15 deletions(-) diff --git a/core/aux_toolchain.mk b/core/aux_toolchain.mk index de0b139d3..c7102288d 100644 --- a/core/aux_toolchain.mk +++ b/core/aux_toolchain.mk @@ -50,4 +50,3 @@ LOCAL_NO_DEFAULT_COMPILER_FLAGS := true LOCAL_SYSTEM_SHARED_LIBRARIES := LOCAL_CXX_STL := none LOCAL_NO_PIC := true -LOCAL_NO_LIBCOMPILER_RT := true diff --git a/core/binary.mk b/core/binary.mk index 07fb48a50..84a26bc6c 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -396,13 +396,6 @@ endif include $(BUILD_SYSTEM)/config_sanitizers.mk -ifneq ($(LOCAL_NO_LIBCOMPILER_RT),true) -# Add in libcompiler_rt for all regular device builds -ifeq (,$(WITHOUT_LIBCOMPILER_RT)) - my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) -endif -endif - # Statically link libwinpthread when cross compiling win32. ifeq ($($(my_prefix)OS),windows) my_static_libraries += libwinpthread diff --git a/core/clang/HOST_CROSS_x86.mk b/core/clang/HOST_CROSS_x86.mk index ffd78119a..758135355 100644 --- a/core/clang/HOST_CROSS_x86.mk +++ b/core/clang/HOST_CROSS_x86.mk @@ -1 +1,2 @@ $(clang_2nd_arch_prefix)HOST_CROSS_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i386.a +$(clang_2nd_arch_prefix)HOST_CROSS_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.bulitins-i386.a diff --git a/core/clang/HOST_CROSS_x86_64.mk b/core/clang/HOST_CROSS_x86_64.mk index f921a1c1c..9a971c751 100644 --- a/core/clang/HOST_CROSS_x86_64.mk +++ b/core/clang/HOST_CROSS_x86_64.mk @@ -1 +1,2 @@ $(clang_2nd_arch_prefix)HOST_CROSS_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a +$(clang_2nd_arch_prefix)HOST_CROSS_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-x86_64.a diff --git a/core/clang/HOST_x86.mk b/core/clang/HOST_x86.mk index 28035173f..2e0865bbe 100644 --- a/core/clang/HOST_x86.mk +++ b/core/clang/HOST_x86.mk @@ -1 +1,2 @@ $(clang_2nd_arch_prefix)HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i386.a +$(clang_2nd_arch_prefix)HOST_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-i386.a diff --git a/core/clang/HOST_x86_64.mk b/core/clang/HOST_x86_64.mk index 4fdffd844..3fd0541d3 100644 --- a/core/clang/HOST_x86_64.mk +++ b/core/clang/HOST_x86_64.mk @@ -1 +1,2 @@ HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a +HOST_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-x86_64.a diff --git a/core/clang/TARGET_arm.mk b/core/clang/TARGET_arm.mk index 9c1a8368f..6140d7cd2 100644 --- a/core/clang/TARGET_arm.mk +++ b/core/clang/TARGET_arm.mk @@ -3,6 +3,7 @@ $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := $(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := armv7-none-linux-gnueabi $(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-arm-android.a +$(clang_2nd_arch_prefix)TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-arm-android.a # Address sanitizer clang config $(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk index 9a67b6b15..9fe55304b 100644 --- a/core/clang/TARGET_arm64.mk +++ b/core/clang/TARGET_arm64.mk @@ -3,6 +3,7 @@ RS_TRIPLE_CFLAGS := RS_COMPAT_TRIPLE := aarch64-linux-android TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a +TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-aarch64-android.a # Address sanitizer clang config ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64 diff --git a/core/clang/TARGET_x86.mk b/core/clang/TARGET_x86.mk index 1b9c78c91..5e2d57ed7 100644 --- a/core/clang/TARGET_x86.mk +++ b/core/clang/TARGET_x86.mk @@ -3,6 +3,7 @@ $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := -D__i386__ $(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := i686-linux-android $(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686-android.a +$(clang_2nd_arch_prefix)TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-i686-android.a # Address sanitizer clang config $(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan diff --git a/core/clang/TARGET_x86_64.mk b/core/clang/TARGET_x86_64.mk index 3161f8475..86b3798a9 100644 --- a/core/clang/TARGET_x86_64.mk +++ b/core/clang/TARGET_x86_64.mk @@ -3,6 +3,7 @@ RS_TRIPLE_CFLAGS := -D__x86_64__ RS_COMPAT_TRIPLE := x86_64-linux-android TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64-android.a +TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-x86_64-android.a # Address sanitizer clang config ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64 diff --git a/core/clang/config.mk b/core/clang/config.mk index 63582c2c7..5936f6698 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -61,8 +61,4 @@ clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk endif -# This allows us to use the superset of functionality that compiler-rt -# provides to Clang (for supporting features like -ftrapv). -COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras - include $(BUILD_SYSTEM)/clang/tidy.mk diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 34a1db894..3a17604f7 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_LIBCOMPILER_RT:= LOCAL_NO_LIBGCC:= LOCAL_NO_NOTICE_FILE:= LOCAL_NO_PIC:= diff --git a/core/definitions.mk b/core/definitions.mk index 0e959d6e4..eabd4c5d3 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1693,6 +1693,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_ALL_STATIC_LIBRARIES) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ + $(PRIVATE_TARGET_LIBCRT_BUILTINS) \ $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ @@ -1728,6 +1729,7 @@ $(hide) $(PRIVATE_CXX) -pie \ $(PRIVATE_ALL_STATIC_LIBRARIES) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ + $(PRIVATE_TARGET_LIBCRT_BUILTINS) \ $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ @@ -1775,6 +1777,7 @@ $(hide) $(PRIVATE_CXX) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \ $(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) diff --git a/core/executable_internal.mk b/core/executable_internal.mk index 70b2ea882..10ed91322 100644 --- a/core/executable_internal.mk +++ b/core/executable_internal.mk @@ -36,6 +36,7 @@ endif endif # Define PRIVATE_ variables from global vars +my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS) ifeq ($(LOCAL_NO_LIBGCC),true) my_target_libgcc := else @@ -60,6 +61,7 @@ my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynami my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o) 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) @@ -68,11 +70,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_libgcc) $(my_target_libatomic) +$(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) $(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_libgcc) $(my_target_libatomic) +$(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) $(transform-o-to-executable) $(PRIVATE_POST_LINK_CMD) endif diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk index 41e6a95ef..8e2ed3ae4 100644 --- a/core/shared_library_internal.mk +++ b/core/shared_library_internal.mk @@ -34,6 +34,7 @@ ifndef skip_build_from_source include $(BUILD_SYSTEM)/dynamic_binary.mk # Define PRIVATE_ variables from global vars +my_target_libcrt_builtins := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBCRT_BUILTINS) ifeq ($(LOCAL_NO_LIBGCC),true) my_target_libgcc := else @@ -54,6 +55,7 @@ ifneq ($(LOCAL_SDK_VERSION),) 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) @@ -64,6 +66,7 @@ $(linked_module): \ $(all_libraries) \ $(my_target_crtbegin_so_o) \ $(my_target_crtend_so_o) \ + $(my_target_libcrt_builtins) \ $(my_target_libgcc) \ $(my_target_libatomic) \ $(LOCAL_ADDITIONAL_DEPENDENCIES)