From 1494221b08854f6358fe810662bb003816572425 Mon Sep 17 00:00:00 2001 From: chrislu Date: Thu, 21 Sep 2023 11:58:03 -0700 Subject: [PATCH] reduce binary size --- .github/workflows/binaries_dev.yml | 8 ++++---- .github/workflows/binaries_release0.yml | 4 ++-- .github/workflows/binaries_release1.yml | 4 ++-- .github/workflows/binaries_release2.yml | 4 ++-- .github/workflows/binaries_release3.yml | 4 ++-- .github/workflows/binaries_release4.yml | 4 ++-- docker/Makefile | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/binaries_dev.yml b/.github/workflows/binaries_dev.yml index 6e007a797..d48a557dd 100644 --- a/.github/workflows/binaries_dev.yml +++ b/.github/workflows/binaries_dev.yml @@ -53,7 +53,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed-large-disk @@ -68,7 +68,7 @@ jobs: release_tag: dev overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed-normal-disk @@ -102,7 +102,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed-large-disk @@ -117,7 +117,7 @@ jobs: release_tag: dev overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed-normal-disk diff --git a/.github/workflows/binaries_release0.yml b/.github/workflows/binaries_release0.yml index 38c233083..51cd482c2 100644 --- a/.github/workflows/binaries_release0.yml +++ b/.github/workflows/binaries_release0.yml @@ -38,7 +38,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed @@ -52,7 +52,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed diff --git a/.github/workflows/binaries_release1.yml b/.github/workflows/binaries_release1.yml index 88e59ad16..f98e7b556 100644 --- a/.github/workflows/binaries_release1.yml +++ b/.github/workflows/binaries_release1.yml @@ -38,7 +38,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed @@ -52,7 +52,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed diff --git a/.github/workflows/binaries_release2.yml b/.github/workflows/binaries_release2.yml index 4da7b5c6e..913e5f0c2 100644 --- a/.github/workflows/binaries_release2.yml +++ b/.github/workflows/binaries_release2.yml @@ -38,7 +38,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed @@ -52,7 +52,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed diff --git a/.github/workflows/binaries_release3.yml b/.github/workflows/binaries_release3.yml index 6c660c0ce..c5014f327 100644 --- a/.github/workflows/binaries_release3.yml +++ b/.github/workflows/binaries_release3.yml @@ -38,7 +38,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed @@ -52,7 +52,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed diff --git a/.github/workflows/binaries_release4.yml b/.github/workflows/binaries_release4.yml index 1fce19261..c07226ab8 100644 --- a/.github/workflows/binaries_release4.yml +++ b/.github/workflows/binaries_release4.yml @@ -39,7 +39,7 @@ jobs: build_flags: -tags elastic,ydb,gocdk,tikv pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 # build_flags: -tags 5BytesOffset # optional, default is - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed @@ -53,7 +53,7 @@ jobs: overwrite: true pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0 build_flags: -tags 5BytesOffset,elastic,ydb,gocdk,tikv - ldflags: -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} + ldflags: -s -w -extldflags -static -X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=${{github.sha}} # Where to run `go build .` project_path: weed binary_name: weed diff --git a/docker/Makefile b/docker/Makefile index 9e9d771c2..b473245e8 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -8,7 +8,7 @@ cgo ?= 0 binary: export SWCOMMIT=$(shell git rev-parse --short HEAD) export SWLDFLAGS="-X github.com/seaweedfs/seaweedfs/weed/util.COMMIT=$(SWCOMMIT)" - cd ../weed && CGO_ENABLED=$(cgo) GOOS=linux go build $(options) -tags "$(tags)" -ldflags "-extldflags -static $(SWLDFLAGS)" && mv weed ../docker/ + cd ../weed && CGO_ENABLED=$(cgo) GOOS=linux go build $(options) -tags "$(tags)" -ldflags "-s -w -extldflags -static $(SWLDFLAGS)" && mv weed ../docker/ binary_race: options = -race binary_race: cgo = 1