# Shared WASI startup object This constructor adopts `PWD` before Rust calls `main`. The process table supplies `PWD` from the spawn request, not from the host environment. The constructor exits with status 1 if the directory does not exist. It preserves one `/` preopen and the whole-world view. Build the object before you build userland: ```sh nix develop -c nu --no-config-file userland/cwd-init/build.nu ``` Run workspace Cargo commands from `userland/` so Cargo loads `.cargo/config.toml`. Its rustflags request the startup object. The linker wrapper resolves the object path independently of each crate's directory. The builder must use the same rustflags, wrapper, and object for agent programs. The object also replaces libc's success/failure exit conversion with standard `wasi:cli/exit.exit-with-code`. Rust std on this toolchain does not use that interface directly. The host registers this gated standard function. The linker places the object before libc to resolve `_Exit` and `_exit`. Numeric exit codes use the usual low eight bits. `probe/` uses normal Rust APIs without startup code. It reads relative and absolute files or calls `std::process::exit` with its first argument. The standard `initial-cwd` import is preferable to `PWD`. The current Rust component does not declare that import. An upstream wasi-libc fix must declare it in the component type and initialize the local cwd before main. The fix must initialize cwd even when the linker omits `chdir` from program code.