Skip to content

internal/fakecgo: remove runtime.load_g references#456

Merged
hajimehoshi merged 1 commit into
ebitengine:mainfrom
gdams:crosscall
May 27, 2026
Merged

internal/fakecgo: remove runtime.load_g references#456
hajimehoshi merged 1 commit into
ebitengine:mainfrom
gdams:crosscall

Conversation

@gdams
Copy link
Copy Markdown
Contributor

@gdams gdams commented May 27, 2026

Summary

Go 1.27 (golang/go@aee6009) enforces stricter checklinkname for assembly symbols. runtime.load_g is now //go:linknamestd (std-only), causing linker errors for non-std packages that reference it:

link: main: invalid reference to runtime.load_g

Changes

crosscall2 (6 architectures: arm, arm64, loong64, ppc64le, riscv64, s390x):
Remove the load_g call — cgocallback already calls load_g internally, so the explicit call is unnecessary. The amd64 and 386 variants already did not call it.

setg_trampoline (ppc64le):
Replace the load_g call with a direct assignment to the g register from the saved newg argument, since setg_gcc has already stored it into TLS.

Status

This resolves the runtime.load_g linker error. The runtime.cgocallback reference remains and will need an upstream Go change or the -ldflags='-checklinkname=0' workaround until resolved upstream.

Go 1.27 (golang/go@aee6009) enforces stricter checklinkname for
assembly symbols. runtime.load_g is now //go:linknamestd (std-only),
causing linker errors for non-std packages that reference it.

In crosscall2, the load_g call is unnecessary because
runtime.cgocallback already calls load_g internally. Remove it from
all 6 architectures that had it (arm, arm64, loong64, ppc64le,
riscv64, s390x). The amd64 and 386 variants already did not call it.

In setg_trampoline on ppc64le, replace the load_g call with a direct
assignment to the g register from the saved newg argument, since
setg_gcc has already stored it into TLS.

This resolves the runtime.load_g linker error. The runtime.cgocallback
reference remains and will need an upstream Go change or the
-ldflags='-checklinkname=0' workaround until then.
Copy link
Copy Markdown
Collaborator

@TotallyGamerJet TotallyGamerJet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Member

@hajimehoshi hajimehoshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hajimehoshi hajimehoshi merged commit 1512f32 into ebitengine:main May 27, 2026
42 checks passed
@gdams gdams deleted the crosscall branch May 27, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants