From b983391b865acdeaebef3a65c898a7ccc561068c Mon Sep 17 00:00:00 2001 From: Chris Alef Date: Sat, 3 Oct 2026 12:29:57 -0700 Subject: [PATCH] Tighten the --target test, docs and build-dev flags after self-review - build-dev: --lib-target conflicts with --skip-libs instead of being ignored. - target_riscv64: drop the usize-width assertion, which holds on every host Kani runs on and so does not show the target changed. - docs: name long double as a C width that differs (64-bit on macOS arm64, 128-bit on riscv64), and say where the overwritten model matters. --- docs/src/reference/experimental/target.md | 7 ++++--- tests/script-based-pre/target_riscv64/riscv64.rs | 1 - tools/build-kani/src/parser.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/reference/experimental/target.md b/docs/src/reference/experimental/target.md index c22076a..28cb6b2 100644 --- a/docs/src/reference/experimental/target.md +++ b/docs/src/reference/experimental/target.md @@ -52,9 +52,10 @@ cargo kani --target riscv64gc-unknown-linux-gnu -Z unstable-options Kani wrote. When `goto-cc` links goto binaries, the first input's architecture symbols win, and Kani currently passes `kani_lib.c` to the link as a C source, which `goto-cc` compiles with the host's configuration. On macOS a cross-target run therefore reports the host's `arm64` and - `char_is_unsigned = 0` there. The Rust side of the goto program spells out its own widths and - signedness, which is what the proof checks, and every target Kani accepts has the same C type - widths as every supported host. Compiling `kani_lib.c` to a goto object ahead of time and + `char_is_unsigned = 0` there, and a 64-bit `long double` where riscv64's is 128-bit. The Rust + side of the goto program spells out its own widths and signedness, which is what the proof + checks, so this matters only where CBMC interprets C: `kani_lib.c`, its C library models, and + any C code a harness reaches. Compiling `kani_lib.c` to a goto object ahead of time and linking it after the Rust inputs would keep the model Kani wrote. * Inline assembly is unsupported on every target, as it is on the host. Code behind `core::arch::asm!` has to be [stubbed](stubbing.md) to be verified. diff --git a/tests/script-based-pre/target_riscv64/riscv64.rs b/tests/script-based-pre/target_riscv64/riscv64.rs index b33370e..baf41a9 100644 --- a/tests/script-based-pre/target_riscv64/riscv64.rs +++ b/tests/script-based-pre/target_riscv64/riscv64.rs @@ -12,7 +12,6 @@ mod riscv64 { fn target_is_riscv64gc() { assert!(core::ffi::c_char::MIN == 0); assert!(cfg!(target_feature = "d")); - assert!(core::mem::size_of::() == 8); } /// A failing check, so the test also shows that CBMC checked the riscv64 program. diff --git a/tools/build-kani/src/parser.rs b/tools/build-kani/src/parser.rs index 3e10a5a..fc23330 100644 --- a/tools/build-kani/src/parser.rs +++ b/tools/build-kani/src/parser.rs @@ -23,7 +23,7 @@ pub struct BuildDevParser { pub skip_libs: bool, /// Also build Kani's verification libraries for this target triple, so that /// `kani --target -Z unstable-options` can verify for it. May be repeated. - #[clap(long = "lib-target", value_name = "TRIPLE")] + #[clap(long = "lib-target", value_name = "TRIPLE", conflicts_with = "skip_libs")] pub lib_targets: Vec, } -- 2.55.0