Skip to content

cmd/vendor: go mod vendor for cmd does not work when rebuilding the toolchain using make.bash #74563

Closed as not planned
@Lslightly

Description

@Lslightly

Go version

1.24.2

Output of go env in your module/workspace:

AR='ar'
CC='/usr/bin/gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='/usr/bin/g++'
GCCGO='gccgo'
GO111MODULE='auto'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/lqw/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/lqw/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2711622146=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/lqw/mygit/go1.24.2/src/go.mod'
GOMODCACHE='/home/lqw/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/lqw/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/home/lqw/mygit/go1.24.2'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/lqw/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/lqw/mygit/go1.24.2/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK='/home/lqw/mygit/go1.24.2/src/go.work'
PKG_CONFIG='pkg-config'

What did you do?

I import gonum package in cmd/compile/internal/escape package to use the graph interface and export dot easily.

The minimal example is to add "gonum.org/v1/gonum/graph" in import section of cmd/compile/internal/escape/escape.go and add the following code in arbitrary function.

var g graph.Graph
_ = g

Then I execute the following instructions:

cd $(go env GOROOT)/src/cmd
go get gonum.org/v1/gonum/graph
go mod tidy
GOWORK=off go mod vendor # instructed in [README.vendor](https://github.com/golang/go/blob/master/src/README.vendor)

Indeed, gonum package is added in cmd/vendor directory, as the following tree shows:

(base) ➜  vendor git:(closure-go) ✗ pwd
/home/lqw/mygit/go1.24.2/src/cmd/vendor
(base) ➜  vendor git:(closure-go) ✗ tree -L 2
.
├── github.com
│   ├── google
│   └── ianlancetaylor
├── golang.org
│   └── x
├── gonum.org
│   └── v1
├── modules.txt
└── rsc.io
    └── markdown

9 directories, 1 file

What did you see happen?

But when I execute make.bash in src directory, I get the following error. The bootstrap version of go1.24.1 is the prebuilt binary downloaded from https://go.dev.

$ GOROOT_BOOTSTRAP=/home/lqw/golangs/go1.24.1 ./make.bash
Building Go cmd/dist using /home/lqw/golangs/go1.24.1. (go1.24.1 linux/amd64)
Building Go toolchain1 using /home/lqw/golangs/go1.24.1.
../../../../src/cmd/compile/internal/xxx: no required module provides package gonum.org/v1/gonum/graph; to add it:
        go get gonum.org/v1/gonum/graph
...(gonum subpackages)

What did you expect to see?

make.bash successfully rebuilds the toolchain although I import new vendor package like gonum.org/v1/gonum/graph in cmd/compile/interal/escape package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions