Loading android/config.go +4 −0 Original line number Diff line number Diff line Loading @@ -1256,6 +1256,10 @@ func (c *deviceConfig) ClangCoverageEnabled() bool { return Bool(c.config.productVariables.ClangCoverage) } func (c *deviceConfig) ClangCoverageContinuousMode() bool { return Bool(c.config.productVariables.ClangCoverageContinuousMode) } func (c *deviceConfig) GcovCoverageEnabled() bool { return Bool(c.config.productVariables.GcovCoverage) } Loading android/variable.go +5 −4 Original line number Diff line number Diff line Loading @@ -310,6 +310,7 @@ type productVariables struct { ClangCoverage *bool `json:",omitempty"` NativeCoveragePaths []string `json:",omitempty"` NativeCoverageExcludePaths []string `json:",omitempty"` ClangCoverageContinuousMode *bool `json:",omitempty"` // Set by NewConfig Native_coverage *bool `json:",omitempty"` Loading cc/coverage.go +10 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,10 @@ func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps { return deps } func EnableContinuousCoverage(ctx android.BaseModuleContext) bool { return ctx.DeviceConfig().ClangCoverageContinuousMode() } func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) { clangCoverage := ctx.DeviceConfig().ClangCoverageEnabled() gcovCoverage := ctx.DeviceConfig().GcovCoverageEnabled() Loading @@ -101,6 +105,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags // Override -Wframe-larger-than. We can expect frame size increase after // coverage instrumentation. flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-frame-larger-than=") if EnableContinuousCoverage(ctx) { flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-runtime-counter-relocation") } } } Loading Loading @@ -152,6 +159,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()) Loading rust/coverage.go +5 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -59,6 +60,10 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags flags.LinkFlags = append(flags.LinkFlags, profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open") 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 Loading
android/config.go +4 −0 Original line number Diff line number Diff line Loading @@ -1256,6 +1256,10 @@ func (c *deviceConfig) ClangCoverageEnabled() bool { return Bool(c.config.productVariables.ClangCoverage) } func (c *deviceConfig) ClangCoverageContinuousMode() bool { return Bool(c.config.productVariables.ClangCoverageContinuousMode) } func (c *deviceConfig) GcovCoverageEnabled() bool { return Bool(c.config.productVariables.GcovCoverage) } Loading
android/variable.go +5 −4 Original line number Diff line number Diff line Loading @@ -310,6 +310,7 @@ type productVariables struct { ClangCoverage *bool `json:",omitempty"` NativeCoveragePaths []string `json:",omitempty"` NativeCoverageExcludePaths []string `json:",omitempty"` ClangCoverageContinuousMode *bool `json:",omitempty"` // Set by NewConfig Native_coverage *bool `json:",omitempty"` Loading
cc/coverage.go +10 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,10 @@ func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps { return deps } func EnableContinuousCoverage(ctx android.BaseModuleContext) bool { return ctx.DeviceConfig().ClangCoverageContinuousMode() } func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) { clangCoverage := ctx.DeviceConfig().ClangCoverageEnabled() gcovCoverage := ctx.DeviceConfig().GcovCoverageEnabled() Loading @@ -101,6 +105,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags // Override -Wframe-larger-than. We can expect frame size increase after // coverage instrumentation. flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-frame-larger-than=") if EnableContinuousCoverage(ctx) { flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-runtime-counter-relocation") } } } Loading Loading @@ -152,6 +159,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()) Loading
rust/coverage.go +5 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading Loading @@ -59,6 +60,10 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags flags.LinkFlags = append(flags.LinkFlags, profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open") 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