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:

https://github.com/golang/go/blob/4e77872d16340595d76b905fe24369b76cfd1b5f/src/cmd/link/internal/ld/pe.go#L310

https://github.com/golang/go/blob/4e77872d16340595d76b905fe24369b76cfd1b5f/src/cmd/link/internal/ld/pe.go#L1393

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.

Comment From: gabyhelp

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: gopherbot

Change https://go.dev/cl/597956 mentions this issue: cmd/link: raise pe export cap to 65535