diff --git a/Makefile b/Makefile index 250cc92f3..b4fd2352b 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,10 @@ SOURCES = $(shell script/build files) SOURCE_DATE_EPOCH ?= $(shell date +%s) BUILD_DATE = $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" '+%d %b %Y' 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" '+%d %b %Y') HUB_VERSION = $(shell hub version | tail -1) +FLAGS_ALL = $(shell go version | grep -q 'go1.[89]' || echo 'all=') +export LDFLAGS := -extldflags='$(LDFLAGS)' +export GCFLAGS := $(FLAGS_ALL)-trimpath='$(PWD)' +export ASMFLAGS := $(FLAGS_ALL)-trimpath='$(PWD)' MIN_COVERAGE = 89.4 diff --git a/script/build b/script/build index 458bad0ed..09d1a7cbe 100755 --- a/script/build +++ b/script/build @@ -13,7 +13,11 @@ find_source_files() { build_hub() { mkdir -p "$(dirname "$1")" - go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1" + go build \ + -ldflags "-X github.com/github/hub/version.Version=`./script/version` $LDFLAGS" \ + -gcflags "$GCFLAGS" \ + -asmflags "$ASMFLAGS" \ + -o "$1" } [ $# -gt 0 ] || set -- -o "bin/hub${windows:+.exe}"