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
This commit is contained in:
Pirama Arumuga Nainar
2018-04-14 01:03:35 -07:00
parent 4884a172de
commit 358056c058
5 changed files with 38 additions and 10 deletions

View File

@@ -40,6 +40,7 @@ func init() {
ctx.BottomUp("ndk_api", ndkApiMutator).Parallel()
ctx.BottomUp("test_per_src", testPerSrcMutator).Parallel()
ctx.BottomUp("begin", beginMutator).Parallel()
ctx.BottomUp("coverage", coverageLinkingMutator).Parallel()
})
android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -54,7 +55,6 @@ func init() {
ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator())
ctx.BottomUp("coverage", coverageLinkingMutator).Parallel()
ctx.TopDown("vndk_deps", sabiDepsMutator)
ctx.TopDown("lto_deps", ltoDepsMutator)
@@ -809,12 +809,15 @@ func (c *Module) deps(ctx DepsContext) Deps {
if c.compiler != nil {
deps = c.compiler.compilerDeps(ctx, deps)
}
// Add the PGO dependency (the clang_rt.profile runtime library), which
// sometimes depends on symbols from libgcc, before libgcc gets added
// in linkerDeps().
// clang_rt.profile runtime libraries necessary for PGO and coverage
// depend on symbols from libgcc. Add the runtime library dependency
// before libgcc gets added in linkerDeps().
if c.pgo != nil {
deps = c.pgo.deps(ctx, deps)
}
if c.coverage != nil {
deps = c.coverage.deps(ctx, deps)
}
if c.linker != nil {
deps = c.linker.linkerDeps(ctx, deps)
}
@@ -824,9 +827,6 @@ func (c *Module) deps(ctx DepsContext) Deps {
if c.sanitize != nil {
deps = c.sanitize.deps(ctx, deps)
}
if c.coverage != nil {
deps = c.coverage.deps(ctx, deps)
}
if c.sabi != nil {
deps = c.sabi.deps(ctx, deps)
}