From e2e2ad48ce4234924cbbbbb36b818b39368142a3 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Fri, 13 Dec 2019 18:42:28 +0530 Subject: [PATCH] Add -trimpath flag to the builds (#13348) Go 1.13 introduced this new flag which removes all absolute file system paths from the binary and just keeps the module path / GOPATH. To debug binary crashes or stack traces, we only need the path to the code and not the full file path. Hence this is a quick way to reduce the binary size without any information loss. Shaves off around 750KB from the server binary. --- build/release.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/release.mk b/build/release.mk index 9dfca71547..2c51900ad8 100644 --- a/build/release.mk +++ b/build/release.mk @@ -3,15 +3,15 @@ dist: | check-style test package build-linux: @echo Build Linux amd64 - env GOOS=linux GOARCH=amd64 $(GO) install -i $(GOFLAGS) -ldflags '$(LDFLAGS)' ./... + env GOOS=linux GOARCH=amd64 $(GO) install $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./... build-osx: @echo Build OSX amd64 - env GOOS=darwin GOARCH=amd64 $(GO) install -i $(GOFLAGS) -ldflags '$(LDFLAGS)' ./... + env GOOS=darwin GOARCH=amd64 $(GO) install $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./... build-windows: @echo Build Windows amd64 - env GOOS=windows GOARCH=amd64 $(GO) install -i $(GOFLAGS) -ldflags '$(LDFLAGS)' ./... + env GOOS=windows GOARCH=amd64 $(GO) install $(GOFLAGS) -trimpath -ldflags '$(LDFLAGS)' ./... build: build-linux build-windows build-osx