[cc/coverage] Pass directory to -fprofile-instr-generate

Bug: http://b/157081822

This will be used if LLVM_PROFILE_FILE is not set at runtime.  Some
bionic tests are run without LLVM_PROFILE_FILE set and if they are run
from '/', they fail unable to write to '/default.profraw'.  This may
affect other tests as well.  Setting this to the value defined by
init.rc.

Test: Enable coverage for bionic, ensure relevant bionic-unit-tests
pass.

Change-Id: If1d0e16ce003149fb21d5472d10699ef6582e065
This commit is contained in:
Pirama Arumuga Nainar 2020-08-05 10:08:30 -07:00
parent 9eb51fc9d4
commit f45e152e15
1 changed files with 4 additions and 2 deletions

View File

@ -22,6 +22,8 @@ import (
"android/soong/android"
)
const profileInstrFlag = "-fprofile-instr-generate=/data/misc/trace/clang-%p-%m.profraw"
type CoverageProperties struct {
Native_coverage *bool
@ -92,7 +94,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
// flags that the module may use.
flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-frame-larger-than=", "-O0")
} else if clangCoverage {
flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-fprofile-instr-generate", "-fcoverage-mapping", "-Wno-pass-failed")
flags.Local.CommonFlags = append(flags.Local.CommonFlags, profileInstrFlag, "-fcoverage-mapping", "-Wno-pass-failed")
}
}
@ -139,7 +141,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv")
} else if clangCoverage {
flags.Local.LdFlags = append(flags.Local.LdFlags, "-fprofile-instr-generate")
flags.Local.LdFlags = append(flags.Local.LdFlags, profileInstrFlag)
coverage := ctx.GetDirectDepWithTag(getClangProfileLibraryName(ctx), CoverageDepTag).(*Module)
deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path())