Rust Real-Time Audit
Verify that a Rust DSP crate respects the real-time-safety rules:
- The crate is
#![no_std]and does not depend onalloc. - The crate uses
panic = "abort"so panics cannot unwind across an FFI or worklet boundary. - No clippy-detectable panic-prone constructs (
unwrap,expect, slice indexing, integer overflow) are present. - No banned heap/blocking constructs (
Vec::,Box::,Mutex,format!,println!, etc.) appear in the source. - The compiled LLVM-IR contains no calls to
__rust_alloc/__rust_realloc/__rust_dealloc.
The first four are cheap and run in seconds. The fifth is the authoritative check — a clean grep can lie, but an IR with no allocator symbols cannot.
Requirements
- rustup with a stable toolchain.
- cargo (bundled with rustup).
- The crate being audited must compile.
Optional but recommended:
clippycomponent (rustup component add clippy) for the lint pass. The script skips clippy cleanly if it is missing.
Instructions
The argument is in $ARGUMENTS. Pass it directly to the audit script:
bash "$(dirname "$0")/audit.sh" $ARGUMENTS
The argument is the path to the crate directory (the one containing Cargo.toml).
Output sections
| Section | What it reports |
|---|---|
NO_STD |
Whether #![no_std] is declared in src/lib.rs |
NO_ALLOC_DEP |
Whether the crate has any dependency on alloc (direct or via Cargo.toml) |
PANIC_ABORT |
Whether panic = "abort" is set in the release profile |
CLIPPY |
Lint results from a curated set of panic/allocation-detecting lints |
HOT_PATH_GREP |
Grep hits for banned constructs in src/**.rs |
LLVM_IR_ALLOC |
Whether __rust_alloc* symbols appear in the release LLVM-IR |
Typical usage
# Audit a single DSP crate
bash audit.sh ./rust/audio-dsp
# Audit every DSP crate in a workspace
for crate in rust/dsp-*; do bash audit.sh "$crate"; done
What to look for
NO_STDfailing is a structural problem — the crate should be split so DSP code lives in ano_stdcrate and anystd-dependent code moves to a sibling crate.NO_ALLOC_DEPfailing means a transitive dependency pulled inalloc. Usecargo tree -e featuresto find the culprit and either gate it behind a feature flag or replace it.PANIC_ABORTfailing is a one-lineCargo.tomlfix.CLIPPYorHOT_PATH_GREPhits require code changes — see the agent profile's Real-Time-Safe Rust section for the rationale and the safe replacements.LLVM_IR_ALLOCfailing despite a clean source grep usually means a third-party crate is allocating.cargo tree+ the IR's call site (look at the function name precedingcall __rust_alloc) identify the source.
Source: gertsylvest/meta-team — distributed by TomeVault.