From fa049385b89273f8c0ab3cd76e5ff3724265ec6c Mon Sep 17 00:00:00 2001 From: Joel Galenson Date: Thu, 14 Jan 2021 16:03:18 -0800 Subject: Migrate Rust to LLVM coverage. Bug: 177675913 Test: Manually compile, run, and see output with llvm-cov. Change-Id: I66729cff87a848782e9fa1b95cbbc06318c5761a --- rust/coverage.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'rust/coverage.go') diff --git a/rust/coverage.go b/rust/coverage.go index 26375f507..dac526a36 100644 --- a/rust/coverage.go +++ b/rust/coverage.go @@ -20,7 +20,9 @@ import ( "android/soong/cc" ) -var CovLibraryName = "libprofile-extras" +var CovLibraryName = "libprofile-clang-extras" + +const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw" type coverage struct { Properties cc.CoverageProperties @@ -53,9 +55,9 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags flags.Coverage = true coverage := ctx.GetDirectDepWithTag(CovLibraryName, cc.CoverageDepTag).(cc.LinkableInterface) flags.RustFlags = append(flags.RustFlags, - "-Z profile", "-g", "-C opt-level=0", "-C link-dead-code") + "-Z instrument-coverage", "-g", "-C link-dead-code") flags.LinkFlags = append(flags.LinkFlags, - "--coverage", "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,getenv") + profileInstrFlag, "-g", coverage.OutputFile().Path().String(), "-Wl,--wrap,open") deps.StaticLibs = append(deps.StaticLibs, coverage.OutputFile().Path()) } -- cgit v1.2.3-59-g8ed1b