Use a versioned profile file if available
Bug: http://b/74395273 Update profile-search logic to look for profile files named <profile_file>.<arbitrary-version> in the profileProject and use that if available. This works around an issue where ccache serves stale cache entries when the profile file has changed. Test: touch toolchain/pgo-profiles/art/dex2oat.profdata.foo and check it gets used. Change-Id: I3de095c263b952cede25af7d0b63dc7280914d76
This commit is contained in:
parent
e9b02776f4
commit
8aed42c798
1 changed files with 24 additions and 1 deletions
25
cc/pgo.go
25
cc/pgo.go
|
@ -16,6 +16,7 @@ package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
@ -100,12 +101,34 @@ func (props *PgoProperties) addProfileGatherFlags(ctx ModuleContext, flags Flags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.OptionalPath {
|
func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.OptionalPath {
|
||||||
|
profile_file := *props.Pgo.Profile_file
|
||||||
|
|
||||||
// Test if the profile_file is present in any of the PGO profile projects
|
// Test if the profile_file is present in any of the PGO profile projects
|
||||||
for _, profileProject := range getPgoProfileProjects(ctx.DeviceConfig()) {
|
for _, profileProject := range getPgoProfileProjects(ctx.DeviceConfig()) {
|
||||||
path := android.ExistentPathForSource(ctx, profileProject, *props.Pgo.Profile_file)
|
// Bug: http://b/74395273 If the profile_file is unavailable,
|
||||||
|
// use a versioned file named
|
||||||
|
// <profile_file>.<arbitrary-version> when available. This
|
||||||
|
// works around an issue where ccache serves stale cache
|
||||||
|
// entries when the profile file has changed.
|
||||||
|
globPattern := filepath.Join(profileProject, profile_file+".*")
|
||||||
|
versioned_profiles, err := ctx.GlobWithDeps(globPattern, nil)
|
||||||
|
if err != nil {
|
||||||
|
ctx.ModuleErrorf("glob: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
path := android.ExistentPathForSource(ctx, profileProject, profile_file)
|
||||||
if path.Valid() {
|
if path.Valid() {
|
||||||
|
if len(versioned_profiles) != 0 {
|
||||||
|
ctx.PropertyErrorf("pgo.profile_file", "Profile_file has multiple versions: "+filepath.Join(profileProject, profile_file)+", "+strings.Join(versioned_profiles, ", "))
|
||||||
|
}
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(versioned_profiles) > 1 {
|
||||||
|
ctx.PropertyErrorf("pgo.profile_file", "Profile_file has multiple versions: "+strings.Join(versioned_profiles, ", "))
|
||||||
|
} else if len(versioned_profiles) == 1 {
|
||||||
|
return android.OptionalPathForPath(android.PathForSource(ctx, versioned_profiles[0]))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record that this module's profile file is absent
|
// Record that this module's profile file is absent
|
||||||
|
|
Loading…
Reference in a new issue