From 343ed674e35ae0911542abe67dca3fb3a1cccf95 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 25 Jan 2015 16:20:57 -0800 Subject: [PATCH] Use prebuilt libclang_rt.profile. Bug: 17574078 Change-Id: I4838cd5d125a0b2bf76aad2fdaef1ee3122687e8 --- core/binary.mk | 24 +++++++----------------- core/clang/HOST_x86.mk | 2 ++ core/clang/HOST_x86_64.mk | 2 ++ core/clang/TARGET_arm.mk | 2 ++ core/clang/TARGET_arm64.mk | 2 ++ core/clang/TARGET_mips.mk | 2 ++ core/clang/TARGET_mips64.mk | 2 ++ core/clang/TARGET_x86.mk | 2 ++ core/clang/TARGET_x86_64.mk | 2 ++ core/clang/config.mk | 1 + core/combo/HOST_linux-x86.mk | 1 - core/definitions.mk | 7 ++++++- core/executable_internal.mk | 2 ++ core/host_executable_internal.mk | 3 +++ core/host_shared_library_internal.mk | 3 +++ core/shared_library_internal.mk | 2 ++ 16 files changed, 40 insertions(+), 19 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index 92b08faca..15d5d1e5c 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -294,24 +294,14 @@ endif # LOCAL_IS_HOST_MODULE # clean build of your module after toggling it. ifeq ($(NATIVE_COVERAGE),true) ifeq ($(my_native_coverage),true) + # Note that clang coverage doesn't play nicely with acov out of the box. + # Clang apparently generates .gcno files that aren't compatible with + # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov + # with `--gcov-tool /usr/bin/gcov-4.6`. + # + # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output my_cflags += --coverage -O0 - ifeq ($(my_clang),true) - # b/17574078 - # We currently don't have a prebuilt libclang_rt.profile-.a, - # which clang is hardcoded to link if --coverage is passed in the - # link stage. For now we manually link libprofile_rt (which is the - # name it is built as from external/compiler-rt). - # - # Note that clang coverage doesn't play nicely with acov out of the - # box. Clang apparently generates .gcno files that aren't compatible - # with gcov-4.8. This can be solved by installing gcc-4.6 and - # invoking lcov with `--gcov-tool /usr/bin/gcov-4.6`. - # - # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output - my_static_libraries += libprofile_rt - else - my_ldflags += --coverage - endif + my_ldflags += --coverage endif else my_native_coverage := false diff --git a/core/clang/HOST_x86.mk b/core/clang/HOST_x86.mk index 35cfe60de..f14a9c32f 100644 --- a/core/clang/HOST_x86.mk +++ b/core/clang/HOST_x86.mk @@ -76,3 +76,5 @@ $(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CPPFLAGS := \ $(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_LDFLAGS := \ $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS)) \ $(CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS) + +$(clang_2nd_arch_prefix)HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686.a diff --git a/core/clang/HOST_x86_64.mk b/core/clang/HOST_x86_64.mk index c546715e9..1211e7381 100644 --- a/core/clang/HOST_x86_64.mk +++ b/core/clang/HOST_x86_64.mk @@ -76,3 +76,5 @@ CLANG_HOST_GLOBAL_CPPFLAGS := \ CLANG_HOST_GLOBAL_LDFLAGS := \ $(call convert-to-host-clang-flags,$(HOST_GLOBAL_LDFLAGS)) \ $(CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS) + +HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a diff --git a/core/clang/TARGET_arm.mk b/core/clang/TARGET_arm.mk index 993755fbf..6f6d6246c 100644 --- a/core/clang/TARGET_arm.mk +++ b/core/clang/TARGET_arm.mk @@ -64,3 +64,5 @@ $(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \ $(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi $(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 diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk index ba6e5f1fa..b67d45882 100644 --- a/core/clang/TARGET_arm64.mk +++ b/core/clang/TARGET_arm64.mk @@ -62,3 +62,5 @@ CLANG_TARGET_GLOBAL_LDFLAGS := \ RS_TRIPLE := aarch64-linux-android RS_TRIPLE_CFLAGS := RS_COMPAT_TRIPLE := aarch64-linux-android + +TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a diff --git a/core/clang/TARGET_mips.mk b/core/clang/TARGET_mips.mk index 236018175..19bbaf2e2 100644 --- a/core/clang/TARGET_mips.mk +++ b/core/clang/TARGET_mips.mk @@ -63,3 +63,5 @@ $(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \ $(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi $(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := RS_COMPAT_TRIPLE := mipsel-linux-android + +$(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-mipsel-android.a diff --git a/core/clang/TARGET_mips64.mk b/core/clang/TARGET_mips64.mk index 742be4be2..104fb7021 100644 --- a/core/clang/TARGET_mips64.mk +++ b/core/clang/TARGET_mips64.mk @@ -62,3 +62,5 @@ CLANG_TARGET_GLOBAL_LDFLAGS := \ RS_TRIPLE := aarch64-linux-android RS_TRIPLE_CFLAGS := RS_COMPAT_TRIPLE := mips64el-linux-android + +TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-mips64el-android.a diff --git a/core/clang/TARGET_x86.mk b/core/clang/TARGET_x86.mk index 3ba34ae79..4e9e8be3a 100644 --- a/core/clang/TARGET_x86.mk +++ b/core/clang/TARGET_x86.mk @@ -72,3 +72,5 @@ $(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \ $(clang_2nd_arch_prefix)RS_TRIPLE := armv7-none-linux-gnueabi $(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 diff --git a/core/clang/TARGET_x86_64.mk b/core/clang/TARGET_x86_64.mk index 9f8e8b062..e44382dcb 100644 --- a/core/clang/TARGET_x86_64.mk +++ b/core/clang/TARGET_x86_64.mk @@ -62,3 +62,5 @@ CLANG_TARGET_GLOBAL_LDFLAGS := \ RS_TRIPLE := aarch64-linux-android 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 diff --git a/core/clang/config.mk b/core/clang/config.mk index 60889e775..ba48f6352 100644 --- a/core/clang/config.mk +++ b/core/clang/config.mk @@ -8,6 +8,7 @@ endif LLVM_PREBUILTS_VERSION := 3.6 LLVM_PREBUILTS_PATH := prebuilts/clang/$(BUILD_OS)-x86/host/$(LLVM_PREBUILTS_VERSION)/bin +LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib/clang/$(LLVM_PREBUILTS_VERSION)/lib/linux/ CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk index 93a1287f9..5f6240052 100644 --- a/core/combo/HOST_linux-x86.mk +++ b/core/combo/HOST_linux-x86.mk @@ -49,7 +49,6 @@ $(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CO $(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined - ############################################################ ## Macros after this line are shared by the 64-bit config. diff --git a/core/definitions.mk b/core/definitions.mk index c601d862d..d7aa477e8 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1367,6 +1367,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \ + $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -o $@ \ $(PRIVATE_LDLIBS) @@ -1405,6 +1406,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \ + $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBPROFILE_RT)) \ $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ @@ -1468,6 +1470,7 @@ $(hide) $(PRIVATE_CXX) -pie \ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \ + $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBPROFILE_RT)) \ $(PRIVATE_TARGET_LIBATOMIC) \ $(PRIVATE_TARGET_LIBGCC) \ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ @@ -1513,8 +1516,9 @@ $(hide) $(PRIVATE_CXX) \ -Wl,--start-group \ $(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_LIBATOMIC) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \ + $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBPROFILE_RT)) \ + $(PRIVATE_TARGET_LIBATOMIC) \ $(call normalize-target-libraries,$(filter %libcompiler_rt.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \ $(PRIVATE_TARGET_LIBGCC) \ -Wl,--end-group \ @@ -1552,6 +1556,7 @@ $(hide) $(PRIVATE_CXX) \ $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \ $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \ + $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES) \ -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ diff --git a/core/executable_internal.mk b/core/executable_internal.mk index ebb686753..2684d514c 100644 --- a/core/executable_internal.mk +++ b/core/executable_internal.mk @@ -35,6 +35,7 @@ endif # Define PRIVATE_ variables from global vars my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) +my_target_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT) my_target_libgcov := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV) my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) @@ -55,6 +56,7 @@ my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o) endif $(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_LIBPROFILE_RT := $(my_target_libprofile_rt) $(linked_module): PRIVATE_TARGET_LIBGCOV := $(my_target_libgcov) $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic) diff --git a/core/host_executable_internal.mk b/core/host_executable_internal.mk index ffb35d2a1..0c0ac3d91 100644 --- a/core/host_executable_internal.mk +++ b/core/host_executable_internal.mk @@ -27,6 +27,9 @@ ifndef skip_build_from_source include $(BUILD_SYSTEM)/binary.mk +my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_LIBPROFILE_RT) +$(LOCAL_BUILT_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt) + $(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries) $(transform-host-o-to-executable) diff --git a/core/host_shared_library_internal.mk b/core/host_shared_library_internal.mk index f1b3311ec..645098a60 100644 --- a/core/host_shared_library_internal.mk +++ b/core/host_shared_library_internal.mk @@ -40,6 +40,9 @@ OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIAT include $(BUILD_SYSTEM)/binary.mk +my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)HOST_LIBPROFILE_RT) +$(LOCAL_BUILD_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt) + $(LOCAL_BUILT_MODULE): \ $(all_objects) \ $(all_libraries) \ diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk index 1fda7942b..2487fbb02 100644 --- a/core/shared_library_internal.mk +++ b/core/shared_library_internal.mk @@ -40,6 +40,7 @@ include $(BUILD_SYSTEM)/dynamic_binary.mk # Define PRIVATE_ variables from global vars my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS) +my_target_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT) my_target_libgcov := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV) my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC) my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC) @@ -58,6 +59,7 @@ my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o) endif $(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_LIBPROFILE_RT := $(my_target_libprofile_rt) $(linked_module): PRIVATE_TARGET_LIBGCOV := $(my_target_libgcov) $(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc) $(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)