Skip to content

cmd/link: binary size increase with Go 1.26 #77235

@pgimalac

Description

@pgimalac

Go version

1.26rc2

Output of go env in your module/workspace:

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE='auto'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/pierre.gimalac/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/pierre.gimalac/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/zp/m8h1x16s30g3f656sxsdt7rm0000gp/T/go-build2439715533=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/pierre.gimalac/pgimalac/kubernetes/go.mod'
GOMODCACHE='/Users/pierre.gimalac/go/pkg/mod'
GONOPROXY=''
GONOSUMDB='github.com/DataDog,go.ddbuild.io'
GOOS='darwin'
GOPATH='/Users/pierre.gimalac/go'
GOPRIVATE=''
GOPROXY='https://depot-read-api-go.us1.ddbuild.io/magicmirror/magicmirror/@current,https://depot-read-api-go.us1.ddbuild.io/magicmirror/testing/@current,proxy.golang.org,direct'
GOROOT='/Users/pierre.gimalac/sdk/go1.26rc2'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/pierre.gimalac/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='go1.26rc2'
GOTOOLDIR='/Users/pierre.gimalac/sdk/go1.26rc2/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.26rc2'
GOWORK='/Users/pierre.gimalac/pgimalac/kubernetes/go.work'
PKG_CONFIG='pkg-config'

What did you do?

I tried building various binaries with go 1.25.6 and go 1.26rc2, and consistently observed a non-negligible (between 300kiB and 1.3MiB) binary size increase, mostly proportional to code size, for binaries ranging from 20MiB to 100MiB.

#77049 (comment) (cc @cherrymui) mentions a fixed 300kiB increase, which is not what I observed.

a small (~300K) fixed-size increase, not proportional to user code size.

I mostly want to ensure this size increase is known/expected (it's not really a blocker for me in practice) as it doesn't match what was mentioned in the other issue.

What did you see happen?

For kubernetes binaries (darwin/arm64):

Binary Go 1.25.6 Go 1.26rc2 Delta
kube-apiserver 77.9 MiB 78.9 MiB +1081 KiB
kube-controller-manager 64.6 MiB 65.6 MiB +1031 KiB
kube-proxy 38.3 MiB 39.1 MiB +853 KiB
kube-scheduler 43.7 MiB 44.5 MiB +886 KiB
kubelet 48.5 MiB 49.4 MiB +982 KiB

If you want to reproduce:

git clone https://github.com/kubernetes/kubernetes.git
cd kubernetes
go get google.golang.org/protobuf@cb6ac5a # fix https://github.com/golang/protobuf/issues/1704
go work vendor
GOTOOLCHAIN=go1.26rc2 make kube-apiserver kubelet kube-controller-manager kube-scheduler kube-proxy
ls -l _output/bin/

For datadog-agent binaries (linux/arm64):

Binary Go 1.25.6 Go 1.26rc2 Delta
agent 102.2 MiB 103.5 MiB +1356 KiB
process-agent 31.1 MiB 31.7 MiB +589 KiB
security-agent 28.8 MiB 29.2 MiB +461 KiB
system-probe 56.5 MiB 57.5 MiB +973 KiB
trace-agent 20.9 MiB 21.2 MiB +334 KiB

What did you expect to see?

A smaller size increase, or ideally none at all.

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.binary-sizecompiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions