Background
LLGo can translate selected Plan 9 assembly for ordinary and additive packages, but replacement packages intentionally skip the original GOROOT .s files. As a result, the replacement syscall package implements rawSyscallNoError through libc syscall, and PR #2098 adds an amd64 gettimeofday libc bridge because the matching Go implementation lives in syscall/asm_linux_amd64.s.
These bridges are correct, but they add a libc dependency and duplicate behavior already maintained by Go. This is a focused follow-up to #1582, not a return to a second general syscall intrinsic system.
Proposal
Evaluate an explicit, target-aware allowlist for reusing selected GOROOT assembly from replacement packages.
- select by package, GOOS, GOARCH, and preferably
TEXT symbol rather than enabling every .s file in the package
- pass selected code through the existing Plan 9 assembly translator and ABI validation
- diagnose duplicate or incompatible symbols instead of silently preferring one implementation
- keep replacement-package assembly as the default; GOROOT reuse must be opt-in
- first evaluate Linux
syscall.rawSyscallNoError and amd64 syscall.gettimeofday
Symbol-level selection matters because one upstream file may also define helpers such as rawVforkSyscall, which LLGo already handles separately.
Linux vDSO initialization
The amd64 Go gettimeofday assembly first calls runtime.vdsoGettimeofdaySym when available and falls back to SYS_gettimeofday. A vDSO is a small kernel-provided ELF image mapped into each process; calling it avoids a kernel transition while preserving kernel timekeeping semantics.
Reusing this assembly therefore also requires LLGo to initialize the vDSO symbol table:
- locate
AT_SYSINFO_EHDR in the process auxiliary vector
- parse the vDSO ELF dynamic and version tables
- resolve supported symbols such as
__vdso_gettimeofday and __vdso_clock_gettime
- publish the resolved addresses expected by reused Go assembly
- retain a raw-syscall fallback when the vDSO or a symbol is unavailable
C-library modes need special consideration because LLGo does not own process startup. Initialization must work when loaded by a foreign executable and must not assume the Go runtime startup path.
Necessity and scope
This facility is justified only if an inventory finds multiple self-contained helpers whose reuse materially improves correctness, portability, performance, or dependency reduction. If gettimeofday is the only useful case, the small libc bridge in #2098 is preferable to a new selection mechanism.
Android, seccomp environments, embedded targets, and architectures unsupported by the assembly translator must keep appropriate libc or LLGo-specific fallbacks.
Acceptance criteria
- document the candidate inventory and the keep-bridge versus reuse decision for each symbol
- no duplicate symbols in executable,
c-shared, or c-archive modes
- test return values and errno behavior, not only symbol resolution
- test vDSO present and forced-fallback paths on Linux amd64
- preserve the existing target and Go-version compatibility matrix
Related: #1582, #1690, #2098
Background
LLGo can translate selected Plan 9 assembly for ordinary and additive packages, but replacement packages intentionally skip the original GOROOT
.sfiles. As a result, the replacementsyscallpackage implementsrawSyscallNoErrorthrough libcsyscall, and PR #2098 adds an amd64gettimeofdaylibc bridge because the matching Go implementation lives insyscall/asm_linux_amd64.s.These bridges are correct, but they add a libc dependency and duplicate behavior already maintained by Go. This is a focused follow-up to #1582, not a return to a second general syscall intrinsic system.
Proposal
Evaluate an explicit, target-aware allowlist for reusing selected GOROOT assembly from replacement packages.
TEXTsymbol rather than enabling every.sfile in the packagesyscall.rawSyscallNoErrorand amd64syscall.gettimeofdaySymbol-level selection matters because one upstream file may also define helpers such as
rawVforkSyscall, which LLGo already handles separately.Linux vDSO initialization
The amd64 Go
gettimeofdayassembly first callsruntime.vdsoGettimeofdaySymwhen available and falls back toSYS_gettimeofday. A vDSO is a small kernel-provided ELF image mapped into each process; calling it avoids a kernel transition while preserving kernel timekeeping semantics.Reusing this assembly therefore also requires LLGo to initialize the vDSO symbol table:
AT_SYSINFO_EHDRin the process auxiliary vector__vdso_gettimeofdayand__vdso_clock_gettimeC-library modes need special consideration because LLGo does not own process startup. Initialization must work when loaded by a foreign executable and must not assume the Go runtime startup path.
Necessity and scope
This facility is justified only if an inventory finds multiple self-contained helpers whose reuse materially improves correctness, portability, performance, or dependency reduction. If
gettimeofdayis the only useful case, the small libc bridge in #2098 is preferable to a new selection mechanism.Android, seccomp environments, embedded targets, and architectures unsupported by the assembly translator must keep appropriate libc or LLGo-specific fallbacks.
Acceptance criteria
c-shared, orc-archivemodesRelated: #1582, #1690, #2098