make: Make builds more likely to be reproducible
As per https://go.dev/blog/rebuild if we include -trimpath then we'll not store full build paths in the build artifacts. We still have some CGO dependencies, but we'll look into those separately.
This commit is contained in:
4
Makefile
4
Makefile
@@ -151,7 +151,7 @@ $(PROGRAM): build/mgmt-${GOHOSTOS}-${GOHOSTARCH} ## build an mgmt binary for cur
|
|||||||
$(PROGRAM).static: $(GO_FILES) $(MCL_FILES) go.mod go.sum
|
$(PROGRAM).static: $(GO_FILES) $(MCL_FILES) go.mod go.sum
|
||||||
@echo "Building: $(PROGRAM).static, version: $(SVERSION)..."
|
@echo "Building: $(PROGRAM).static, version: $(SVERSION)..."
|
||||||
go generate
|
go generate
|
||||||
go build -a -installsuffix cgo -tags netgo -ldflags '-extldflags "-static" -X main.program=$(PROGRAM) -X main.version=$(SVERSION) -s -w' -o $(PROGRAM).static $(BUILD_FLAGS);
|
go build -trimpath -a -installsuffix cgo -tags netgo -ldflags '-extldflags "-static" -X main.program=$(PROGRAM) -X main.version=$(SVERSION) -s -w' -o $(PROGRAM).static $(BUILD_FLAGS);
|
||||||
|
|
||||||
build: LDFLAGS=-s -w ## build a fresh mgmt binary
|
build: LDFLAGS=-s -w ## build a fresh mgmt binary
|
||||||
build: $(PROGRAM)
|
build: $(PROGRAM)
|
||||||
@@ -165,7 +165,7 @@ GOOS=$(firstword $(subst -, ,$*))
|
|||||||
GOARCH=$(lastword $(subst -, ,$*))
|
GOARCH=$(lastword $(subst -, ,$*))
|
||||||
build/mgmt-%: $(GO_FILES) $(MCL_FILES) go.mod go.sum | lang funcgen
|
build/mgmt-%: $(GO_FILES) $(MCL_FILES) go.mod go.sum | lang funcgen
|
||||||
@echo "Building: $(PROGRAM), os/arch: $*, version: $(SVERSION)..."
|
@echo "Building: $(PROGRAM), os/arch: $*, version: $(SVERSION)..."
|
||||||
@time env GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags=$(PKGNAME)="-X main.program=$(PROGRAM) -X main.version=$(SVERSION) ${LDFLAGS}" -o $@ $(BUILD_FLAGS)
|
@time env GOOS=${GOOS} GOARCH=${GOARCH} go build -trimpath -ldflags=$(PKGNAME)="-X main.program=$(PROGRAM) -X main.version=$(SVERSION) ${LDFLAGS}" -o $@ $(BUILD_FLAGS)
|
||||||
|
|
||||||
# create a list of binary file names to use as make targets
|
# create a list of binary file names to use as make targets
|
||||||
# to use this you might want to run something like:
|
# to use this you might want to run something like:
|
||||||
|
|||||||
Reference in New Issue
Block a user