tree: 4bc74fc78daddaefb77e38dd7461032a8eae642e [search]
  1. cpp-diff/
  2. ffi-check/
  3. isa-oracle/
  4. lower-common/
  5. lower-cpp/
  6. postlink/
  7. Cargo.lock
  8. Cargo.toml
  9. README.md
tools/anneal-cpp/README.md

tools/anneal-cpp: C/C++ Frontend, Differential Oracle, and Binary Tools

[!NOTE] Experimental / unbridged prototype: The crates in tools/anneal-cpp/ are excluded host tools outside Anneal's Rust verifier TCB; standalone C/C++ claim admission and correspondence bridges do not yet ship in cargo-anneal.

tools/anneal-cpp/ is a standalone Cargo workspace (Cargo.toml) containing untrusted Rust tools for C11 and -fno-exceptions C++17/C++20 lowering, semantics and ISA differential testing, C/C++-to-Rust FFI parity checking, and post-link ELF64 auditing. It pairs with the companion C++20 Clang LibTooling extractor anneal-clang-dump, which emits the RawCppBundle (schema v1) JSON consumed by anneal-lower-cpp, anneal-cpp-diff, and anneal-ffi-check.

Role and Trust Boundary

The root workspace (Cargo.toml) explicitly excludes tools/anneal-cpp so anneal-audit's Cargo boundary (check_cargo_boundary) keeps every crate here in zone 2 (tools/), strictly outside trusted/ and tests/ (see docs/trust-model.md). Every member is publish = false and build.rs-free, and neither trusted/ nor tests/ may depend on crates under tools/.

Tools in this workspace target companion Lean modules—including Trusted.CppAst, Trusted.CppSemantics, Anneal.ElfX86, and Anneal.ElfAArch64—for lowering, layout-parity export, and differential testing. Because anneal-clang-dump and anneal-lower-cpp perform semantic gating and normalization outside trusted/, and TrustedBoundary does not yet define an admission rule for CapturedCpp modules on main, admitting standalone C/C++ verification claims will require either TCB promotion or translation validation rather than trusting excluded-tool output directly.

Workspace Crates

tools/anneal-cpp/Cargo.toml defines six workspace members:

MemberPackageTargetsSummaryDetails
lower-commonanneal-lower-commonlibDependency-free Tarjan callee-first SCC ordering, 16-element balanced-tree Lean list chunking, and SHA-256 helpers shared by anneal-lower-cpp, anneal-cpp-diff, and anneal-postlink.lower-common/README.md
lower-cppanneal-lower-cpplib, binPure-Rust, fail-closed lowerer from anneal-clang-dump RawCppBundle JSON to CapturedCpp.lean (Trusted.CppAst.CppProgram), enforcing language policy, ABI cross-checks, SSENF, scope lifetimes, and return-slot normalization.lower-cpp/README.md
cpp-diffanneal-cpp-difflib, bin#![forbid(unsafe_code)] C11/C++20 operational-semantics differential oracle comparing Trusted.CppSemantics against clang/clang++ (UBSan+ASan) and optional gcc/g++ (UBSan) over a built-in inline corpus.cpp-diff/src/main.rs
ffi-checkanneal-ffi-checklib, binFail-closed C/C++ to Rust FFI layout, calling-convention, ABI-passing, const-consistency, and unwind-safety checker consuming RawCppBundle JSON with a Rust FFI descriptor and/or rustc -Z print-type-sizes; optionally emits C _Static_assert headers and Lean layout-parity modules.ffi-check/README.md
isa-oracleanneal-isa-oraclelib, binDual-ISA (x86-64 and AArch64) differential decoder oracle comparing Anneal's Lean decoders (Anneal.ElfX86 and Anneal.ElfAArch64) against llvm-objdump and GNU objdump on a built-in adversarial corpus, raw hex bytes, or ELF64 sections.isa-oracle/src/main.rs
postlinkanneal-postlinklib, bin#![forbid(unsafe_code)] post-link ELF64 (ET_EXEC / ET_DYN) auditor for x86-64 and AArch64 checking .text byte fidelity outside allowlisted relocations, .rodata immutability, GOT/PLT binding, and binary hardening (W^X, PT_GNU_STACK, PT_GNU_RELRO, CET/BTI/PAC, .stack_sizes, syscall absence).postlink/README.md

Differential Oracles Without Dedicated READMEs

  • anneal-cpp-diff (cpp-diff/src/lib.rs, cpp-diff/src/main.rs): runs the inline C11/C++20 corpus (--list, --filter SUBSTR, --json, --json-out PATH) through both the Lean Trusted.CppSemantics leg (using anneal-clang-dump and lean, overridable via --clang-dump / $ANNEAL_CLANG_DUMP and --lean) and native compiler legs (--cc, --cxx, and optional --gcc/--gxx). Exits 0 when all cases pass, 1 on differential failures, and 2 on CLI, environment, or tool errors.
  • anneal-isa-oracle (isa-oracle/src/lib.rs, isa-oracle/src/main.rs): checks the built-in dual-ISA adversarial corpus (--adversarial), raw hex bytes (--hex <BYTES> --arch <x86-64|aarch64>), or an ELF64 section (--elf <PATH> [--section .text]) against llvm-objdump and GNU objdump (requiring --lean-bin <PATH> unless --disasm-only is passed; supports --lane <base|word-simd>, --olean-dir <DIR>, --require-reloc, and --pretty). Exits 0 when all cases pass, 1 on mismatches or unexpected gaps, and 2 on CLI or tool errors.

Building, Linting, and Testing

CI runs the tools-anneal-cpp check declared in ci/checks.toml via ci/scripts/run_anneal_cpp_check.sh using the pinned stable toolchain from ci/pins/rust-toolchains.toml:

cd tools/anneal-cpp
cargo "+${PIN_RUST_TOOLCHAINS__STABLE}" clippy --locked --offline \
  --workspace --all-targets -- -D warnings
cargo "+${PIN_RUST_TOOLCHAINS__STABLE}" test --locked --offline --workspace

To invoke the CI wrapper directly from the repository root (it sets CARGO_NET_OFFLINE=true, defaults CARGO_TARGET_DIR to ${HOME:-/scratch}/anneal-cpp-target, and enforces a 1800 s timeout):

PIN_RUST_TOOLCHAINS__STABLE=<stable> ./ci/scripts/run_anneal_cpp_check.sh

For local runs from tools/anneal-cpp/ with your default Cargo toolchain (add --offline once dependencies are cached):

cd tools/anneal-cpp
cargo clippy --locked --workspace --all-targets -- -D warnings
cargo test --locked --workspace

Workspace formatting is checked in CI by ci/scripts/run_fmt_domain.sh using the pinned nightly toolchain from ci/pins/rust-toolchains.toml:

cargo +"${PIN_RUST_TOOLCHAINS__NIGHTLY}" fmt \
  --manifest-path tools/anneal-cpp/Cargo.toml --all --check

The workspace test suite runs entirely offline against checked-in JSON fixtures (lower-cpp/tests/fixtures/) and inline corpora (cpp-diff, isa-oracle), with no C++, LLVM, or Lean installation required. Live end-to-end runs of anneal-clang-dump, anneal-cpp-diff, or anneal-isa-oracle additionally require the external tools noted above (see ../anneal-clang-dump/README.md for building anneal-clang-dump against Clang/LLVM 22+).