mirror of https://github.com/golang/go.git
cmd/go: keep BuildInfo list sorted even with -pgo
The -pgo build setting is added late, so sort it into place. Noticed while working on CL 504536. Change-Id: I080d2389dc0b3176fb72c9e2434e5f3ae70e294e Reviewed-on: https://go-review.googlesource.com/c/go/+/504537 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
c14655da98
commit
faa549e4c7
|
|
@ -2387,10 +2387,10 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
|
|||
appendSetting("-ldflags", ldflags)
|
||||
}
|
||||
}
|
||||
// N.B. -pgo added later by setPGOProfilePath.
|
||||
if cfg.BuildMSan {
|
||||
appendSetting("-msan", "true")
|
||||
}
|
||||
// N.B. -pgo added later by setPGOProfilePath.
|
||||
if cfg.BuildRace {
|
||||
appendSetting("-race", "true")
|
||||
}
|
||||
|
|
@ -2928,6 +2928,10 @@ func setPGOProfilePath(pkgs []*Package) {
|
|||
} else {
|
||||
appendBuildSetting(p.Internal.BuildInfo, "-pgo", file)
|
||||
}
|
||||
// Adding -pgo breaks the sort order in BuildInfo.Settings. Restore it.
|
||||
slices.SortFunc(p.Internal.BuildInfo.Settings, func(x, y debug.BuildSetting) int {
|
||||
return strings.Compare(x.Key, y.Key)
|
||||
})
|
||||
}
|
||||
|
||||
switch cfg.BuildPGO {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ stderr 'compile.*-p test/dep.*-pgoprofile=.*default\.pgo'
|
|||
# if the first arg starts with - it is a grep flag.
|
||||
stderr 'build\\t-pgo=.*default\.pgo'
|
||||
|
||||
# check also that -pgo appears with the other flags, before non-flag settings
|
||||
! stderr 'build\\t[A-Za-z].*build\\t-pgo'
|
||||
|
||||
# use default.pgo for ... with a single main package
|
||||
go build -n -pgo=auto ./a/...
|
||||
stderr 'compile.*-pgoprofile=.*default\.pgo.*a1.go'
|
||||
|
|
|
|||
Loading…
Reference in New Issue