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

cmd/go: go build -i doesn't actually install dependencies #8255

Closed
gopherbot opened this issue Jun 20, 2014 · 8 comments
Closed

cmd/go: go build -i doesn't actually install dependencies #8255

gopherbot opened this issue Jun 20, 2014 · 8 comments
Milestone

Comments

@gopherbot
Copy link

by adamh.zero:

After upgrading to go 1.3, I decided to try the new `go build -i` option to cut down on
my build times.

I removed everything from `$GOPATH/pkg` to simulate a clean build and timed a clean
build (16 seconds). Then I ran `go build -i -v` (visual to make sure it's doing what I
think it's doing) and re-timed a `go build`, which still came out to about 16 seconds.
No significant improvement, despite most of the build time being spent on 2 external
packages.

I ran for loop that does what `go build -i` should do, then timed another build... build
complete in .3 seconds. (sidenote: why does `go build -v` output to stderr??)

Am I misunderstanding what `go build -i` does? From the release notes: "The go
build subcommand supports a new -i option to install dependencies of the specified
target, but not the target itself."

Running on Mac OS 10.9.3, go 1.3.

Console output of what is described above:

[22:03:50] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z go version
go version go1.3 darwin/amd64
 
[22:04:36] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z rm -rf $GOPATH/pkg/*
zsh: sure you want to delete all the files in /Users/atg/.go/pkg [yn]? y
 
[22:04:54] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z time go build -v
bitbucket.org/zombiezen/math3/vec32
github.com/adam000/Go-SDL2/sdl/keys
github.com/go-gl/gl
bitbucket.org/zombiezen/math3/mat32
github.com/adam000/Go-SDL2/sdl
github.com/adam000/shader
github.com/adam000/terminus
go build -v  16.19s user 2.08s system 115% cpu 15.874 total
 
[22:05:25] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z ls $GOPATH/pkg
 
[22:05:52] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z go build -i -v
bitbucket.org/zombiezen/math3/vec32
github.com/adam000/Go-SDL2/sdl/keys
github.com/go-gl/gl
bitbucket.org/zombiezen/math3/mat32
github.com/adam000/Go-SDL2/sdl
github.com/adam000/shader
github.com/adam000/terminus
 
[22:06:34] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z ls $GOPATH/pkg
 
[22:06:37] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z time go build -v
bitbucket.org/zombiezen/math3/vec32
github.com/adam000/Go-SDL2/sdl/keys
github.com/go-gl/gl
bitbucket.org/zombiezen/math3/mat32
github.com/adam000/Go-SDL2/sdl
github.com/adam000/shader
github.com/adam000/terminus
go build -v  16.24s user 2.08s system 115% cpu 15.886 total
 
[22:07:04] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z for SRC_PATH in `go build -v 2>&1`; do
for> cd $GOPATH/src/$SRC_PATH
for> go install
for> done
 
[22:08:31] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z ls $GOPATH/pkg
darwin_amd64
 
[22:08:41] (Masyaf) ~/.go/src/github.com/adam000/terminus
Z time go build -v
github.com/adam000/terminus
go build -v  0.25s user 0.06s system 99% cpu 0.311 total
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.4.

@adg
Copy link
Contributor

adg commented Aug 7, 2014

Comment 2:

Timing the build is telling us nothing. You need to look at the generated build
artefacts in $GOPATH/pkg.
In this example, I have package "importtest" that imports package "importtest/bar". As
you can see here, when I run "go build -i" it builds package "importtest/bar" and puts
the generated object file at $GOPATH/pkg/darwin_adm64/importtest/bar.a.
~/src/importtest $ rm -r ~/pkg/darwin_amd64/importtest*
~/src/importtest $ go build -i
~/src/importtest $ ls ~/pkg/darwin_amd64/importtest/
bar.a
Are you not observing this behaviour?

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 4 by adamh.zero:

The timing is incidental (though not insignificant -- it is a symptom of the problem),
but you can see that I also `ls $GOPATH/pkg` and there's nothing there. See line marked
"22:06:34" ;)

@adg
Copy link
Contributor

adg commented Aug 7, 2014

Comment 5:

Is terminus a "package main" ?

@adg
Copy link
Contributor

adg commented Aug 7, 2014

Comment 6:

It would be helpful if you could strip this down to a minimal reproduction with code
that I can run on my own machine. The packages you're building don't appear to be
publicly available.

@adg
Copy link
Contributor

adg commented Aug 7, 2014

Comment 7:

I'm thinking this might be a duplicate of issue #8242.

@gopherbot
Copy link
Author

Comment 8 by adamh.zero:

> Is terminus a "package main" ?
It was at the time of writing, though it isn't anymore. I plan on open sourcing terminus
soon, but for now I have an alternate solution using only some of the packages.
The package github.com/adam000/Go-SDL2/demos/showimage (a main package) builds only
referencing packages within the repo (Go-SDL2/{sdl/keys,sdl,image}), so that's a nice
little self-contained repro. There might be some work on it some time in the near
future, so for future reference the SHA of the commit I'm testing with is
327de6af0b00d765e4f2f0dfbddf56f2fc3104a1.
If there's anything else you need, let me know.

@adg
Copy link
Contributor

adg commented Aug 11, 2014

Comment 9:

If your repros are both for "main" packages then this is a dupe.

Status changed to Duplicate.

Merged into issue #8242.

@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants