Skip to content

Commit

Permalink
Enable buildmode 'pie'
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmalkmus committed Mar 2, 2021
1 parent fe13a05 commit 46e9793
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ builds:
env:
- CGO_ENABLED=0
flags:
- -buildmode=exe
- -buildmode=pie
- -installsuffix=cgo
- -trimpath
- -tags="osusergo netgo static_build"
ldflags:
- -s -w -extldflags "-fno-PIC -static"
- -s -w -extldflags "-fno-PIC -static -Wl -z now -z relro"
- -X github.com/axiomhq/cli/pkg/version.release={{ .Version }}
- -X github.com/axiomhq/cli/pkg/version.revision={{ .ShortCommit }}
- -X github.com/axiomhq/cli/pkg/version.buildDate={{ .CommitDate }}
Expand All @@ -27,18 +27,27 @@ builds:
- darwin
goarch:
- amd64
- arm64

- <<: *build_defaults
id: linux
goos:
- linux
goarch:
- 386
- amd64
- arm64
goarm:
- 6
- 7

- <<: *build_defaults
flags:
- -buildmode=exe
id: linux-no-pie
goos:
- linux
goarch:
- 386

- <<: *build_defaults
id: windows
Expand All @@ -55,6 +64,7 @@ archives:
builds:
- darwin
- linux
- linux-no-pie
wrap_in_directory: true
format: tar.gz
files:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ MANPAGES_DIR := man
GOTAGS := osusergo netgo static_build

# FLAGS
GOFLAGS := -buildmode=exe -tags='$(GOTAGS)' -installsuffix=cgo -trimpath
GOFLAGS += -ldflags='-s -w -extldflags "-fno-PIC -static"
GOFLAGS := -buildmode=pie -tags='$(GOTAGS)' -installsuffix=cgo -trimpath
GOFLAGS += -ldflags='-s -w -extldflags "-fno-PIC -static -Wl -z now -z relro"
GOFLAGS += -X $(MOD_NAME)/pkg/version.release=$(RELEASE)
GOFLAGS += -X $(MOD_NAME)/pkg/version.revision=$(REVISION)
GOFLAGS += -X $(MOD_NAME)/pkg/version.buildDate=$(BUILD_DATE)
Expand Down

0 comments on commit 46e9793

Please sign in to comment.