Proposal: selectively reuse GOROOT assembly in replacement packages
Nobody has claimed this yet.
- Dominant language
- LLVM
- Stars
- 758
- Forks
- 49
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 138
Description
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
TEXTsymbol rather than enabling every.sfile 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.rawSyscallNoErrorand amd64syscall.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_EHDRin the process auxiliary vector - parse the vDSO ELF dynamic and version tables
- resolve supported symbols such as
__vdso_gettimeofdayand__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, orc-archivemodes - 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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing syscall/asm_linux_amd64.s, the existing replacement syscall implementation, and the behavior described in #2098. Inventory candidate symbols and determine whether reuse or the existing libc bridge is preferable, then investigate vDSO initialization and fallback behavior. Done means documented decisions, no duplicate symbols, validated errno and return values, and coverage for vDSO and fallback paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, linux
- Domain
- compilers, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100