From eaba4e09236f887fe96e3cf047e70310dbca0381 Mon Sep 17 00:00:00 2001 From: jp Date: Thu, 5 Sep 2024 08:59:52 +0200 Subject: [PATCH 1/2] -s disable symbol table -w disable DWARF generation --- makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile b/makefile index 6f2682ea..faac4c88 100644 --- a/makefile +++ b/makefile @@ -5,6 +5,7 @@ DIRECTORY = $(sort $(dir $(wildcard ./test/*/))) VERSION = $(shell git describe --tags --dirty) BUILDTIME := $(shell date '+%Y-%m-%dT%T%z') +GOLDFLAGS += -s -w GOLDFLAGS += -X main.Version=$(VERSION) GOLDFLAGS += -X main.Buildtime=$(BUILDTIME) GOFLAGS = -ldflags "$(GOLDFLAGS)" From 00c1da6ec7b64efcbc69782eade9e249d7c1bca7 Mon Sep 17 00:00:00 2001 From: Maarten de Kruijf <16100232+MaartendeKruijf@users.noreply.github.com> Date: Fri, 22 Nov 2024 14:46:51 +0100 Subject: [PATCH 2/2] Added new release flags for compilation --- makefile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index faac4c88..400d1e33 100644 --- a/makefile +++ b/makefile @@ -5,11 +5,16 @@ DIRECTORY = $(sort $(dir $(wildcard ./test/*/))) VERSION = $(shell git describe --tags --dirty) BUILDTIME := $(shell date '+%Y-%m-%dT%T%z') -GOLDFLAGS += -s -w + GOLDFLAGS += -X main.Version=$(VERSION) GOLDFLAGS += -X main.Buildtime=$(BUILDTIME) GOFLAGS = -ldflags "$(GOLDFLAGS)" + +LINKERFLAGS = $(GOLDFLAGS) +LINKERFLAGS += -s -w +GORELEASEFLAGS = -ldflags "$(LINKERFLAGS)" + swagger: mkdir -p swaggerdocs swag init -o swaggerdocs @@ -36,9 +41,9 @@ clean: compile: swagger echo "Compiling for every OS and Platform" - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) main.go - CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/${BINARY_NAME}-${VERSION}-darwin-arm64 $(GOFLAGS) main.go - CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-windows-amd64 $(GOFLAGS) main.go + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GORELEASEFLAGS) main.go + CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/${BINARY_NAME}-${VERSION}-darwin-arm64 $(GORELEASEFLAGS) main.go + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-windows-amd64 $(GORELEASEFLAGS) main.go sbom: echo "Generating SBOMs" @@ -48,7 +53,7 @@ sbom: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 cyclonedx-gomod app -json -licenses -output bin/${BINARY_NAME}-${VERSION}-windows-amd64.bom.json pre-docker-build: swagger - GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) main.go + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/${BINARY_NAME}-${VERSION}-linux-amd64 $(GOFLAGS) main.go docker: pre-docker-build docker build --no-cache -t soarca:${VERSION} --build-arg="VERSION=${VERSION}" .