diff options
author | Dan Albert <danalbert@google.com> | 2014-09-19 14:25:57 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2014-09-23 15:19:02 -0700 |
commit | 4bbc6c790bd3b0a4894cc844059e73b5721a28fd (patch) | |
tree | b346f99e1a19714f769236eb7dcfbad2df0553b0 /core/combo | |
parent | 98f7742a7f5bdc69913ba5e15bba2e60ae5cf724 (diff) | |
download | build-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')
-rw-r--r-- | core/combo/TARGET_linux-arm.mk | 5 | ||||
-rw-r--r-- | core/combo/TARGET_linux-arm64.mk | 5 | ||||
-rw-r--r-- | core/combo/TARGET_linux-mips.mk | 5 | ||||
-rw-r--r-- | core/combo/TARGET_linux-mips64.mk | 5 | ||||
-rw-r--r-- | core/combo/TARGET_linux-x86.mk | 7 | ||||
-rw-r--r-- | core/combo/TARGET_linux-x86_64.mk | 7 |
6 files changed, 27 insertions, 7 deletions
diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk index c9a34e7..2d7faae 100644 --- a/core/combo/TARGET_linux-arm.mk +++ b/core/combo/TARGET_linux-arm.mk @@ -164,7 +164,7 @@ $(combo_2nd_arch_prefix)TARGET_LIBGCC := $(shell $($(combo_2nd_arch_prefix)TARGE $($(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) \ +$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ -print-file-name=libgcov.a) endif @@ -213,6 +213,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -240,6 +241,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -263,6 +265,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(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)) diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk index 82eb7fd..f0fab7b 100644 --- a/core/combo/TARGET_linux-arm64.mk +++ b/core/combo/TARGET_linux-arm64.mk @@ -131,6 +131,8 @@ 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) +TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ + -print-file-name=libgcov.a) KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH) @@ -177,6 +179,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -204,6 +207,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -227,6 +231,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(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)) diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk index 92ad21a..b260073 100644 --- a/core/combo/TARGET_linux-mips.mk +++ b/core/combo/TARGET_linux-mips.mk @@ -136,7 +136,7 @@ LIBGCC_EH := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_pre ifneq ($(LIBGCC_EH),libgcc_eh.a) $(combo_2nd_arch_prefix)TARGET_LIBGCC += $(LIBGCC_EH) endif -target_libgcov := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ +$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \ --print-file-name=libgcov.a) endif @@ -185,6 +185,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -212,6 +213,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -235,6 +237,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(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)) diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk index 3435814..ef66a73 100644 --- a/core/combo/TARGET_linux-mips64.mk +++ b/core/combo/TARGET_linux-mips64.mk @@ -137,7 +137,7 @@ LIBGCC_EH := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgc ifneq ($(LIBGCC_EH),libgcc_eh.a) TARGET_LIBGCC += $(LIBGCC_EH) endif -target_libgcov := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ +TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \ --print-file-name=libgcov.a) endif @@ -189,6 +189,7 @@ $(hide) $(PRIVATE_CXX) \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -216,6 +217,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bdynamic -pie \ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \ $(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) @@ -239,6 +241,7 @@ $(hide) $(PRIVATE_CXX) -nostdlib -Bstatic \ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(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)) 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)) diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk index 0fb8795..c7a53a6 100644 --- a/core/combo/TARGET_linux-x86_64.mk +++ b/core/combo/TARGET_linux-x86_64.mk @@ -62,8 +62,8 @@ 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) +TARGET_LIBGCOV := \ + $(shell $(TARGET_CC) -m64 -print-file-name=libgcov.a) endif TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined @@ -170,6 +170,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)) endef @@ -196,6 +197,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) @@ -217,6 +219,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)) \ |