Merge "Match Rust gcda output to cc via -Z profile-emit." am: f094f1c313 am: 78599c2cc5

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1329395

Change-Id: I66ee99afb22cc1147aed07703e9bcf2add77e010
This commit is contained in:
Ivan Lozano 2020-06-13 02:51:23 +00:00 committed by Automerger Merge Worker
commit 7f108c9ae3
2 changed files with 16 additions and 6 deletions

View File

@ -283,16 +283,19 @@ var (
"cFlags")
)
func PwdPrefix() string {
// Darwin doesn't have /proc
if runtime.GOOS != "darwin" {
return "PWD=/proc/self/cwd"
}
return ""
}
func init() {
// We run gcc/clang with PWD=/proc/self/cwd to remove $TOP from the
// debug output. That way two builds in two different directories will
// create the same output.
if runtime.GOOS != "darwin" {
pctx.StaticVariable("relPwd", "PWD=/proc/self/cwd")
} else {
// Darwin doesn't have /proc
pctx.StaticVariable("relPwd", "")
}
pctx.StaticVariable("relPwd", PwdPrefix())
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
pctx.Import("android/soong/remoteexec")

View File

@ -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)