diff options
author | Joel Galenson <jgalenson@google.com> | 2021-01-14 16:03:18 -0800 |
---|---|---|
committer | Joel Galenson <jgalenson@google.com> | 2021-01-15 19:44:07 +0000 |
commit | fa049385b89273f8c0ab3cd76e5ff3724265ec6c (patch) | |
tree | 0d5449d0fbef8dc3679b588d5609b0c1986dc92b /rust/coverage.go | |
parent | 66f7fdd1c89ad5d0eab631143902f6ee17de6332 (diff) |
Migrate Rust to LLVM coverage.
Bug: 177675913
Test: Manually compile, run, and see output with llvm-cov.
Change-Id: I66729cff87a848782e9fa1b95cbbc06318c5761a
Diffstat (limited to 'rust/coverage.go')
-rw-r--r-- | rust/coverage.go | 8 |
1 files changed, 5 insertions, 3 deletions
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()) } |