Skip to content

cmd/link: Windows build fails due to PE export cap #68405

@jgillich

Description

@jgillich

Go version

1.22.5

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\jakob\AppData\Local\go-build
set GOENV=C:\Users\jakob\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\jakob\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\jakob\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:/msys64/mingw64/lib/go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\msys64\mingw64\lib\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\msys64\home\jakob\seabird\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\msys64\tmp\go-build3132037066=/tmp/go-build -gno-record-gcc-switches

What did you do?

I am trying to build a program that uses gotk4 on Windows, which exports around 1050 functions with CGO.

Reproduction steps (Windows only, will need msys environment with gtk4 dependencies)

git clone https://github.com/getseabird/seabird.git && cd seabird
go generate ./...
go build main.go

What did you see happen?

The following error is returned by go:

_gotk4_gdkpixbuf2_PixbufLoaderClass_closed: pe dynexport table is full

It appears that there is currently a hard-coded limit of 1024 exports:

dexport = make([]loader.Sym, 0, 1024)

if len(dexport)+1 > cap(dexport) {

This error does not occur on Linux and macOS.

What did you expect to see?

The build should have completed.

Can the export limit be increased? Based on information I found, the PE export table limit should be around 65k. The choice of 1024 in Go seems arbitrary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windowscompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions