Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot speed compiling when using go build -mod=vendor #46944

Closed
jianzhangbjz opened this issue Jun 27, 2021 · 6 comments
Closed

Cannot speed compiling when using go build -mod=vendor #46944

jianzhangbjz opened this issue Jun 27, 2021 · 6 comments

Comments

@jianzhangbjz
Copy link

What version of Go are you using (go version)?

$ go version
[cloud-user@preserve-olm-env ~]$ go version
go version go1.16.5 linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
[cloud-user@preserve-olm-env ~]$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/data/jian/go/bin"
GOCACHE="/home/cloud-user/.cache/go-build"
GOENV="/home/cloud-user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/data/goproject/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/data/goproject"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/data/jian/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/data/jian/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1279982106=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I want to use the dependency packages with specific versions, and don't want to depend on the Network. So, we use go build -mod=vendor for compiling. To save building time, we want to cache the binary so that it only rebuilds when the source is newer.

What did you expect to see?

When using go build for building, it saves the mod cache ( *.a files) to the $GOPATH/pkg/mod. We can reuse this cache and rebuilding the binary faster.
But, when using go build -mod=vendor, it works/saves the cache( *.a files) to a random temporary(such as /tmp/go-build1307922253/) WORK folder, and remove it once compiling done. So, that means, it will never reuse the mod cache when running go build -mod=vendor for compiling. Is it right?
So, how to utilize the mod cache to speed the compiling when using the go build -mod=vendor? Much appreciate!

What did you see instead?

@jianzhangbjz jianzhangbjz changed the title Help: how to speed compiling when using go build -mod=vendor Question: how to speed compiling when using go build -mod=vendor Jun 27, 2021
@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@jianzhangbjz
Copy link
Author

Thanks for your info, ask it in Slack: https://gophers.slack.com/archives/C029RQSEE/p1624784324040700

@jianzhangbjz
Copy link
Author

@jianzhangbjz jianzhangbjz changed the title Question: how to speed compiling when using go build -mod=vendor cannot speed compiling when using go build -mod=vendor Jun 28, 2021
@jianzhangbjz jianzhangbjz changed the title cannot speed compiling when using go build -mod=vendor Cannot speed compiling when using go build -mod=vendor Jun 28, 2021
@jianzhangbjz
Copy link
Author

Reopen it, since I thought this is a prroblem we should fix, at least a feature request.

@jianzhangbjz
Copy link
Author

/reopen

@golang golang locked as resolved and limited conversation to collaborators Jun 28, 2021
@ianlancetaylor
Copy link
Contributor

I don't think you are correctly describing how the system works. Please use a forum, as suggested above, to see how the system works, and then file an issue describing specific changes to make.

In particular the module cache, the build cache, and the temporary work directory are all different things.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants