From 0c87f3d733f289978dd2fa6fd4df324a52f0a4f4 Mon Sep 17 00:00:00 2001 From: Andrew Hsieh Date: Thu, 29 May 2014 02:47:27 -0700 Subject: [PATCH] Add -latomic to all target builds Projects using stdatomic.h needs libatomic.a in case compiler can't expand all __atomic* intrinsics. eg, __atomic_is_lock_free in armeabi/mips. Adding libatomic.a globally makes more sense than adding "LOCAL_LDLIB += -latomic " in each project including . Projects don't need atomic operations won't get redundant DT_NEEDED entry because libatomic.a is not a shared library. Change-Id: I81dbf524544c848e667e18ab5eeabff75b5063ef --- core/combo/TARGET_linux-arm.mk | 5 +++++ core/combo/TARGET_linux-arm64.mk | 5 +++++ core/combo/TARGET_linux-mips.mk | 5 +++++ core/combo/TARGET_linux-mips64.mk | 5 +++++ core/combo/TARGET_linux-x86.mk | 5 +++++ core/combo/TARGET_linux-x86_64.mk | 5 +++++ core/executable_internal.mk | 2 ++ core/shared_library_internal.mk | 2 ++ 8 files changed, 34 insertions(+) diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index d882ea67c..e3491c0ea 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -162,6 +162,8 @@ ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),) # 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) target_libgcov := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ -print-file-name=libgcov.a) endif @@ -240,6 +242,7 @@ $(hide) $(PRIVATE_CXX) \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \ $(PRIVATE_LDLIBS) @@ -266,6 +269,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \ $(PRIVATE_LDLIBS) @@ -288,6 +292,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(PRIVATE_TARGET_FDO_LIB) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk index 9518ba7da..3cd4fb829 100644 --- a/core/combo/TARGET_linux-arm64.mk +++ b/core/combo/TARGET_linux-arm64.mk @@ -132,6 +132,8 @@ libstdc++_root := bionic/libstdc++ 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) KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH) @@ -178,6 +180,7 @@ $(hide) $(PRIVATE_CXX) \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \ $(PRIVATE_LDLIBS) @@ -204,6 +207,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \ $(PRIVATE_LDLIBS) @@ -226,6 +230,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(PRIVATE_TARGET_FDO_LIB) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk index 015d46b8c..8826ce200 100644 --- a/core/combo/TARGET_linux-mips.mk +++ b/core/combo/TARGET_linux-mips.mk @@ -149,6 +149,8 @@ ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),) # 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) @@ -231,6 +233,7 @@ $(hide) $(PRIVATE_CXX) \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \ $(PRIVATE_LDLIBS) @@ -257,6 +260,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \ $(PRIVATE_LDLIBS) @@ -279,6 +283,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(PRIVATE_TARGET_FDO_LIB) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk index a7b03b2fc..969aff805 100644 --- a/core/combo/TARGET_linux-mips64.mk +++ b/core/combo/TARGET_linux-mips64.mk @@ -155,6 +155,8 @@ ifneq ($(wildcard $(TARGET_CC)),) # 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) @@ -240,6 +242,7 @@ $(hide) $(PRIVATE_CXX) \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \ $(PRIVATE_LDLIBS) @@ -266,6 +269,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -fPIE -pie \ -o $@ \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \ $(PRIVATE_LDLIBS) @@ -288,6 +292,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(PRIVATE_TARGET_FDO_LIB) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk index 4ebcd9329..323290a54 100644 --- a/core/combo/TARGET_linux-x86.mk +++ b/core/combo/TARGET_linux-x86.mk @@ -60,6 +60,8 @@ $(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_P 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) target_libgcov := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ -print-file-name=libgcov.a) endif @@ -195,6 +197,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -o $@ \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \ $(PRIVATE_LDLIBS) @@ -221,6 +224,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -o $@ \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \ $(PRIVATE_LDLIBS) @@ -241,6 +245,7 @@ $(hide) $(PRIVATE_CXX) \ -Wl,--start-group \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(PRIVATE_TARGET_FDO_LIB) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk index ee6c6e2e2..bd656e9f0 100644 --- a/core/combo/TARGET_linux-x86_64.mk +++ b/core/combo/TARGET_linux-x86_64.mk @@ -62,6 +62,8 @@ TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip$(HOST_EXECUTABLE_SUFFIX) 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) $(TARGET_GLOBAL_CFLAGS) \ -print-file-name=libgcov.a) endif @@ -200,6 +202,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -o $@ \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) endef @@ -225,6 +228,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -o $@ \ $(PRIVATE_LDFLAGS) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \ $(PRIVATE_LDLIBS) @@ -245,6 +249,7 @@ $(hide) $(PRIVATE_CXX) \ -Wl,--start-group \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(PRIVATE_TARGET_FDO_LIB) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ $(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \ diff --git a/core/executable_internal.mk b/core/executable_internal.mk index c235a7295..2e380b62e 100644 --- a/core/executable_internal.mk +++ b/core/executable_internal.mk @@ -30,6 +30,7 @@ include $(BUILD_SYSTEM)/dynamic_binary.mk my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) my_target_fdo_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LIB) my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) +my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_DYNAMIC_O) my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_STATIC_O) my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_O) @@ -49,6 +50,7 @@ $(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) $(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) $(linked_module): PRIVATE_TARGET_FDO_LIB := $(my_target_fdo_lib) $(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) $(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o) diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk index bda44f407..abef11fe5 100644 --- a/core/shared_library_internal.mk +++ b/core/shared_library_internal.mk @@ -42,6 +42,7 @@ include $(BUILD_SYSTEM)/dynamic_binary.mk my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) my_target_fdo_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_LIB) my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) +my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_SO_O) my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_SO_O) ifdef LOCAL_SDK_VERSION @@ -59,6 +60,7 @@ $(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs) $(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) $(linked_module): PRIVATE_TARGET_FDO_LIB := $(my_target_fdo_lib) $(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)