UPSTREAM PR #2471: feat: add WASI (wasm32-wasip2) platform support#33
UPSTREAM PR #2471: feat: add WASI (wasm32-wasip2) platform support#33loci-dev wants to merge 1 commit into
Conversation
Add compilation support for the `wasm32-wasip2` target across four crates: **gix-path**: Enable `#![feature(wasip2)]` via `cfg_attr` for WASI builds, required for `std::os::wasi` path handling. **gix-fs/symlink**: Split `#[cfg(not(windows))]` into separate `#[cfg(unix)]` and `#[cfg(target_os = "wasi")]` blocks. WASI uses `std::fs::soft_link` since `std::os::unix::fs::symlink` is unavailable. `remove()` and `is_collision_error()` use `#[cfg(any(unix, target_os = "wasi"))]`. **gix-fs/capabilities**: Add a `Default` impl for `Capabilities` on WASI (no executable bit, symlinks enabled, no case-folding or unicode precomposition). **gix-index/fs**: Replace `#[cfg(not(windows))]` / `#[cfg(windows)]` pairs with `#[cfg(unix)]` / `#[cfg(not(unix))]`. This groups WASI with Windows for metadata access, using `std::fs::Metadata` instead of `rustix::fs::Stat` (rustix doesn't support WASI). The `system_time_from_secs_nanos` helper is now `#[cfg(unix)]` only. These changes allow gitoxide to compile (and partially function) under WASI sandboxed environments such as Wasmtime.
OverviewAnalysis of WASI platform support addition (commit 43bf94d) across two binaries shows negligible performance impact. Total functions: 34,636 (6,159 modified, 8,250 new, 8,282 removed). Power consumption:
Function AnalysisStandard library I/O improvements (performance-critical):
Regressions in non-critical paths:
Compiler-generated changes: Multiple Source code context: Single commit added WASI platform support to gix-fs, gix-path, and gix-config-value with compile-time conditionals. Changes don't affect aarch64-linux target directly. Observed performance differences stem from compiler optimizations, standard library updates, and external dependency changes rather than application code modifications. Additional FindingsPerformance-critical Git operations (pack handling, object database access, diff algorithms) remain unaffected. Core I/O primitives show improvements through better lock acquisition (-2.6% in 🔎 Full breakdown: Loci Inspector |
0223bcb to
bfaee00
Compare
0e47b1e to
8b02847
Compare
96cdaee to
cdbe120
Compare
9c2e45d to
5124e99
Compare
1c8b114 to
e902b63
Compare
c6739bc to
6f67b12
Compare
Note
Source pull request: GitoxideLabs/gitoxide#2471
Summary
Add compilation support for the
wasm32-wasip2target across four crates, enabling gitoxide to compile under WASI sandboxed environments such as Wasmtime.Changes
#![feature(wasip2)]viacfg_attrfor WASI builds, required forstd::os::wasipath handling#[cfg(not(windows))]into separate#[cfg(unix)]and#[cfg(target_os = "wasi")]blocks — WASI usesstd::fs::soft_linksincestd::os::unix::fs::symlinkis unavailableDefaultimpl forCapabilitieson WASI (no executable bit, symlinks enabled, no case-folding or unicode precomposition)#[cfg(not(windows))]/#[cfg(windows)]with#[cfg(unix)]/#[cfg(not(unix))], grouping WASI with Windows for metadata access viastd::fs::Metadatainstead ofrustix::fs::StatMotivation
We're compiling the GitButler CLI (
but) towasm32-wasip2to run git operations inside sandboxed WASI agents. These four changes were the minimum needed to get gitoxide compiling for this target.Notes
#![feature(wasip2)]in gix-path requires nightly orRUSTC_BOOTSTRAP=1on stable — this is a temporary requirement untilstd::os::wasistabilizesrustixdoesn't support WASI, sogix-indexfalls back tostd::fs::Metadata(same as Windows)#[cfg]paths are preservedTest plan
cargo build --target wasm32-wasip2succeeds for a downstream consumer (GitButlerbutCLI)