diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2018-04-14 01:03:35 -0700 |
---|---|---|
committer | Pirama Arumuga Nainar <pirama@google.com> | 2018-04-23 10:34:37 -0700 |
commit | 358056c058e43bfb2bbae8978fbfe4a8e4c84fb5 (patch) | |
tree | b1a42e94fec59b8693a2a89dac731b19672806d5 /cc/coverage.go | |
parent | 4884a172de66ce5491ba07f7f948014159eec9cc (diff) | |
download | android_build_soong-358056c058e43bfb2bbae8978fbfe4a8e4c84fb5.tar.gz android_build_soong-358056c058e43bfb2bbae8978fbfe4a8e4c84fb5.tar.bz2 android_build_soong-358056c058e43bfb2bbae8978fbfe4a8e4c84fb5.zip |
Support coverage instrumentation for Linux host
Bug: http://b/77792074
- Add the libclang_rt.profile runtime libraries directly to the compile
command (for both host and target) instead of relying on the Clang
driver.
- Move the coverage mutator to PreDepsMutators so the mutation has
already happened when runtime libraries are added during dependence
computation.
- Factor out cc/config/toolchain to identify libclang_rt.profile modules
for the x86 and x86_64 host.
Test: make NATIVE_COVERAGE=true produces coverage-enabled host binaries.
Change-Id: I1ebc8cffdf11622bfc18199a57674672888b3a5f
Diffstat (limited to 'cc/coverage.go')
-rw-r--r-- | cc/coverage.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cc/coverage.go b/cc/coverage.go index 391b1181..671353c9 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -16,6 +16,7 @@ package cc import ( "android/soong/android" + "android/soong/cc/config" ) type CoverageProperties struct { @@ -38,6 +39,10 @@ func (cov *coverage) props() []interface{} { func (cov *coverage) begin(ctx BaseModuleContext) {} func (cov *coverage) deps(ctx BaseModuleContext, deps Deps) Deps { + if cov.Properties.CoverageEnabled { + runtimeLibrary := config.ProfileRuntimeLibrary(ctx.toolchain()) + deps.LateStaticLibs = append(deps.LateStaticLibs, runtimeLibrary) + } return deps } @@ -99,9 +104,8 @@ func coverageLinkingMutator(mctx android.BottomUpMutatorContext) { if !mctx.DeviceConfig().NativeCoverageEnabled() { // Coverage is disabled globally - } else if mctx.Host() { - // TODO(dwillemsen): because of -nodefaultlibs, we must depend on libclang_rt.profile-*.a - // Just turn off for now. + } else if mctx.Darwin() || mctx.Windows() { + // Coverage not supported for Darwin and Windows } else if c.coverage.Properties.Native_coverage != nil { enabled = *c.coverage.Properties.Native_coverage } else { |