From 7837164e6e886c944218c3ecdcc40bf4ec48167b Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Fri, 2 Dec 2022 09:44:52 +0100 Subject: [PATCH] Build system improvements - build PIE binaries using goreleaser - add snapshot target to Makefile - add -trimpath option to go build --- .goreleaser.yaml | 9 +++++++++ Makefile | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 8b9a6f1..7ddc8c6 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -16,6 +16,9 @@ builds: env: - CC=x86_64-linux-gnu-gcc - CXX=x86_64-linux-gnu-g++ + flags: + - -buildmode=pie + - -trimpath - id: linux-arm64 main: ./cmd/signer binary: cacert-gosigner @@ -29,6 +32,9 @@ builds: - CC=aarch64-linux-gnu-gcc - CXX=aarch64-linux-gnu-g++ - PKG_CONFIG_PATH=/usr/aarch64-linux-gnu/pkgconfig + flags: + - -buildmode=pie + - -trimpath - id: linux-armhf main: ./cmd/signer binary: cacert-gosigner @@ -42,6 +48,9 @@ builds: - CC=arm-linux-gnueabihf-gcc - CXX=arm-linux-gnueabihf-g++ - PKG_CONFIG_PATH=/usr/arm-linux-gnueabihf/pkgconfig + flags: + - -buildmode=pie + - -trimpath archives: - id: cacert-gosigner builds: diff --git a/Makefile b/Makefile index 1559b64..71307a9 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,15 @@ test: go test -race ./... clientsim: $(GOFILES) - go build -race ./cmd/clientsim + go build -race -trimpath ./cmd/clientsim signer: $(GOFILES) - go build -race -ldflags="-X 'main.date=$(BUILD_TIME)' -X 'main.commit=$(COMMIT)' -X 'main.version=$(VERSION)'" ./cmd/signer + go build -race -trimpath -ldflags="-X 'main.date=$(BUILD_TIME)' -X 'main.commit=$(COMMIT)' -X 'main.version=$(VERSION)'" ./cmd/signer clean: rm -f signer clientsim pkg/messages/resolver.msgpackgen.go -.PHONY: test lint all clean \ No newline at end of file +snapshot: + goreleaser build --rm-dist --snapshot + +.PHONY: test lint all clean snapshot