Skip to content

Commit 36af4a7

Browse files
dmitshurgopherbot
authored andcommitted
cmd/buildlet{,stage0}: use go version in go.mod via go.dev/doc/toolchain
Both go1.22.8 and go1.19 are old and need to be updated to go1.23+. As of Go 1.21, instead of doing: go install golang.org/dl/go1.n.m@latest go1.n.m download to get a specific Go toolchain version, we can do: env GOTOOLCHAIN=go1.n.m go But there's probably no good reason not to permit newer versions than go1.n.m if the x/build go.mod go directive is upgraded to a higher Go version, so it should be: env GOTOOLCHAIN=go1.n.m+auto go But that means in most cases exactly go1.n.m will be used, even if the local Go toolchain is slightly newer. Instead of maintaining the Go version both here and in x/build's go.mod file, reuse the top-level one. Getting the desired behavior can be done by running $(go env GOROOT)/bin/go inside the x/build module, or simply by running 'go' directly. Change-Id: Ie1eec998e17b84adda0c3b3d3dc58e369f734d35 Reviewed-on: https://go-review.googlesource.com/c/build/+/657956 Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 6383021 commit 36af4a7

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

cmd/buildlet/Makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@
33
# - compile: build all buildlets (but do not upload)
44
# - upload: build and upload all buildlets to prod
55
# - dev-upload: build and upload all buildlets to dev cluster
6-
# - install-go: install the version of Go needed by the Makefile
76
#
87
# Individual targets:
98
#
109
# - buildlet.linux-amd64: build buildlet for linux-amd64 (but do not upload)
1110
# - upload.linux-amd64: build buildlet for linux-amd64 and upload to prod
1211
# - dev-upload.linux-amd64: build buildlet for linux-amd64 and upload to dev cluster
1312

14-
GO=go1.22.8
15-
1613
ALL=\
1714
buildlet.aix-ppc64 \
1815
buildlet.darwin-amd64 \
@@ -65,11 +62,6 @@ usage: FORCE
6562

6663
FORCE:
6764

68-
# A convenience for people who are missing $(GO).
69-
install-go:
70-
go install golang.org/dl/$(GO)@latest
71-
$(GO) download
72-
7365
clean:
7466
rm -f buildlet.*-*
7567

@@ -80,7 +72,7 @@ GOFILES:=$(shell ls *.go)
8072

8173
VERSION:=$(USER)-$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
8274

83-
BUILD=CGO_ENABLED=0 $(GO) build -ldflags='-X main.Version=$(VERSION)' -o
75+
BUILD=CGO_ENABLED=0 go build -ldflags='-X main.Version=$(VERSION)' -o
8476

8577
buildlet.%-386: $(GOFILES)
8678
GOOS=$* GOARCH=386 $(BUILD) $@
@@ -145,7 +137,7 @@ buildlet.%-s390x: $(GOFILES)
145137
# Upload everything.
146138
upload: $(ALL:buildlet.%=upload.%)
147139

148-
UPLOAD=$(GO) run golang.org/x/build/cmd/upload -verbose -public -cacheable=false
140+
UPLOAD=go run golang.org/x/build/cmd/upload -verbose -public -cacheable=false
149141

150142
upload.%: buildlet.%
151143
$(UPLOAD) -file=$< go-builder-data/$<

cmd/buildlet/stage0/Makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# - upload: build and upload all stage0 binaries to prod
55
# - dev-upload: build and upload all stage0 binaries to dev cluster
66
# - docker: build golang/buildlet-stage0 Docker image (but do not push)
7-
# - install-go: install the version of Go needed by the Makefile
87
#
98
# Individual targets:
109
#
@@ -19,8 +18,6 @@
1918
# automated VM/container creation scripts download them from.
2019
#
2120

22-
GO=go1.19
23-
2421
ALL=\
2522
buildlet-stage0.illumos-amd64 \
2623
buildlet-stage0.linux-arm \
@@ -43,11 +40,6 @@ usage: FORCE
4340

4441
FORCE:
4542

46-
# A convenience for people who are missing $(GO).
47-
install-go:
48-
go install golang.org/dl/$(GO)@latest
49-
$(GO) download
50-
5143
clean:
5244
rm -f buildlet-stage0.*-*
5345

@@ -56,7 +48,7 @@ compile: $(ALL)
5648

5749
GOFILES:=$(shell ls *.go)
5850

59-
BUILD=CGO_ENABLED=0 $(GO) build -o
51+
BUILD=CGO_ENABLED=0 go build -o
6052

6153
buildlet-stage0.%-arm: $(GOFILES)
6254
GOOS=$* GOARCH=arm GOARM=7 $(BUILD) $@
@@ -98,7 +90,7 @@ docker: Dockerfile
9890
# Upload everything.
9991
upload: $(ALL:buildlet-stage0.%=upload.%)
10092

101-
UPLOAD=$(GO) run golang.org/x/build/cmd/upload -verbose -public -cacheable=false
93+
UPLOAD=go run golang.org/x/build/cmd/upload -verbose -public -cacheable=false
10294

10395
upload.%: buildlet-stage0.%
10496
$(UPLOAD) -file=$< go-builder-data/$<

0 commit comments

Comments
 (0)