From cc886f0163229c0230891ab3c0de8aec2f7a231b Mon Sep 17 00:00:00 2001 From: Jack Chen Date: Fri, 8 Nov 2024 10:51:35 +0800 Subject: [PATCH] fix: Only one ldflags flag is allowed Signed-off-by: Jack Chen --- Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 81771e12..176697fe 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ .PHONY: build test unittest lint clean prepare update docker # change the following boolean flag to enable or disable the Full RELRO (RELocation Read Only) for linux ELF (Executable and Linkable Format) binaries -ENABLE_FULL_RELRO:="true" +ENABLE_FULL_RELRO=true # change the following boolean flag to enable or disable PIE for linux binaries which is needed for ASLR (Address Space Layout Randomization) on Linux, the ASLR support on Windows is enabled by default -ENABLE_PIE:="true" +ENABLE_PIE=true MICROSERVICES=cmd/device-mqtt @@ -18,16 +18,17 @@ DOCKERS=docker_device_mqtt_go VERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0) GIT_SHA=$(shell git rev-parse HEAD) +ifeq ($(ENABLE_FULL_RELRO), true) + ENABLE_FULL_RELRO_GOFLAGS = -bindnow +endif + SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/device-sdk-go/v4 v' | awk '{print $$2}') GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-mqtt-go.Version=$(VERSION) \ - -X github.com/edgexfoundry/device-sdk-go/v4/internal/common.SDKVersion=$(SDKVERSION)" \ + -X github.com/edgexfoundry/device-sdk-go/v4/internal/common.SDKVersion=$(SDKVERSION) \ + $(ENABLE_FULL_RELRO_GOFLAGS)" \ -trimpath -mod=readonly -ifeq ($(ENABLE_FULL_RELRO), "true") - GOFLAGS += -ldflags "-bindnow" -endif - -ifeq ($(ENABLE_PIE), "true") +ifeq ($(ENABLE_PIE), true) GOFLAGS += -buildmode=pie endif