eggo/0003-eggo-static-compile.patch
zhangxiaoyu ffd5b7662b eggo static compile
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
2021-09-07 17:13:19 +08:00

53 lines
1.7 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

From 2471b2b91c1e0581c386cf63a8db7e95a039ba8b Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 7 Sep 2021 16:36:44 +0800
Subject: [PATCH] eggo static compile
Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
Makefile | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index e1cb535..9722c0c 100644
--- a/Makefile
+++ b/Makefile
@@ -9,26 +9,30 @@ LDFLAGS := -X isula.org/eggo/cmd.Version=$(VERSION) \
-X isula.org/eggo/cmd.BuildTime=$(SOURCE_DATE_EPOCH) \
-X isula.org/eggo/cmd.Arch=$(ARCH) \
$(EXTRALDFLAGS)
+STATIC_LDFLAGS := -extldflags=-static -linkmode=external
SAFEBUILDFLAGS := -buildmode=pie -extldflags=-ftrapv -extldflags=-zrelro -extldflags=-znow -tmpdir=/tmp/xxeggo $(LDFLAGS)
+GO := go
+GO_BUILD := CGO_ENABLED=0 $(GO)
+
.PHONY: eggo
eggo:
@echo "build eggo starting..."
- @go build -ldflags '$(LDFLAGS)' -o bin/eggo .
+ @$(GO_BUILD) build -ldflags '$(LDFLAGS) $(STATIC_LDFLAGS)' -o bin/eggo .
@echo "build eggo done!"
local:
@echo "build eggo use vendor starting..."
- @go build -ldflags '$(LDFLAGS)' -mod vendor -o bin/eggo .
+ @$(GO_BUILD) build -ldflags '$(LDFLAGS) $(STATIC_LDFLAGS)' -mod vendor -o bin/eggo .
@echo "build eggo use vendor done!"
test:
@echo "Unit tests starting..."
- @go test -race -cover -count=1 -timeout=300s ./...
+ @$(GO) test -race -cover -count=1 -timeout=300s ./...
@echo "Units test done!"
.PHONY: safe
safe:
@echo "build safe eggo starting..."
- go build -ldflags '$(SAFEBUILDFLAGS)' -o bin/eggo .
+ $(GO_BUILD) build -ldflags '$(SAFEBUILDFLAGS) $(STATIC_LDFLAGS)' -o bin/eggo .
@echo "build safe eggo done!"
images: image-eggo
--
2.25.1