Derive the cargo output directory from cargo's reported artifacts - #4766
Merged
feliperodri merged 1 commit intoAug 27, 2026
Merged
Conversation
`cargo_build` hardcoded the compiler output directory as `target/kani/<triple>/debug/deps`, and `cargo_project` then canonicalized it -- so any layout that does not match becomes `error: No such file or directory (os error 2)`. That layout is cargo's to choose, and cargo 1.99 changes it: artifacts no longer share `debug/deps`, each package getting its own `debug/build/PKG/HASH/out/` instead. Artifact discovery was already layout-agnostic (`map_kani_artifact` derives every path from the `filenames` cargo reports), so the hardcoded directory was the only thing tying the driver to the old layout. Derive it from the discovered artifacts instead, and drop the canonicalization: an artifact path is canonical already, and the no-artifacts fallback names a directory cargo had no reason to create. Two tests hardcoded the same layout and are now layout-agnostic: `check-output` searches the target directory for its `--gen-c` output, and `cargo_playback_opts` asserts only the file name of the executable whose path cargo reports.
feliperodri
enabled auto-merge
August 27, 2026 00:55
This was referenced Aug 27, 2026
rajath-mk
approved these changes
Aug 27, 2026
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.
Description
cargo_buildhardcoded the compiler output directory astarget/kani/<triple>/debug/deps, andcargo_projectthen canonicalized it. That layout is cargo's to choose, and cargo 1.99 changes it: artifacts no longer sharedebug/deps— each package gets its owndebug/build/PKG/HASH/out/— sodebug/depsis never created and the canonicalize fails:Artifact discovery was already layout-agnostic:
map_kani_artifactderives every path from thefilenamesthat cargo reports. The hardcoded directory was the only thing tying the driver to the old layout.This PR:
CargoOutputs::outdirfrom the discovered artifacts instead of assuming a path.canonicalizeincargo_project. An artifact path is canonical already (Artifact::try_newcanonicalizes), and the no-artifacts fallback names a directory cargo had no reason to create — canonicalizing it turns a benign case into a hard error.check-outputsearches the target directory for its--gen-coutput, andcargo_playback_optsasserts only the file name of the executable whose path cargo itself reports.Note that with cargo 1.99 a multi-package build no longer has a single output directory.
outdirnames one of them; it feeds only theoutput_dirfield of the-Z unstable-optionsJSON frontend, and previously named a directory that under 1.99 does not exist at all. The doc comment says so explicitly.The layout change, confirmed locally on nightly-2026-08-01 (cargo 1.99.0-nightly):
Why this is a standalone PR
This unblocks the toolchain upgrade chain. It has no dependency on any toolchain bump and is behaviour-preserving on the current toolchain, so it can land on its own. The intended order is #4760 (2026-06-01) → #4764 (2026-07-01) → this PR → the 2026-08-01 bump, which is blocked on it.
Testing
On the current toolchain (nightly-2026-05-01, cargo 1.97 — old layout):
cargo-kani: 71 passed, 0 failedscript-based-pre: 70 passed, 2 failed — both failures (cargo_autoharness_filter,cargo_autoharness_slices) reproduce on unmodifiedmainand are unrelated to this changecargo test -p kani-driver: 93 passed./scripts/kani-fmt.sh --check,cargo clippy --workspace --tests -- -D warnings,RUSTFLAGS="--cfg=kani_sysroot" cargo clippy --workspace -- -D warnings: cleanCherry-picked onto the local 2026-08-01 branch (cargo 1.99 — new layout), which is where the bug bites:
cargo-kaniscript-based-preBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.