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

proposal: cmd/go: deprecate the -i flag #41696

Open
jayconrod opened this issue Sep 29, 2020 · 3 comments
Open

proposal: cmd/go: deprecate the -i flag #41696

jayconrod opened this issue Sep 29, 2020 · 3 comments
Labels
Projects
Milestone

Comments

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented Sep 29, 2020

go build, go install, and go test accept the -i flag. From go help build:

The -i flag installs the packages that are dependencies of the target.

For example, if you run go build -i example.com/a, and example.com/x imports example.com/y, go build installs the file $GOPATH/pkg/$GOOS_$GOARCH/example.com/y.a.

This was useful for speeding up builds before Go 1.10, since previously installed packages didn't need to be recompiled. go build re-used packages installed in $GOPATH/pkg.

Go 1.10 introduced the build cache, so the $GOPATH/pkg directory is largely obsolete. Compiled packages are now stored in $GOCACHE. The -i flag merely copies files out of the build cache, so there's no longer any performance advantage.

The -i can cause errors when a target directory is not writable, as in #37962. In that issue, VSCode installed tools with -i, which caused errors when $GOROOT/pkg was not writable (common when Go is installed system-wide with an installer). Something caused runtime/cgo to be recompiled (perhaps a new clang version or flag), but it couldn't be written to $GOROOT/pkg/darwin_amd64/runtime/cgo.a.

Because of these problems, we should consider deprecating and eventually removing the -i flag.

@jayconrod jayconrod added this to the Proposal milestone Sep 29, 2020
@gopherbot gopherbot added Proposal and removed NeedsDecision labels Sep 29, 2020
@jayconrod
Copy link
Contributor Author

@jayconrod jayconrod commented Sep 29, 2020

@rsc rsc added this to Incoming in Proposals Oct 6, 2020
@rsc rsc moved this from Incoming to Active in Proposals Oct 7, 2020
@rsc
Copy link
Contributor

@rsc rsc commented Oct 14, 2020

Are there any objections to doing this? I see plenty of emoji in favor and nothing else.

@mvdan
Copy link
Member

@mvdan mvdan commented Oct 17, 2020

My only potential objection is breaking people who learned to use go build -i years ago, and perhaps introduced the flag in build or CI scripts. So the eventual removal of support for -i should come with a clear deprecation warning in the release changelog at least one or two releases before then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.