cargo.build: a persistent build cache shared by all worlds
- The cargo target folder is <cache>/cargo-target, next to Wasmtime's cache, which moves to <cache>/wasmtime: Wasmtime's cleanup worker deletes unknown entries in its folder, also Cargo's artifacts. - Builds use the SDK at <cache>/sdk/<content hash>/, so cargo reuses the compiled SDK in every world. /plugins/cargo/sdk/ stays for agents. - Tests run in the release profile and share compiled crates with the release build. - The cargo and cli tests use a persistent cache in CARGO_TARGET_TMPDIR: warm, the cargo suite takes 11 s (was 235 s) and the cli suite 6 s (was 149 s). - nix flake check runs ignored stress tests. AGENTS.md: rules for fast tests.
This commit is contained in:
+7
-4
@@ -411,16 +411,19 @@ The core has one native plugin: `cargo`. `cargo.build {"plugin": "notes"}`
|
||||
builds `/plugins/notes/source/`:
|
||||
|
||||
1. It copies the source once. The tests and the build both use this copy.
|
||||
2. It runs the tests under WASI.
|
||||
3. It builds the release `.wasm` for `wasm32-wasip2`.
|
||||
2. It runs the tests under WASI, in the release profile.
|
||||
3. It builds the release `.wasm` for `wasm32-wasip2`. The tests and the build
|
||||
share the compiled dependencies.
|
||||
4. It returns `{"wasm": "/state/cargo/builds/<n>/notes.wasm", "tests":
|
||||
{"passed", "failed", "output"}, "warnings"}`. If a step fails, it returns
|
||||
an error with the compiler or test output.
|
||||
|
||||
- A call to `cargo.build` gets a process ID, a folder in `/proc`, and journal
|
||||
entries, like other calls.
|
||||
- The dependency `sausage-plugin = "0.1"` points to the SDK copy at
|
||||
`/plugins/cargo/sdk/`.
|
||||
- `/plugins/cargo/sdk/` shows the source of the SDK. The dependency
|
||||
`sausage-plugin = "0.1"` points to the same files in the host's cache.
|
||||
- Compiled crates stay in the host's cache, outside the world, and all worlds
|
||||
share them. So a second build compiles only what changed.
|
||||
- Build scripts can compile C: `CC_wasm32_wasip2` and `AR_wasm32_wasip2`
|
||||
point to a WASI clang.
|
||||
- The build does not activate the result. Call `core.activate` next.
|
||||
|
||||
Reference in New Issue
Block a user