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? ;)
This commit is contained in:
2
Makefile
2
Makefile
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user