lxcfs-tools/0002-enable-external-linkmode-for-cgo-build.patch
zhangsong234 701a476cea enable external linkmode for cgo build
Signed-off-by: zhangsong234 <zhangsong34@huawei.com>
2021-09-02 21:24:08 +08:00

40 lines
1.3 KiB
Diff

From 1d3927ed6a300498bd1384ad961a2029ab18be45 Mon Sep 17 00:00:00 2001
From: zhangsong234 <zhangsong34@huawei.com>
Date: Thu, 2 Sep 2021 21:18:50 +0800
Subject: [PATCH] enable external linkmode for cgo build
Signed-off-by: zhangsong234 <zhangsong34@huawei.com>
---
Makefile | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index a597ff4..6507429 100644
--- a/Makefile
+++ b/Makefile
@@ -20,18 +20,13 @@ TAGS="cgo static_build"
BEP_DIR=/tmp/lxcfs-tools-build-bep
BEP_FLAGS=-tmpdir=/tmp/lxcfs-tools-build-bep
-GO_LDFLAGS="-buildid=IdByiSula $(BEP_FLAGS) -extldflags=-static -extldflags=-Wl,-z,relro,-z,now -X main.gitCommit=${COMMIT} -X main.version=${VERSION}"
-DEF_GOPATH=${GOPATH}
-ifneq ($(GOPATH), )
-CUS_GOPATH=${GOPATH}:${PWD}
-ENV = GOPATH=${CUS_GOPATH} \
+GO_LDFLAGS="-buildid=IdByiSula $(BEP_FLAGS) -linkmode=external -extldflags=-static -extldflags=-Wl,-z,relro,-z,now -X main.gitCommit=${COMMIT} -X main.version=${VERSION}"
+
+ENV = GOPATH=${GOPATH} \
CGO_ENABLED=1 \
CGO_CFLAGS="-fstack-protector-strong -fPIE" \
CGO_LDFLAGS_ALLOW='-Wl,-z,relro,-z,now' \
CGO_LDFLAGS="-Wl,-z,relro,-z,now -Wl,-z,noexecstack"
-else
-ENV = CGO_ENABLED=1
-endif
all: dep toolkit lxcfs-hook
dep:
--
1.8.3.1