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
This commit is contained in:
committed by
Matthew Maurer
parent
9e90e61ffd
commit
f3717eec6c
@@ -283,16 +283,19 @@ var (
|
|||||||
"cFlags")
|
"cFlags")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func PwdPrefix() string {
|
||||||
|
// Darwin doesn't have /proc
|
||||||
|
if runtime.GOOS != "darwin" {
|
||||||
|
return "PWD=/proc/self/cwd"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// We run gcc/clang with PWD=/proc/self/cwd to remove $TOP from the
|
// 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
|
// debug output. That way two builds in two different directories will
|
||||||
// create the same output.
|
// create the same output.
|
||||||
if runtime.GOOS != "darwin" {
|
pctx.StaticVariable("relPwd", PwdPrefix())
|
||||||
pctx.StaticVariable("relPwd", "PWD=/proc/self/cwd")
|
|
||||||
} else {
|
|
||||||
// Darwin doesn't have /proc
|
|
||||||
pctx.StaticVariable("relPwd", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
|
||||||
pctx.Import("android/soong/remoteexec")
|
pctx.Import("android/soong/remoteexec")
|
||||||
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/google/blueprint/pathtools"
|
"github.com/google/blueprint/pathtools"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
"android/soong/cc"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -161,11 +162,17 @@ func transformSrctoCrate(ctx android.ModuleContext, main android.Path, deps Path
|
|||||||
|
|
||||||
if flags.Coverage {
|
if flags.Coverage {
|
||||||
var gcnoFile android.WritablePath
|
var gcnoFile android.WritablePath
|
||||||
|
// Provide consistency with cc gcda output, see cc/builder.go init()
|
||||||
|
profileEmitArg := strings.TrimPrefix("PWD=", cc.PwdPrefix()) + "/"
|
||||||
|
|
||||||
if outputFile.Ext() != "" {
|
if outputFile.Ext() != "" {
|
||||||
gcnoFile = android.PathForModuleOut(ctx, pathtools.ReplaceExtension(outputFile.Base(), "gcno"))
|
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 {
|
} else {
|
||||||
gcnoFile = android.PathForModuleOut(ctx, outputFile.Base()+".gcno")
|
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)
|
implicitOutputs = append(implicitOutputs, gcnoFile)
|
||||||
|
Reference in New Issue
Block a user