Skip to content

purego: use runtime/cgo instead of fakecgo on Go 1.28 and later - #574

Merged
hajimehoshi merged 2 commits into
ebitengine:mainfrom
matloob:main
Nov 26, 2026
Merged

hajimehoshi merged 2 commits into
ebitengine:mainfrom
matloob:main

Conversation

@matloob

@matloob matloob commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Go 1.28 has a pure assembly and Go implementation of runtime/cgo that can build with CGO_ENABLED=0 (GOEXPERIMENT=noruntimecgopurego can be set to disable it). Use that instead of fakecgo.

Once purego supports a minimum version of Go 1.28 in its go.mod file we should be able to delete fakecgo entirely.

For #565

What issue is this addressing?

Closes #565

What type of issue is this addressing?

feature

What this PR does | solves

This PR changes purego to use the pure assembly and Go runtime/cgo implementation that will be available on Go 1.28+ instead of using fakecgo.

Go 1.28 has a pure assembly and Go implementation of runtime/cgo
that can build with CGO_ENABLED=0 (GOEXPERIMENT=noruntimecgopurego
can be set to disable it). Use that instead of fakecgo.

Once purego supports a minimum version of Go 1.28 in its go.mod
file we should be able to delete fakecgo entirely.

For ebitengine#565

@TotallyGamerJet TotallyGamerJet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If someone disables the GOEXPERIMENT, runtimecgopurego shouldn't we still fall back to fakecgo?

@matloob

matloob commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

I added build tags to fall back to fakecgo when the goexperiment is disabled on go1.28 but always enabled in go1.29, with the expectation that we well remove the experiment in go1.29.

But the experiment is meant to be an emergency fallback in case bugs are encountered rather than a supported configuration

@TotallyGamerJet TotallyGamerJet left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Thanks

@matloob

matloob commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! How can I run the checks?

@TotallyGamerJet

Copy link
Copy Markdown
Collaborator

I approved them for you

@matloob

matloob commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks!!

@hajimehoshi hajimehoshi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@hajimehoshi
hajimehoshi merged commit 819b54d into ebitengine:main Nov 26, 2026
27 checks passed
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.

all: support Go 1.28's builtin no C compiler option

3 participants