build: make c-shared and c-archive outputs usable from C#2083
Merged
xushiwei merged 9 commits intoJul 18, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This was referenced Jul 13, 2026
cpunion
marked this pull request as ready for review
July 14, 2026 00:05
cpunion
force-pushed
the
codex/funcinfo-cshared-relocations
branch
from
July 15, 2026 10:36
3d99272 to
0b7858b
Compare
This was referenced Jul 15, 2026
12 tasks
cpunion
force-pushed
the
codex/funcinfo-cshared-relocations
branch
from
July 17, 2026 12:44
c1519da to
7858ab9
Compare
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.
Problem
ELF
c-sharedlinks reject funcinfo metadata relocations because site records contain absolute pointers in non-writable sections. Once exported Go functions are actually retained, the same issue also appears in compiler-emitted PC/line records.The generated C libraries had several additional usability gaps:
c-sharedpackage archives did not retain unreferenced//exportfunctions, so the header declared symbols that were absent from the shared libraryc-archivestored package.afiles as nested archive members, which C linkers cannot searchc-sharedwere not compiled as PICos.executablePathreference prevented runtime-backed C libraries from linkingChanges
SHF_LINK_ORDERand GNU retain semantics//exportsymbol as ac-sharedlinker root on ELF and Mach-Oc-archiveoutputs withllvm-arMRIADDLIB/ADDMODcommands so package archives are flattened into ordinary object members-fPICforc-sharedos.executablePathfallback needed whenruntimeis linked withoutosruntime.Callers,CallersFrames, andFuncForPCsymbol/file/line lookupllvm-arselection, paths containing spaces, flat archive membership, and tool failuresgo.modrequirementThis is a generic C-library and shared-library metadata fix extracted from #2079. It has no TLS/GLS dependency and is based directly on
xgo-dev/llgomain.The separate Go 1.26 standard-library hook gap found with an exported function using
fmt.Sprintfis tracked in #2096 and is intentionally not included here.The ELF Full LTO PC-line anchor issue is handled independently by #2097. When the branches are combined, its local-label anchor must retain this PR's writable
awosection flags.Testing
_demo/go/export/test.shpassesCallers/FuncForPC_demo/go/export/test.shpasses.soand static archive C executables run through the same runtime and ABI assertionsinternal/header: 92.3%; the changed export-filter and missing-export paths are coveredinternal/build: 71.9%; all new build/header helpers: 100%internal/cabi: 96.4%runtime/internal/clite/libuvcompiles successfullyinternal/build,internal/header, andinternal/cabipass locally withGOMAXPROCS=2,GOMEMLIMIT=6GiB, and-p=1_demo/go/export/test.shpasses on macOS arm64 and in an Ubuntu arm64 container limited to 15 GiB, 2 CPUs, and 512 PIDs; both shared and static C consumers execute all assertions