From 2b65ef5710e45d00bd62f568eea7acaf82db1580 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 24 Mar 2025 10:49:59 +0100 Subject: [PATCH] backend/gs: disable GRPC API to reduce binary size bloat Since cloud.google.com/go/storage v1.44.0 the GRPC API is enabled by default. However, this causes the restic binary size to explode by 20MB. So just disable it again. --- build.go | 14 ++++++++------ helpers/build-release-binaries/main.go | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build.go b/build.go index 0f4e80c91..e6237bf21 100644 --- a/build.go +++ b/build.go @@ -53,12 +53,14 @@ import ( // config contains the configuration for the program to build. var config = Config{ - Name: "restic", // name of the program executable and directory - Namespace: "github.com/restic/restic", // subdir of GOPATH, e.g. "github.com/foo/bar" - Main: "./cmd/restic", // package name for the main package - DefaultBuildTags: []string{"selfupdate"}, // specify build tags which are always used - Tests: []string{"./..."}, // tests to run - MinVersion: GoVersion{Major: 1, Minor: 23, Patch: 0}, // minimum Go version supported + Name: "restic", // name of the program executable and directory + Namespace: "github.com/restic/restic", // subdir of GOPATH, e.g. "github.com/foo/bar" + Main: "./cmd/restic", // package name for the main package + // disable_grpc_modules is necessary to reduce the binary size since cloud.google.com/go/storage v1.44.0 + // see https://github.com/googleapis/google-cloud-go/issues/11448 + DefaultBuildTags: []string{"selfupdate", "disable_grpc_modules"}, // specify build tags which are always used + Tests: []string{"./..."}, // tests to run + MinVersion: GoVersion{Major: 1, Minor: 23, Patch: 0}, // minimum Go version supported } // Config configures the build. diff --git a/helpers/build-release-binaries/main.go b/helpers/build-release-binaries/main.go index 8fe8c24fb..d01bd93c1 100644 --- a/helpers/build-release-binaries/main.go +++ b/helpers/build-release-binaries/main.go @@ -106,7 +106,9 @@ func build(sourceDir, outputDir, goos, goarch string) (filename string) { } outputFile := filepath.Join(outputDir, filename) - tags := "selfupdate" + // disable_grpc_modules is necessary to reduce the binary size since cloud.google.com/go/storage v1.44.0 + // see https://github.com/googleapis/google-cloud-go/issues/11448 + tags := "selfupdate,disable_grpc_modules" if opts.Tags != "" { tags += "," + opts.Tags }