Merge "Enable memory-mapped coverage instrumentation" am: 6609484961
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1729633 Change-Id: I26d495298c4273e8000e17f70ad6d3537a680b48
This commit is contained in:
commit
74eb07ae42
2 changed files with 17 additions and 0 deletions
|
@ -22,6 +22,7 @@ import (
|
|||
"android/soong/android"
|
||||
)
|
||||
|
||||
// Add '%c' to default specifier after we resolve http://b/210012154
|
||||
const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw"
|
||||
|
||||
type CoverageProperties struct {
|
||||
|
@ -77,6 +78,11 @@ func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps {
|
|||
return deps
|
||||
}
|
||||
|
||||
func EnableContinuousCoverage(ctx android.BaseModuleContext) bool {
|
||||
// http://b/210012154 Disable continuous coverage if we're instrumenting bionic/libc.
|
||||
return !ctx.DeviceConfig().NativeCoverageEnabledForPath("bionic/libc")
|
||||
}
|
||||
|
||||
func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) {
|
||||
clangCoverage := ctx.DeviceConfig().ClangCoverageEnabled()
|
||||
gcovCoverage := ctx.DeviceConfig().GcovCoverageEnabled()
|
||||
|
@ -98,6 +104,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
|
|||
} else if clangCoverage {
|
||||
flags.Local.CommonFlags = append(flags.Local.CommonFlags, profileInstrFlag,
|
||||
"-fcoverage-mapping", "-Wno-pass-failed", "-D__ANDROID_CLANG_COVERAGE__")
|
||||
if EnableContinuousCoverage(ctx) {
|
||||
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-runtime-counter-relocation")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,6 +158,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
|
|||
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
|
||||
} else if clangCoverage {
|
||||
flags.Local.LdFlags = append(flags.Local.LdFlags, profileInstrFlag)
|
||||
if EnableContinuousCoverage(ctx) {
|
||||
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm=-runtime-counter-relocation")
|
||||
}
|
||||
|
||||
coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
|
||||
deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())
|
||||
|
|
|
@ -22,6 +22,7 @@ import (
|
|||
|
||||
var CovLibraryName = "libprofile-clang-extras"
|
||||
|
||||
// Add '%c' to default specifier after we resolve http://b/210012154
|
||||
const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw"
|
||||
|
||||
type coverage struct {
|
||||
|
@ -70,6 +71,10 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
|
|||
"-Wl,-z,nostart-stop-gc",
|
||||
)
|
||||
deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path())
|
||||
if cc.EnableContinuousCoverage(ctx) {
|
||||
flags.RustFlags = append(flags.RustFlags, "-C llvm-args=--runtime-counter-relocation")
|
||||
flags.LinkFlags = append(flags.LinkFlags, "-Wl,-mllvm,-runtime-counter-relocation")
|
||||
}
|
||||
}
|
||||
|
||||
return flags, deps
|
||||
|
|
Loading…
Reference in a new issue