Skip to content

Commit a35701b

Browse files
committed
cmd/dist: only install necessary tools when doing local test
Instead of installing all of cmd, install only the tools that cmd/dist would normally install. Also, remove the addition of the buildid tool to the list of commands in the toolchain in debug mode. The uses of buildid were removed in CL 451360. For #71867 Change-Id: I062909d23c18294aa23ea43b9f7eeb69bfa80c8c Reviewed-on: https://go-review.googlesource.com/c/go/+/680475 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Matloob <matloob@google.com>
1 parent a189516 commit a35701b

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/cmd/dist/build.go

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,21 @@ func toolenv() []string {
13901390
return env
13911391
}
13921392

1393-
var toolchain = []string{"cmd/asm", "cmd/cgo", "cmd/compile", "cmd/link", "cmd/preprofile"}
1393+
var (
1394+
toolchain = []string{"cmd/asm", "cmd/cgo", "cmd/compile", "cmd/link", "cmd/preprofile"}
1395+
1396+
// Keep in sync with binExes in cmd/distpack/pack.go.
1397+
binExesIncludedInDistpack = []string{"cmd/go", "cmd/gofmt"}
1398+
1399+
// Keep in sync with the filter in cmd/distpack/pack.go.
1400+
toolsIncludedInDistpack = []string{"cmd/asm", "cmd/cgo", "cmd/compile", "cmd/cover", "cmd/link", "cmd/preprofile", "cmd/vet"}
1401+
1402+
// We could install all tools in "cmd", but is unnecessary because we will
1403+
// remove them in distpack, so instead install the tools that will actually
1404+
// be included in distpack, which is a superset of toolchain. Not installing
1405+
// the tools will help us test what happens when the tools aren't present.
1406+
toolsToInstall = slices.Concat(binExesIncludedInDistpack, toolsIncludedInDistpack)
1407+
)
13941408

13951409
// The bootstrap command runs a build from scratch,
13961410
// stopping at having installed the go_bootstrap command.
@@ -1456,11 +1470,6 @@ func cmdbootstrap() {
14561470
// GOEXPERIMENT.
14571471
os.Setenv("GOEXPERIMENT", "none")
14581472

1459-
if debug {
1460-
// cmd/buildid is used in debug mode.
1461-
toolchain = append(toolchain, "cmd/buildid")
1462-
}
1463-
14641473
if isdir(pathf("%s/src/pkg", goroot)) {
14651474
fatalf("\n\n"+
14661475
"The Go package sources have moved to $GOROOT/src.\n"+
@@ -1589,18 +1598,6 @@ func cmdbootstrap() {
15891598
os.Setenv("GOCACHE", oldgocache)
15901599
}
15911600

1592-
// Keep in sync with binExes in cmd/distpack/pack.go.
1593-
binExesIncludedInDistpack := []string{"cmd/go", "cmd/gofmt"}
1594-
1595-
// Keep in sync with the filter in cmd/distpack/pack.go.
1596-
toolsIncludedInDistpack := []string{"cmd/asm", "cmd/cgo", "cmd/compile", "cmd/cover", "cmd/link", "cmd/preprofile", "cmd/vet"}
1597-
1598-
// We could install all tools in "cmd", but is unnecessary because we will
1599-
// remove them in distpack, so instead install the tools that will actually
1600-
// be included in distpack, which is a superset of toolchain. Not installing
1601-
// the tools will help us test what happens when the tools aren't present.
1602-
toolsToInstall := slices.Concat(binExesIncludedInDistpack, toolsIncludedInDistpack)
1603-
16041601
if goos == oldgoos && goarch == oldgoarch {
16051602
// Common case - not setting up for cross-compilation.
16061603
timelog("build", "toolchain")

src/cmd/dist/test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (t *tester) run() {
178178
// otherwise relevant to the actual set of packages under test.
179179
goInstall(toolenv(), gorootBinGo, toolchain...)
180180
goInstall(toolenv(), gorootBinGo, toolchain...)
181-
goInstall(toolenv(), gorootBinGo, "cmd")
181+
goInstall(toolenv(), gorootBinGo, toolsToInstall...)
182182
}
183183
}
184184

0 commit comments

Comments
 (0)