Permalink
Browse files

compiling: Add -i flag to go build to speed up builds

So builds take about 30s on my shitty machine which is pretty long.
Turns out golang caches things in $GOPATH/pkg/ but is not clever enough
to erase things from there that are out of date. As a result, it was
rebuilding everything (including the unchanged dependencies) every
build!

By completely wiping out $GOPATH/pkg/ and then running `go build -i`,
this now takes builds down to about 8 seconds. (After one full build is
finished.)

This is basically the same as running `go install`, but without copying
junk to $GOPATH/bin.

Hopefully the tooling will be smart enough to know when to throw out
stuff in $GOPATH/pkg automatically and avoid this problem entirely.

Is it wrong to send Google a bill for all the extra cpu cycles I've
used? ;)
  • Loading branch information...
purpleidea committed Feb 26, 2017
1 parent 4626074 commit 46c6d6f6565a5e01c4fc3d7249f87a1a6a487ab8
Showing with 1 addition and 1 deletion.
  1. +1 −1 Makefile
View
@@ -112,7 +112,7 @@ ifneq ($(OLDGOLANG),)
@# avoid equals sign in old golang versions eg in: -X foo=bar
time go build -ldflags "-X main.program $(PROGRAM) -X main.version $(SVERSION)" -o $(PROGRAM) $(BUILD_FLAGS);
else
- time go build -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM) $(BUILD_FLAGS);
+ time go build -i -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM) $(BUILD_FLAGS);
endif
$(PROGRAM).static: main.go

1 comment on commit 46c6d6f

@roidelapluie

This comment has been minimized.

Show comment
Hide comment
@roidelapluie

roidelapluie Feb 26, 2017

Contributor

🎆 🎉 thanks @davecheney

Contributor

roidelapluie commented on 46c6d6f Feb 26, 2017

🎆 🎉 thanks @davecheney

Please sign in to comment.