Skip to content

Commit

Permalink
Merge pull request #472 from jackchenjc/edgex-go-issue-4916-2
Browse files Browse the repository at this point in the history
fix: Only one ldflags flag is allowed
  • Loading branch information
cloudxxx8 authored Nov 8, 2024
2 parents b1923ec + 1059907 commit 10f464a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ CGO_CXXFLAGS="-O2 -pipe -fno-plt"
CGO_LDFLAGS="-Wl,-O1,–sort-common,–as-needed,-z,relro,-z,now"

# 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

ARCH=$(shell uname -m)

Expand All @@ -22,16 +22,17 @@ VERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0)
# This pulls the version of the SDK from the go.mod file
SDKVERSION=$(shell cat ./go.mod | grep 'github.com/edgexfoundry/device-sdk-go/v4 v' | awk '{print $$2}')

ifeq ($(ENABLE_FULL_RELRO), true)
ENABLE_FULL_RELRO_GOFLAGS = -bindnow
endif

GIT_SHA=$(shell git rev-parse HEAD)
GOFLAGS=-ldflags "-s -w -X github.com/edgexfoundry/device-onvif-camera.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

Expand Down

0 comments on commit 10f464a

Please sign in to comment.