notes

Review of model-checking/kani#4913

Name: ratified 2026-10-18 (calef, "Approve all"). Refused pr-4913-review. Written 2026-09-30 (UTC) by the lane lane/kani-upstream. The parent note is kani-upstream.md.

This lane reviewed kani#4913 as a hostile-but-fair upstream reviewer would, and records the findings here. The pull request is our own: head 6760749, base c1a1cf6, opened 2026-09-30 01:18 (UTC). The review is therefore a rehearsal for the real one, and its findings are ours to fix before a maintainer makes them.

Evidence used, all fetched without cloning kani. The pull request diff and body came through gh; the touched driver and build files at the head SHA were fetched raw; so were CBMC's src/util/config.cpp at tag cbmc-6.11.0, the RISC-V psABI riscv-cc.adoc at master, and .github/workflows/kani.yml.

Blocking

Nothing found. The two highest-risk areas both check out, verified rather than trusted:

Should-fix

  1. The posted body still contains the literal token SUITE_RESULTS (Testing section, sentence listing the compiletest suites). It reads as unfinished, and it stands where the evidence should be. Our own record (kani-upstream.md, "Tests, on patagonia") says script-based-pre had one local failure (verify_std_cmd, undiagnosed) and coverage never produced a result. Fill the token honestly or drop it, and say which suites were clean.
  2. The two rejections and the missing-library error have no test. The pull request adds the --concrete-playback conflict (validate in kani-driver/src/args/mod.rs), the verify-std rejection (validate in kani-driver/src/args/std_args.rs), and the bail naming the build command (lib_folder_for in kani-driver/src/session.rs). The new script test covers only the -Z gate (the [TEST] --target needs -Z unstable-options block of tests/script-based-pre/target_riscv64/target_riscv64.sh). Each check is one more [TEST] block in that script; Kani tests its other argument conflicts, and these are new surface.
  3. docs/src/reference/experimental/target.md omits the goto-cc arch-symbol overwrite from its Limitations list (file lines 46-54). The body discloses it with measurements: after linking, __CPROVER_architecture_* are the host's, and char_is_unsigned flips from the written value. That bounds what a cross-target proof claims, and a user who reads only the docs page will not find it. Add a bullet and link the offered issue.

Nice-to-have

  1. The body says the flag "replaces env!(\"TARGET\") in ... the single-file rustc call". Nothing was replaced there: the old single-file path never read or passed a target, and the diff adds --target only when the flag is given (compile_single_rust_file in kani-driver/src/call_single_file.rs at head). The next sentence in the body states the truth, so this is wording, not substance.
  2. target_is_riscv64gc in tests/script-based-pre/target_riscv64/riscv64.rs asserts size_of::<usize>() == 8. Every host Kani runs on is 64-bit, so this cannot discriminate. The doc comment above it (lines 10-11) says "not for every host", which the first two assertions satisfy and this one does not. Harmless as a sanity check; misleading as evidence of cross-compilation.
  3. verify-std rejects --target even when the triple is the host's (validate in std_args.rs), while the --concrete-playback gate allows the host triple (validate in args/mod.rs). Both defensible; worth one comment line each, or align them.
  4. cargo build-dev --skip-libs --lib-target T silently ignores the target (the skip_libs branch of main in tools/build-kani/src/main.rs at head). A warning would save a confusing missing-library error later.

Questions for maintainers

  1. CI cost. The cargo build-dev --lib-target step in scripts/kani-regression.sh adds a riscv64 library build, and the matrix of .github/workflows/kani.yml runs that script on five runners, including macos-15-intel. The body pre-offers moving the build to one job. The maintainer call is whether five duplicated builds buy enough matrix coverage; the test does exercise x86_64 and aarch64 hosts either way.
  2. Coverage with --target is accepted but untested. cov_session.rs now threads the verification target into both metadata calls (diff lines 389-401), and nothing rejects the combination, but no test runs it. Intended, or worth a rejection until tested?
  3. Cross-target builds with proc-macro or build-script dependencies are untested. Reading the mechanism: cargo_config_args sets host.rustflags (in kani-driver/src/call_cargo.rs), which keeps host crates native, and pass_rustc_args(..., PassTo::AllCrates) carries the target sysroot in CARGO_ENCODED_RUSTFLAGS (pass_rustc_args in kani-driver/src/util.rs). That says proc macros still compile for the host, as they do today. The sample crate has no dependencies. A test with one proc-macro dependency would pin this.
  4. The -Z unstable-options gate and the targets/<TRIPLE>/lib/ layout are already offered as negotiable in the body. Nothing to add from this side.

What holds up

The machine model (machine_model_for in kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs at head) was checked field by field against two primary sources, both fetched for this review. CBMC 6.11.0's set_arch_spec_riscv64 (config.cpp:437-463 plus set_LP64 at 47-61): LP64 widths, char_is_unsigned=true, wchar_t signed and 32 bits, long_double_width 16 bytes, little-endian, NULL_is_zero. The psABI master riscv-cc.adoc: the LP64 table matches every width, line 908 says "char is unsigned", line 1050 says "wchar_t is signed", and long double is binary128. Every value in the new arm agrees with both. The code cites both sources at the arm, which is the part a reviewer would actually praise.

The threading: cargo_build uses the verification target for the cargo invocation, metadata (--filter-platform), and library folder (cargo_build in kani-driver/src/call_cargo.rs at head). cargo_build_std and playback stay on HOST_TARGET, correctly, since both are host activities. Both cov_session sites use it; single-file passes --target only when given. With no flag, every path passes the same string env!("TARGET") produced before.

The layout: build and driver agree on targets/<TRIPLE>/lib/ (tools/build-kani/src/sysroot.rs::kani_target_lib and kani-driver/src/session.rs::lib_folder_for); the host lib/ path is unchanged; playback and no_core libraries stay host-built; no packaging or setup file is touched, verified against the pull request's file list. The missing-library error names cargo build-dev --lib-target <TRIPLE>, which is the exact command.

The gating: -Z unstable-options fires on the flag alone; both rejections behave as documented.

The test proves real target facts: c_char::MIN == 0 differs on an x86_64 host, target_feature = "d" differs on every host, and the failing overflow check forces CBMC to actually solve a riscv64 program. The host-run case proving the harnesses are compiled out is the right negative control, and the expected-file format matches the framework's ordered-subsequence comparison.

Could not verify from the diff