Build & Run
The master build is CMake-driven. Corrosion
invokes Cargo to compile the Rust core/ into a static library that links into the
C++ targets. Third-party C++ dependencies come in via CMake FetchContent (MTL5,
Universal, Catch2, yaml-cpp, stb) — no vcpkg/Conan, because the cross-compilation
story for the custom SoC depends on every dependency living under the master
toolchain.
SITL (host x86, emulated MemoryProvider) — default
Section titled “SITL (host x86, emulated MemoryProvider) — default”cmake -B build -DBUILD_TARGET_KPU=OFFcmake --build build -j$(nproc)cd build && ctest --output-on-failureKPU target (cross-compile, real KPU/DMA kernel bindings)
Section titled “KPU target (cross-compile, real KPU/DMA kernel bindings)”cmake -B build -DCMAKE_TOOLCHAIN_FILE=cross-toolchain.cmake -DBUILD_TARGET_KPU=ONcmake --build build -j$(nproc)The BUILD_TARGET_KPU flag
Section titled “The BUILD_TARGET_KPU flag”This one flag controls both sides of the FFI:
- it sets
TARGET_KPU/TARGET_SITLfor the C++ targets, and - it exports
RUST_HAL_TARGET=KPU|SITLso the RustMemoryProviderselects between the real kernel-driver implementation and the POSIX-shm emulation.
The C++ operators (sdk/) and math (math/) never branch on the build target —
that distinction stays confined to the Rust core/ HAL.
CMake presets
Section titled “CMake presets”Four presets remove the need to memorize flag chains:
| Preset | Build type | Purpose |
|---|---|---|
sitl-debug | Debug | Primary host build; what CI runs |
sitl-release | Release | Optimized host build (latency budgets are enforced here) |
kpu-cross | Release | aarch64 cross-compile for KPU silicon |
wsl2-sitl | Debug | Linux build from the Windows/Visual Studio IDE via WSL2 |
cmake --preset sitl-releasecmake --build --preset sitl-releasectest --preset sitl-releaseRunning specific tests
Section titled “Running specific tests”The suite is Catch2-based and registered with
catch_discover_tests, so ctest -R filters by name:
# the VIO trajectory metrics + EuRoC harnessctest -R vio_euroc --output-on-failure
# the MSCKF and estimator suitesctest -R 'sdk_msckf|sdk_vio' --output-on-failureThe EuRoC accuracy benchmark and the latency budget are dataset-/optimized-build
gated — they run when you point CORTEX_EUROC_V101 at a sequence and build under
NDEBUG, and otherwise skip cleanly so CI stays green without the dataset. See
Benchmarks & Validation.
Toolchain notes
Section titled “Toolchain notes”- C++20 is required (
std::span, the concepts MTL5 leans on). Do not lower it. - The Rust toolchain is pinned in
rust-toolchain.toml(currently1.83.0); bumps are deliberate PRs of their own. - If CI compile time grows, the answer is sccache, not a package manager.
- MLIR/LLVM (when introduced) are installed as pre-built binaries, never
FetchContent’d — building LLVM from source destroys iteration time.