Skip to content

Commit d5c6b43

Browse files
Merge pull request #1003 from tiffanny29631/makefile
Build go-licenses with the same toolchain as the main module
2 parents c5f6bea + a937d1e commit d5c6b43

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎Makefile‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,16 @@ DOTFILE_IMAGE = $(subst /,_,$(IMAGE))-$(OS_ARCH_TAG)
163163

164164
LICENSES = .licenses
165165

166+
# go-licenses identifies stdlib packages by its compiled-in GOROOT, so it must
167+
# be built with the same toolchain that the main module selects when it runs
168+
# `go list`. Otherwise (e.g. with GOTOOLCHAIN=auto and an older host Go) the
169+
# tools module and the main module can resolve to different toolchains, and
170+
# every stdlib package is reported as "does not have module info".
166171
$(LICENSES):
167172
pushd tools >/dev/null; \
168173
export GOOS=$(shell go env GOHOSTOS); \
169174
export GOARCH=$(shell go env GOHOSTARCH); \
175+
export GOTOOLCHAIN=$(shell go env GOVERSION); \
170176
go build -o ../bin/tools/ github.com/google/go-licenses/v2; \
171177
popd >/dev/null
172178
rm -rf $(LICENSES)

0 commit comments

Comments
 (0)