Remove the libc getpagesize dependency from Linux memory providers
- Dominant language
- Rust
- Stars
- 53
- Forks
- 16
- Avg merge
- 4h 22m
- Merged PRs (30d)
- 46
Description
Linux memory allocation/free use raw mmap/munmap syscalls, but `sys_page_size` in the amd64, arm64 and riscv64 providers declares and calls the libc `getpagesize` symbol. LoongArch64 re-exports the RISC-V memory provider, so it inherits the same dependency. Calling the page helpers therefore still requires a libc symbol even though the Linux sys layer is intended to supply native primitives without libc bindings.
A hardcoded 4096 return is not a sufficient replacement: the implementation must obtain the actual runtime page size on supported configurations.
Code evidence:
- [std/sys/linux/amd64/memory.wave:38](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/std/sys/linux/amd64/memory.wave#L38)
- [std/sys/linux/arm64/memory.wave:31](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/std/sys/linux/arm64/memory.wave#L31)
- [std/sys/linux/riscv64/memory.wave:31](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/std/sys/linux/riscv64/memory.wave#L31)
- [std/sys/linux/loong64/memory.wave:6](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/std/sys/linux/loong64/memory.wave#L6)
- [std/mem/alloc.wave:177](https://github.com/wavefnd/Wave/blob/ea74c2dafc31da876e5561f2d176ba719f5a0458/std/mem/alloc.wave#L177)
Acceptance:
- [ ] Obtain page size from native Linux startup/kernel information, such as a correctly integrated AT_PAGESZ path, without adding another libc wrapper.
- [ ] Keep the same public page-size/rounding helpers and avoid assuming that every supported system uses 4 KiB pages.
- [ ] Add a no-libc link fixture that actually calls sys_page_size and the relevant memory page helper, so an unused-function optimization cannot hide the dependency.
- [ ] Validate the returned value against the native environment on amd64, arm64, riscv64 and loong64, including an available non-4-KiB configuration.
- [ ] Define error/fallback behavior when startup metadata is unavailable and retain existing allocation/free correctness.
Reference: [Linux getpagesize library and architecture notes](https://man7.org/linux/man-pages/man2/getpagesize.2.html). Related #515 is specifically event/vectored I/O and #371 covers freestanding startup; this issue is the independent memory-provider dependency.
Audit status: static source inspection against canonical master `ea74c2dafc31da876e5561f2d176ba719f5a0458` on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.
Contributor guide
Research direction
Read std/sys/linux/amd64/memory.wave, arm64/memory.wave, riscv64/memory.wave, loong64/memory.wave, and std/mem/alloc.wave, starting with sys_page_size and the existing startup/sys-layer paths. Add a no-libc link fixture that calls the page-size and memory helpers, then validate native page sizes on all four architectures, including a non-4-KiB configuration. Done means the dependency is removed without changing public helpers or allocation/free correctness, with defined missing-metadata behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100