summaryrefslogtreecommitdiff
path: root/rust/builder.go
diff options
context:
space:
mode:
author Ivan Lozano <ivanlozano@google.com> 2020-05-20 09:03:20 -0400
committer Matthew Maurer <mmaurer@google.com> 2020-06-11 17:16:27 +0000
commitf3717eec6c526b4f0e985bf6b3dbcc3a51222f5e (patch)
tree7e45d2be1c7e94de7953419c115ce2e6822ec550 /rust/builder.go
parent9e90e61ffdbf1831efb5019d2e9151b45aa001ec (diff)
Match Rust gcda output to cc via -Z profile-emit.
Use the -Z profile-emit flag to ensure that rust gcda files have /proc/self/cwd/ appended to them similar to cc modules. This makes sure our gcda output is consistent no matter what language the binary is written in. Bug: 156482307 Test: gcda outputs to the new path. Change-Id: Ife4d55f885c7e33dffa66f7436bc2bf8b5916586
Diffstat (limited to 'rust/builder.go')
-rw-r--r--rust/builder.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/rust/builder.go b/rust/builder.go
index fbe0e5372..5069b076a 100644
--- a/rust/builder.go
+++ b/rust/builder.go
@@ -21,6 +21,7 @@ import (
"github.com/google/blueprint/pathtools"
"android/soong/android"
+ "android/soong/cc"
)
var (
@@ -161,11 +162,17 @@ func transformSrctoCrate(ctx android.ModuleContext, main android.Path, deps Path
if flags.Coverage {
var gcnoFile android.WritablePath
+ // Provide consistency with cc gcda output, see cc/builder.go init()
+ profileEmitArg := strings.TrimPrefix("PWD=", cc.PwdPrefix()) + "/"
if outputFile.Ext() != "" {
gcnoFile = android.PathForModuleOut(ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcno"))
+ rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut(
+ ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcda")).String())
} else {
gcnoFile = android.PathForModuleOut(ctx, outputFile.Base()+".gcno")
+ rustcFlags = append(rustcFlags, "-Z profile-emit="+profileEmitArg+android.PathForModuleOut(
+ ctx, outputFile.Base()+".gcda").String())
}
implicitOutputs = append(implicitOutputs, gcnoFile)