From be66519c261d9d0d5b18b5bb0b5fcf42d04535b9 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Tue, 19 May 2020 09:44:06 -0700 Subject: [PATCH] Remove "-buildmode=pie" from platforms that don't support it This sequence (and syntax) is inspired by containerd's implementation of the same: https://github.com/containerd/containerd/blob/4e08c2de67ec514b5602eea47804d41dfeabdc72/Makefile.linux#L21-L26 Signed-off-by: Tianon Gravi --- Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 38683052c..aa7d95a5e 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,12 @@ VERSION := $(shell cat ./VERSION) ifneq ($(GO111MODULE),off) MOD_VENDOR := "-mod=vendor" endif -GO_BUILD := $(GO) build $(MOD_VENDOR) -buildmode=pie $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ +ifeq ($(shell $(GO) env GOOS),linux) + ifeq (,$(filter $(shell $(GO) env GOARCH),mips mipsle mips64 mips64le ppc64)) + GO_BUILDMODE := "-buildmode=pie" + endif +endif +GO_BUILD := $(GO) build $(MOD_VENDOR) $(GO_BUILDMODE) $(EXTRA_FLAGS) -tags "$(BUILDTAGS)" \ -ldflags "-X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)" GO_BUILD_STATIC := CGO_ENABLED=1 $(GO) build $(MOD_VENDOR) $(EXTRA_FLAGS) -tags "$(BUILDTAGS) netgo osusergo" \ -ldflags "-w -extldflags -static -X main.gitCommit=$(COMMIT) -X main.version=$(VERSION) $(EXTRA_LDFLAGS)"