summaryrefslogtreecommitdiffstats
path: root/core/combo/TARGET_linux-x86.mk
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2014-09-19 14:25:57 -0700
committerDan Albert <danalbert@google.com>2014-09-23 15:19:02 -0700
commit4bbc6c790bd3b0a4894cc844059e73b5721a28fd (patch)
treeb346f99e1a19714f769236eb7dcfbad2df0553b0 /core/combo/TARGET_linux-x86.mk
parent98f7742a7f5bdc69913ba5e15bba2e60ae5cf724 (diff)
downloadbuild-4bbc6c790bd3b0a4894cc844059e73b5721a28fd.zip
build-4bbc6c790bd3b0a4894cc844059e73b5721a28fd.tar.gz
build-4bbc6c790bd3b0a4894cc844059e73b5721a28fd.tar.bz2
Add option for generating coverage info.
To enable building with coverage, the environment variable NATIVE_COVERAGE must be set to true. Set `LOCAL_NATIVE_COVERAGE := true` to generate coverage information for a given component. This is currently not supported for clang (b/17574078, b/17583330). If static library A is included in a binary B (dynamic or static executable, or shared library), and A is built with coverage information, B is required to link with libgcov.a. Since the make does not offer a good way to track this dependency, link libgcov.a even if LOCAL_NATIVE_COVERAGE is not set (but still guarded by NATIVE_COVERAGE). This ensures that all of the libgcov dependencies will always be resolved, and causes no change in the resulting binary if coverage is not used. Bug: 10134489 Change-Id: Id5a19f2c215e4be80e6eae27ecc19b582f2f6813
Diffstat (limited to 'core/combo/TARGET_linux-x86.mk')
-rw-r--r--core/combo/TARGET_linux-x86.mk7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
index 6e5f5ac..ef37de0 100644
--- a/core/combo/TARGET_linux-x86.mk
+++ b/core/combo/TARGET_linux-x86.mk
@@ -62,8 +62,8 @@ $(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)
+$(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
@@ -165,6 +165,7 @@ $(hide) $(PRIVATE_CXX) \
-o $@ \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_TARGET_LIBATOMIC) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \
$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_SO_O)) \
$(PRIVATE_LDLIBS)
@@ -192,6 +193,7 @@ $(hide) $(PRIVATE_CXX) \
-o $@ \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_TARGET_LIBATOMIC) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \
$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O)) \
$(PRIVATE_LDLIBS)
@@ -213,6 +215,7 @@ $(hide) $(PRIVATE_CXX) \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(PRIVATE_TARGET_FDO_LIB) \
$(PRIVATE_TARGET_LIBATOMIC) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_LIBGCOV)) \
$(if $(PRIVATE_LIBCXX),,$(PRIVATE_TARGET_LIBGCC)) \
-Wl,--end-group \
$(if $(filter true,$(PRIVATE_NO_CRT)),,$(PRIVATE_TARGET_CRTEND_O))