Description
Go version
go version go1.24.0 linux/arm64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/ayke/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ayke/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1340575841=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/ayke/src/tinygo/tinygo/go.mod'
GOMODCACHE='/home/ayke/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ayke'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go1.24.0'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/ayke/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go1.24.0/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
I ran the code here: https://go.dev/play/p/SzYsA_F4wwR
What did you see happen?
In Go 1.23, it reports the following error:
got type checking error: -: undefined: C.FOO
got type checking error: test.go:5:6: undefined: BAR
In Go 1.24, it reports only the following error:
got type checking error: test.go:5:6: undefined: BAR
What did you expect to see?
I expected the C.FOO
undefined error to still be reported.
This is a regression from 5bd442a (see #68183). We relied on the previous behavior for CGo support in TinyGo: we replaced all C.foo strings with a literal "C.foo"
identifier and defined functions and constants and such with a similar name. This worked very well and led to nice error messages (such as the "undefined: C.FOO" message above, instead of having to use name mangling).
I'm not sure how to best fix this. I see that 5bd442a fixes a real bug, but in our case it's a regression. We can use name mangling to work around this, making the CGo error messages less nice. We can do some search-and-replace on the error messages to work around the name mangling, but I'm afraid that's going to be fragile. Name mangling is probably the easiest short-term fix (since we need Go 1.24 support) but if there's any way this can be fixed upstream that would be great.