Repository navigation
Conversation
Kani's cargo target, sysroot, target allowlist and machine model were all keyed to the host triple, so code that only compiles for another target could not be verified. CBMC's machine model is data in the goto program, so no such host is needed. - kani-compiler: riscv64 (LP64D) machine model, riscv64gc target features, riscv64-unknown-linux-gnu in check_target. - kani-driver: --target <TRIPLE>, gated on -Z unstable-options; rejected with non-host concrete playback and with verify-std. - build-kani: `cargo build-dev --lib-target <TRIPLE>` builds that target's verification libraries into targets/<TRIPLE>/lib, a sysroot of its own; the host's lib/ is unchanged. - tests/script-based-pre/target_riscv64, run by kani-regression.sh. Towards model-checking#2402. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script test now exercises the --concrete-playback and verify-std rejections alongside the -Z gate, so every new argument conflict has coverage. The missing-library bail has no transcript-stable test: every target check_target accepts is a host triple on some CI runner, so its libraries exist somewhere in the matrix. The docs page's Limitations now carries the __CPROVER_architecture_* overwrite the README discloses.
A PATH wrapper pointing at this machine's build directory, created to run the committed test against the dev-built driver; it never belonged in the branch and the copyright check said so.
check_target matched on the LLVM target alone. riscv64a23-unknown-linux-gnu and riscv64-wrs-vxworks share riscv64gc's LLVM target, but target_config reports riscv64gc's features for all of them, so a23 was accepted and verified with the wrong cfg(target_feature) set. The Apple prefix checks also let iOS, tvOS, visionOS and watchOS through now that --target makes them reachable. Match the OS for both, and the feature string for riscv64. The error now names the target triple as well as its LLVM target, since the LLVM target alone made a rejected a23 read like riscv64gc. Also rewrap an over-long comment in new_machine_model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The overwrite does not come from linking. When goto-cc links goto binaries the first input's __CPROVER_architecture_* symbols win, and kani_lib.c reaches the link as C source, which goto-cc compiles with the host's configuration. Say so, and say what would keep the model Kani wrote. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- 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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
link_goto_binary passed kani_lib.c to goto-cc as C source. goto-cc compiles it with the host's C configuration, and that configuration replaced the __CPROVER_architecture_* symbols kani-compiler wrote, so a riscv64 run was checked with the host's char signedness and long double width (CBMC printed "Adding CPROVER library (arm64)" on a macOS host). When goto-cc links goto binaries the first input's symbols win. For a cross target, compile kani_lib.c to an object next to the link output and pass it after the Rust inputs. Host runs keep the old command line. --c-lib now conflicts with a cross --target: those sources would also be compiled for the host and replace the model. goto-cc does accept clang's --target=<triple>, but it only sets the architecture (not the OS), and needs a native compiler that understands the flag, which gcc does not. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The target_riscv64 assertions are rustc facts (c_char, cfg), which hold whatever machine model CBMC ends up using. Inspect the binary Kani links for a harness and check that __CPROVER_architecture_arch is riscv64 and char_is_unsigned is 1. Without the previous commit it reads "arm64" and 0 on a macOS arm64 host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_metadata_json wrote env!("TARGET"), the triple Kani was built for,
so a riscv64 run exported metadata.target as the host's triple. Pass the
verification target in, and check the exported value in target_riscv64.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The linked program now keeps the target's __CPROVER_architecture_* symbols. List the --c-lib conflict instead, and say that the OS symbol is still the host's, since Kani's machine model does not record one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The AArch64 model set char_is_unsigned for every OS. That holds on Linux, but char is signed on Apple arm64 (Apple's "Writing ARM64 code for Apple platforms", core::ffi::c_char on aarch64-apple-darwin, and CBMC's own macOS arm64 configuration). Host runs on macOS hid this, because the host-compiled kani_lib.c replaced the symbol at link time. A run with --target aarch64-apple-darwin from another host would not. Make it depend on the OS, as wchar_t_is_unsigned already does, and split the table out of new_machine_model so a unit test can check it without a rustc session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1eaa2d9 refuses --c-lib with a non-host --target and covers it with a unit test, but nothing checked the message a user actually sees. The C file is the reviewer's reproducer: char is unsigned on riscv64 and signed on x86_64, which is why compiling it for the host would be wrong. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
autoharness --std builds std through the same cargo_build_std path as verify-std, which passes the host triple to cargo because Kani's no_core library exists for the host only. verify-std rejects --target for that reason, but autoharness --std accepted it and quietly verified the host's std. Check it before the std path, so the error names the real problem. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kernels usually build for riscv64gc-unknown-none-elf, and the obvious workaround of verifying as riscv64gc-unknown-linux-gnu changes what gets verified: target_os becomes "linux" and std is available, so cfg(target_os = "none") code drops out. A kernel user should know that before reading a SUCCESSFUL result. Also list autoharness --std beside verify-std, since it now refuses --target too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The driver accepted any string for --target and only looked for targets/<triple>/lib, so an unsupported triple or a typo got "build them with cargo build-dev --lib-target <triple>". For musl, following that advice failed the whole build with kani-compiler's target error deep in the log, and --target "" resolved to the targets/ folder itself. SUPPORTED_TARGETS in kani_metadata is now the one list. The driver checks --target against it after the unstable gate, and build-kani checks --lib-target before building anything. kani_metadata is the crate the driver and compiler already share; build-kani takes it as a new path dependency, since it had no Kani crate in common with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_target recognised targets by LLVM target, and for riscv64 also compared the spec's features string exactly, because riscv64gc, riscv64a23 and riscv64-wrs-vxworks share an LLVM target. A toolchain bump that respelled that string would have rejected riscv64gc. Compare the session's tuple against SUPPORTED_TARGETS instead. The tuple names the built-in spec, so it separates those targets without the features string. A target JSON file is refused outright, because rustc names it after its file stem and a file called riscv64gc-unknown-linux-gnu.json would otherwise pass with any layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cargo build-dev without --lib-target left targets/<triple>/lib from the last build in place, and the driver used it. A change to library/kani or Kani's std overrides was then verified against the old copy for that target with no error; only a removed or renamed function showed up, as a compile failure. build-dev now rebuilds each supported target that already has a folder, as well as the ones named on the command line. Rebuilding rather than deleting keeps a riscv64 setup working across plain builds, and keeps the driver's "build them with cargo build-dev --lib-target" advice true: naming a target once is enough. --skip-libs still skips all of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The merge of main brought the RFC 0015 --export-json shape (model-checking#4941), which reports `target` as the triple Kani was built for and gates the flag behind `-Z export-json`. With --target that triple is the wrong one, and the target_riscv64 script test, which checks that the export records the verification target, no longer ran. Take `target` from `verification_target()`, say so in the RFC's field table, and update the script test for the new key and the new gate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Mark char as signed in the aarch64-apple-darwin machine model" changes the model of an existing host target, not just the new one, and does not depend on --target. It goes to its own pull request against main so it can be reviewed and merged on its own. This restores new_machine_model to its shape on main, apart from the riscv64 arm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
The verification target in --export-json metadata (and RFC 0015's field table) is a fix the review confirmed, but it is not needed for --target to verify correctly. It goes to its own pull request on top of this one, so this one carries only what the review asked for. Until then, --export-json reports the triple Kani was built for, as on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
Rebuilding every target already under targets/ on a plain cargo build-dev was a review suggestion. It only affects local builds, since CI always names the target, so it moves to the follow-up that hardens --target. Until then the docs say to name a target again after changing library/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
Checking --target in the driver, and --lib-target in build-kani, against one shared list gives a clear error before anything is built. That was a review suggestion, and it moves to the follow-up that hardens --target, with the kani_metadata constant and build-kani's new dependency on it. What keeps verification sound stays here: kani-compiler's check_target still accepts only the five exact target tuples (and no target JSON), so riscv64a23-unknown-linux-gnu, riscv64-wrs-vxworks and the non-macOS Apple targets are refused when the libraries or the crate are compiled. Its list now sits beside check_target, the only place this PR reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
The paragraph on riscv64gc-unknown-none-elf answers a review suggestion and goes with the other supported-target changes in the follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
The overwrite comes from goto-cc compiling kani_lib.c during the link, not from linking goto binaries, as the review pointed out. The --c-lib limitation already says so; add how Kani avoids it for its own C file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
The driver accepts any string for --target and only looks for targets/<triple>/lib, so an unsupported triple or a typo gets "build them with cargo build-dev --lib-target <triple>". For musl, following that advice fails the whole build with kani-compiler's target error deep in the log, and --target "" resolves to the targets/ folder itself. SUPPORTED_TARGETS moves from kani-compiler to kani_metadata and becomes the one list. The driver checks --target against it after the unstable gate, and build-kani checks --lib-target before building anything. kani_metadata is the crate the driver and compiler already share; build-kani takes it as a new path dependency, since it had no Kani crate in common with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
A cargo build-dev without --lib-target leaves targets/<triple>/lib from the last build in place, and the driver uses it. A change to library/kani or Kani's std overrides is then verified against the old copy for that target with no error; only a removed or renamed function shows up, as a compile failure. build-dev now rebuilds each supported target that already has a folder, as well as the ones named on the command line. Rebuilding rather than deleting keeps a riscv64 setup working across plain builds, and keeps the driver's "build them with cargo build-dev --lib-target" advice true: naming a target once is enough. --skip-libs still skips all of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
Kernels usually build for riscv64gc-unknown-none-elf, which Kani refuses. Verifying such a crate as riscv64gc-unknown-linux-gnu sets target_os = "linux" and makes std available, so code behind cfg(target_os = "none") is compiled out and the linux branch is what gets verified. Say so, so kernel users know what they are verifying. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #4913 and is based on its branch. Only the last three commits are new here.
These are the suggestions from the #4913 review, split out so that PR stays small.
SUPPORTED_TARGETSmoves from kani-compiler tokani_metadata. The driver checks--targetagainst it after the unstable gate, andcargo build-devchecks--lib-targetbefore building anything. Today an unsupported triple or a typo gets "build them withcargo build-dev --lib-target <triple>", and for musl, following that advice fails the whole build with the compiler's error deep in the log.--target ""also resolved to thetargets/folder itself.build-kanitakeskani_metadataas a new path dependency.cargo build-devnow rebuilds each target that already has a folder undertargets/, so a change tolibrary/kanior Kani'sstdoverrides is not verified against a stale copy. Rebuilding rather than deleting keeps a riscv64 setup working across plain builds.--skip-libsstill skips all of them.riscv64gc-unknown-none-elfis not supported, and that verifying a bare-metal crate asriscv64gc-unknown-linux-gnucompiles out code behindcfg(target_os = "none").Testing: unit tests for the driver check and for
--lib-targetparsing, plus a line intarget_riscv64for the up-front error. fmt, clippy and the driver, compiler, metadata and build-kani tests pass locally with CBMC 6.11.0.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
🤖 Generated with Claude Code
https://claude.ai/code/session_01M1dgc2zy347cbi6td1Wd4x