Makefile: automatically trim paths in Go 1.13
One persistent problem we've had with building binaries is that paths from the build system get embedded in them. We'd like to produce reproducible binaries, so take advantage of Go 1.13's -trimpath argument that does this for us. This is better than the old technique because it works regardless of where our binaries are built on the system and regardless of where GOPATH is located.
This commit is contained in:
parent
35d05729d1
commit
50d13e0ca2
5
Makefile
5
Makefile
@ -47,6 +47,10 @@ GC_FLAGS = $(BUILTIN_GC_FLAGS) $(EXTRA_GC_FLAGS)
|
||||
|
||||
ASM_FLAGS ?= all=-trimpath="$$HOME"
|
||||
|
||||
# TRIMPATH contains arguments to be passed to go to strip paths on Go 1.13 and
|
||||
# newer.
|
||||
TRIMPATH ?= $(shell [ "$$($(GO) version | awk '{print $$3}' | sed -e 's/^[^.]*\.//;s/\..*$$//;')" -ge 13 ] && echo -trimpath)
|
||||
|
||||
# RONN is the name of the 'ronn' program used to generate man pages.
|
||||
RONN ?= ronn
|
||||
# RONN_EXTRA_ARGS are extra arguments given to the $(RONN) program when invoked.
|
||||
@ -143,6 +147,7 @@ BUILD = GOOS=$(1) GOARCH=$(2) \
|
||||
-ldflags="$(LD_FLAGS)" \
|
||||
-gcflags="$(GC_FLAGS)" \
|
||||
-asmflags="$(ASM_FLAGS)" \
|
||||
$(TRIMPATH) \
|
||||
-o ./bin/git-lfs$(3) $(BUILD_MAIN)
|
||||
|
||||
# BUILD_TARGETS is the set of all platforms and architectures that Git LFS is
|
||||
|
Loading…
Reference in New Issue
Block a user