internal/fakecgo: remove runtime.load_g references#456
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Go 1.27 (
golang/go@aee6009) enforces stricterchecklinknamefor assembly symbols.runtime.load_gis now//go:linknamestd(std-only), causing linker errors for non-std packages that reference it:Changes
crosscall2 (6 architectures: arm, arm64, loong64, ppc64le, riscv64, s390x):
Remove the
load_gcall —cgocallbackalready callsload_ginternally, so the explicit call is unnecessary. The amd64 and 386 variants already did not call it.setg_trampoline (ppc64le):
Replace the
load_gcall with a direct assignment to thegregister from the savednewgargument, sincesetg_gcchas already stored it into TLS.Status
This resolves the
runtime.load_glinker error. Theruntime.cgocallbackreference remains and will need an upstream Go change or the-ldflags='-checklinkname=0'workaround until resolved upstream.