Freebsd support - #698
Open
mfechner wants to merge 2 commits into
Open
Conversation
Linux records a child's file-system accesses via a seccomp-user-notifications supervisor and macOS via Detours artifacts + an LD_PRELOAD interposer. FreeBSD has neither facility in this crate, so fspy previously could not be compiled there at all. Add a no-op backend so fspy builds on FreeBSD: the command is spawned and waited on normally, and PathAccessIterable::iter yields no entries. Callers (e.g. vp_command::run_command_with_fspy) keep working on FreeBSD — they simply observe zero path accesses, which is an honest result for a platform without tracing support. The change: - Adds src/freebsd.rs, a SpyImpl that spawns the command via into_tokio_command + tokio::task::spawn_blocking and returns an empty PathAccessIterable, mirroring the async shape of the Linux/macOS backends. - Routes os_impl to freebsd.rs under #[cfg(target_os = "freebsd")] in lib.rs, and gates the ipc and arena modules off FreeBSD. - Gates the Exec import and Command::get_exec/set_exec off FreeBSD in command.rs. - Moves fspy_shared_unix, nix, and fspy_preload_unix behind cfg(all(unix, not(target_os = "freebsd"))) in Cargo.toml, keeping them out of the FreeBSD build graph (and its fspy_nostd/fspy_client_unix subtree). bumpalo and materialized_artifact remain general dependencies since both are pure-Rust and FreeBSD-safe, and materialized_artifact is also used by the Windows backend.
fspy_nostd is the no_std low-level crate that fspy, fspy_shared,
fspy_shm, fspy_ipc_str, and fspy_nostd_alloc all depend on. Its
backends were gated to Linux, macOS, and Windows only, so on FreeBSD the
whole fspy build failed to compile — every one of these crates stopped
at fspy_nostd with "OsCStr"/"Error" undefined. This is the last
compilation blocker for the FreeBSD no-op backend from the accompanying
fspy change.
FreeBSD is a BSD, so rather than duplicating a fourth syscall surface the
crate routes it onto the existing libc-based macOS backends:
- mm (mmap/munmap/mprotect), param::page_size (sysconf), and fd
(close/AT_FDCWD) are API-identical to macOS and now shared.
- fs reuses the macOS openat/unlinkat/fstat/ftruncate backend.
- error::last_os_error uses libc::__error, present on FreeBSD.
Two pieces are Darwin-specific and are handled explicitly:
- F_GETPATH is a macOS fcntl command, so fcntl_getpath and the
F_GETPATH-based getcwd are macOS-only.
- FreeBSD implements getcwd with the standard getcwd(2) call,
normalizing the empty-buffer case to Error::RANGE to match the
macOS contract (FreeBSD reports it as EINVAL).
env and io remain off FreeBSD: their only consumers
(fspy_client_unix/fspy_shared_unix/fspy_preload_unix) are already
excluded from the FreeBSD build by the fspy no-op backend, and the
macOS env implementation relies on _NSGetArgv/_NSGetEnviron, which
FreeBSD does not expose.
freebsd-git
pushed a commit
to freebsd/freebsd-ports
that referenced
this pull request
Aug 24, 2026
Required patches are recorded upstream: voidzero-dev/vite-plus#2537 voidzero-dev/vite-task#698 voidzero-dev/vite-plus#2552
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Started to add FreeBSD support as mentioned here: voidzero-dev/vite-plus#2537