notes

Name: ratified 2026-10-18 (calef, "Approve all"). Refused pull-request.

This PR adds an unstable --target <TRIPLE> option, so Kani can verify a crate for a target other than the host, and adds riscv64gc-unknown-linux-gnu as a target Kani has a machine model for.

Towards #2402. It covers the part of that issue that needs no new machine-model work: 64-bit little-endian targets. The 16-bit and big-endian cases asked for there are left for later (see "Not in this PR").

Why

CBMC does not care which machine it runs on; the machine model is data Kani writes into the goto program. What stops Kani verifying for another target today is that four places are keyed to env!("TARGET"): the target passed to cargo, the sysroot build-kani builds, check_target's allowlist, and new_machine_model. Our use is a kernel with an arch/riscv64 tree whose code only compiles for riscv64 (cfg(target_arch), core::arch::riscv64), which we want to prove from x86_64 and Apple Silicon machines, including GitHub-hosted runners. CBMC 6.11's set_arch_spec_riscv64 already exists, so CBMC needs no change.

What changes

Testing

Something I noticed and did not change

link_goto_binary compiles kani_lib.c with goto-cc, which configures itself for the host. After linking, the __CPROVER_architecture_* symbols are the host's rather than the ones Kani wrote. With --target riscv64gc-unknown-linux-gnu on an Apple Silicon Mac, architecture_arch is "riscv64" in the .symtab.out and "arm64" in the linked .out, and char_is_unsigned goes from 1 to 0. The same thing happens without --target: on macOS the aarch64 model's char_is_unsigned = true is replaced by goto-cc's 0. For Rust code this looks harmless, because the goto program spells out its own widths and signedness, and for the targets check_target accepts, pointer width and endianness match every supported host. It is the #2086 problem (goto-cc needing -m32) in general form, though. goto-cc's -march table has no riscv64 entry, so it cannot be fixed from Kani's side alone. I'm happy to open an issue for it.

Not in this PR

Disclosure

This change was written by an AI coding agent (Claude Code) working under my direction, for nife, a capability microkernel that uses Kani for its kernel proofs. I'm responsible for it and will follow up on review.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.