Problem
On Darwin with Go 1.26, a C library whose exported Go function uses fmt cannot be linked. After the generic c-shared PIC/runtime-library blockers found while extending #2083 are removed, ld64.lld reports missing Go 1.26 runtime hooks from internal/synctest and Darwin CPU initialization.
This is separate from the funcinfo relocation/C ABI work in #2083: a runtime-only export using runtime.Callers and a goroutine can build, link, load, and execute, while adding fmt.Sprintf pulls in the missing hooks below.
Reproducer
package main
import "fmt"
//export Format
func Format(value string, number int) string {
return fmt.Sprintf("%s:%d", value, number)
}
func main() {}
llgo build -buildmode=c-shared -o export .
Environment used:
- xgo-dev/llgo main
2c9d1897dbfaabe78c08e56a2ff77f0f6b2bbcca
- Go 1.26.5
- LLVM/Clang 19.1.7
- macOS arm64
Actual result
ld64.lld reports unresolved symbols including:
internal/synctest.acquire
internal/synctest.release
internal/synctest.inBubble
internal/cpu.sysctlbynameBytes
internal/cpu.sysctlbynameInt32
internal/synctest.Acquire itself is present, but its lowercase runtime hooks are not. The Darwin internal/cpu package likewise expects sysctl helpers that are not supplied to the external link.
Linux arm64 with Go 1.24.2 builds the equivalent fmt probe, but that does not exercise the new Go 1.26 internal/synctest dependency. This should be covered natively with Go 1.26 on both Darwin and Linux.
Expected result
Exported functions in c-shared and c-archive libraries can use supported standard-library packages such as fmt, and a C consumer can link and execute them.
Suggested coverage
Related: #2083, #2088
Problem
On Darwin with Go 1.26, a C library whose exported Go function uses
fmtcannot be linked. After the genericc-sharedPIC/runtime-library blockers found while extending #2083 are removed,ld64.lldreports missing Go 1.26 runtime hooks frominternal/synctestand Darwin CPU initialization.This is separate from the funcinfo relocation/C ABI work in #2083: a runtime-only export using
runtime.Callersand a goroutine can build, link, load, and execute, while addingfmt.Sprintfpulls in the missing hooks below.Reproducer
Environment used:
2c9d1897dbfaabe78c08e56a2ff77f0f6b2bbccaActual result
ld64.lldreports unresolved symbols including:internal/synctest.Acquireitself is present, but its lowercase runtime hooks are not. The Darwininternal/cpupackage likewise expects sysctl helpers that are not supplied to the external link.Linux arm64 with Go 1.24.2 builds the equivalent
fmtprobe, but that does not exercise the new Go 1.26internal/synctestdependency. This should be covered natively with Go 1.26 on both Darwin and Linux.Expected result
Exported functions in
c-sharedandc-archivelibraries can use supported standard-library packages such asfmt, and a C consumer can link and execute them.Suggested coverage
internal/synctestruntime hooks/source patchesinternal/cpusysctl hooksfmt.SprintfRelated: #2083, #2088