Commit bfb16b1
feat(macos): port the native runtime + sidecar to macOS
The native stack previously compiled only on Linux. This adds macOS
(aarch64/x86_64) support, gated entirely behind cfg(target_os) so the Linux
paths are untouched.
v8-runtime (per-thread CPU accounting):
- timeout.rs: pthread_getcpuclockid has no macOS equivalent; the CpuBudgetGuard
watchdog now reads the execution thread's CPU time via the Mach thread port
(pthread_mach_thread_np + thread_info(THREAD_BASIC_INFO)), readable
cross-thread like the Linux clockid.
- bridge.rs: RUSAGE_THREAD is Linux-only; process.cpuUsage/resourceUsage get
per-thread CPU time from thread_info, the rest best-effort from RUSAGE_SELF.
sidecar (host-mount filesystem confinement):
- macos_fs.rs: macOS has no openat2(RESOLVE_BENEATH); resolve-beneath path
resolution now goes through cap-std (audited userspace walk; openat2 on Linux,
fd-relative O_NOFOLLOW walk elsewhere). F_GETPATH replaces readlink on
/proc/self/fd; /dev/fd/N replaces /proc/self/fd/N.
- host_dir.rs + filesystem.rs: open_beneath / mapped-runtime helpers resolve via
cap-std on macOS; O_PATH -> read-only anchor, O_TMPFILE -> empty. All nine
mapped-runtime child ops (mkdir/rmdir/unlink/symlink/rename/readlink/lstat/
lutimes) converted from the Linux /proc/self/fd-join idiom to fd-relative *at
calls, since /dev/fd/N cannot have children appended. lstat goes through a
platform-neutral HostStat translator; rename uses renameat with a real-path
EXDEV fallback. Also fixes a latent dangling-fd bug in the mapped utimes path
(the resolved handle is now held across the operation on both platforms).
- execution.rs: waitid/WNOWAIT is unavailable in nix on macOS; the child-status
poll uses waitpid(WNOHANG) there.
- Plus latent macOS type-width fixes (mode_t/dev_t/nlink_t).
All sidecar lib tests pass on macOS, including every host-mount escape test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 19f34bd commit bfb16b1
9 files changed
Lines changed: 915 additions & 98 deletions
File tree
- crates
- sidecar
- src
- plugins
- v8-runtime/src
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | 65 | | |
61 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
20991 | 20995 | | |
20992 | 20996 | | |
20993 | 20997 | | |
| 20998 | + | |
20994 | 20999 | | |
20995 | 21000 | | |
20996 | 21001 | | |
| |||
21016 | 21021 | | |
21017 | 21022 | | |
21018 | 21023 | | |
| 21024 | + | |
| 21025 | + | |
| 21026 | + | |
| 21027 | + | |
| 21028 | + | |
| 21029 | + | |
| 21030 | + | |
| 21031 | + | |
| 21032 | + | |
| 21033 | + | |
| 21034 | + | |
| 21035 | + | |
| 21036 | + | |
| 21037 | + | |
| 21038 | + | |
| 21039 | + | |
| 21040 | + | |
| 21041 | + | |
| 21042 | + | |
| 21043 | + | |
| 21044 | + | |
| 21045 | + | |
| 21046 | + | |
| 21047 | + | |
21019 | 21048 | | |
21020 | 21049 | | |
21021 | 21050 | | |
| |||
0 commit comments