Skip to content

[Based on #2090] runtime: support Go 1.26 in C libraries#2098

Open
cpunion wants to merge 3 commits into
xgo-dev:mainfrom
cpunion:codex/go126-c-library-runtime-hooks
Open

[Based on #2090] runtime: support Go 1.26 in C libraries#2098
cpunion wants to merge 3 commits into
xgo-dev:mainfrom
cpunion:codex/go126-c-library-runtime-hooks

Conversation

@cpunion

@cpunion cpunion commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Depends on #2090

Problem

Go 1.26 standard-library code retained by c-shared and c-archive needs runtime hooks LLGo did not provide. This caused unresolved symbols on Darwin. On Linux, the generated shared-library constructor could fail to initialize the runtime and reflection ABI tables before C first called an exported Go function.

Fix

  • add the missing Go 1.26 synctest, Darwin sysctl, and Linux syscall/time runtime hooks;
  • initialize the runtime and reflection ABI tables before C calls Go;
  • emit the Linux c-shared constructor in .init_array, while retaining platform constructor lowering for c-archive and Darwin;
  • exercise fmt.Sprintf, goroutines, funcinfo, platform syscall paths, and DWARF lookup from real C consumers.

After rebasing onto current main, the Darwin sysctl additions extend os_darwin.go instead of duplicating the bridge already merged by #2150.

This PR has an independent diff of +187/-25 across 11 files. The broader standard-library package matrix remains in #2134.

Validation

  • macOS arm64 / Go 1.26.5: focused build tests and real LLGo runtime/debug execution pass.
  • Ubuntu arm64 / Go 1.26.5 / LLVM 19.1.7: executable, c-shared, and c-archive C runners pass in an 8 GiB, 2 CPU, no-swap container.
  • TestDefineLibraryRuntimeInitInitializesAbiTypes covers constructor call order.
  • No existing test is skipped or ignored.

Closes #2096.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cpunion cpunion added go1.26 Go 1.26 compatibility and support bugfix Fixes an existing bug or regression labels Jul 16, 2026
@cpunion
cpunion force-pushed the codex/go126-c-library-runtime-hooks branch 2 times, most recently from 75c7b56 to 4b2d5d1 Compare July 19, 2026 13:38
@cpunion cpunion changed the title runtime: add Go 1.26 C library hooks runtime: add missing C-library runtime hooks Jul 19, 2026
@cpunion
cpunion marked this pull request as draft July 19, 2026 15:23
@cpunion
cpunion force-pushed the codex/go126-c-library-runtime-hooks branch from bab45a2 to dc28e83 Compare July 19, 2026 17:04
@cpunion cpunion changed the title runtime: add missing C-library runtime hooks runtime: complete stdlib functional coverage across build modes Jul 19, 2026
@cpunion cpunion changed the title runtime: complete stdlib functional coverage across build modes runtime: complete stdlib support and functional coverage across build modes Jul 19, 2026
@cpunion
cpunion force-pushed the codex/go126-c-library-runtime-hooks branch from 037745f to de1b304 Compare July 20, 2026 01:05
@cpunion cpunion changed the title runtime: complete stdlib support and functional coverage across build modes runtime: complete stdlib package coverage across build modes Jul 20, 2026
@cpunion
cpunion marked this pull request as ready for review July 20, 2026 01:46
@cpunion
cpunion marked this pull request as draft July 20, 2026 01:49
@cpunion
cpunion force-pushed the codex/go126-c-library-runtime-hooks branch from de1b304 to 048bea5 Compare July 20, 2026 03:03
@cpunion cpunion changed the title runtime: complete stdlib package coverage across build modes runtime: add Go 1.26 C library hooks Jul 20, 2026
@cpunion
cpunion marked this pull request as ready for review July 20, 2026 03:25
@cpunion
cpunion force-pushed the codex/go126-c-library-runtime-hooks branch from 048bea5 to e4cc229 Compare July 20, 2026 06:00
@cpunion cpunion changed the title runtime: add Go 1.26 C library hooks [Based on #2090] runtime: add Go 1.26 C library hooks Jul 20, 2026
@cpunion cpunion changed the title [Based on #2090] runtime: add Go 1.26 C library hooks [Based on #2090] runtime: support Go 1.26 in C libraries Jul 20, 2026
@cpunion
cpunion force-pushed the codex/go126-c-library-runtime-hooks branch 2 times, most recently from 20269d2 to b91e889 Compare July 23, 2026 10:50
cpunion added 2 commits July 24, 2026 11:25
Provide the synctest, Darwin CPU, Linux gettimeofday, and all-thread syscall hooks required by Go 1.26 standard-library code in c-shared and c-archive builds. Extend the export demo so C consumers link and execute fmt, goroutine, syscall, funcinfo, and explicit DWARF paths in both library modes.
@cpunion
cpunion force-pushed the codex/go126-c-library-runtime-hooks branch from b91e889 to eed7973 Compare July 24, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes an existing bug or regression go1.26 Go 1.26 compatibility and support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: Go 1.26 C libraries miss runtime hooks on Darwin and Linux

1 participant