Skip to content

Stop after codegen with -Z lean instead of failing to link a goto model - #4924

Merged
feliperodri merged 2 commits into
model-checking:mainfrom
tautschnig:llbc-lean-exit-status
Sep 30, 2026
Merged

feliperodri merged 2 commits into
model-checking:mainfrom
tautschnig:llbc-lean-exit-status

Conversation

@tautschnig

@tautschnig tautschnig commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

With -Z lean, stop once the compiler has run instead of trying to link a goto model that the LLBC backend never writes.

The bug. kani-compiler translates to LLBC under -Z lean and writes no goto program, but the driver still went on to link one for every harness. Every kani file.rs -Zlean --print-llbc therefore printed the LLBC and then ended with

error: Failed to canonicalize harness model .../test__...main.symtab.out: No such file or directory (os error 2)

and exit status 1, even when the translation had succeeded. On current main all 23 tests/llbc tests exit with status 1 this way. The llbc tests only compare output, so nothing noticed, but it also means a real failure of the LLBC backend cannot be told apart from success by exit status.

The fix. With the LLBC backend there is nothing to link or verify, so the driver now stops after compilation, as --only-codegen does: Project::try_new creates no link jobs, and the standalone, cargo kani and autoharness entry points skip verification. A failing translation (a compiler panic, or Charon reporting errors) still exits with an error.

Stopping early must not skip what the driver checks before verification (both from Copilot's review): the LLBC path still runs determine_targets, so a --harness filter that matches nothing (or a missing one under --exact) is still an error, and --export-json and --sarif are rejected with -Z lean, as they are with --only-codegen, since nothing would write the requested file.

Manual testing.

  • kani tests/llbc/basic0/test.rs -Zlean --print-llbc prints the LLBC and exits 0 (was 1 with the error above).
  • A program that makes the LLBC translation panic still exits 1.
  • kani -Z lean --harness typo (also with --exact) and cargo kani -Z lean --harness typo fail with "Failed to match the following harness(es)"; a matching --harness succeeds. -Z lean with --export-json or --sarif is rejected as a conflict; the argument tests cover both.
  • All 23 llbc tests exit 0; checked with the compiletest flag from Make the LLBC regression require Kani to exit successfully #4925.
  • cargo test -p kani-driver passes (105/105); the expected (487 passed, 0 failed) and ui (152/152) suites and kani-llbc-regression.sh pass; fmt and both CI clippy invocations are clean.

#4925 makes kani-llbc-regression.sh check exit statuses, which is what Copilot pointed out on #4920; it is stacked on this one.

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

…odel

With `-Z lean`, `kani-compiler` translates to LLBC and writes no goto
program, but the driver still went on to link one for every harness and
failed: every `kani file.rs -Zlean --print-llbc` printed the LLBC and then
ended with "error: Failed to canonicalize harness model ....symtab.out: No
such file or directory" and exit status 1, even when the translation had
succeeded. The llbc tests only compare output, so nothing noticed.

With the LLBC backend there is nothing to link or verify, so stop once the
compiler has run, as `--only-codegen` does. A failing translation (a
compiler panic, or Charon reporting errors) still exits with an error.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@tautschnig
tautschnig requested review from a team as code owners September 30, 2026 12:26
Copilot AI balanced review requested due to automatic review settings September 30, 2026 12:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

LLBC early returns bypass harness validation and silently ignore requested verification output files.

Review effort: Balanced
Findings: 1 High severity · 1 Medium severity

Open (2)
What changed in this PR

Stops LLBC (-Z lean) runs after compilation instead of attempting unavailable goto-model linking and verification.

Changes:

  • Detects LLBC backend usage centrally.
  • Skips goto linking and verification for standalone, Cargo, and autoharness flows.
  • Preserves compiler translation errors.
File Description
kani-driver/​src/​args/​mod.rs Adds LLBC backend detection.
kani-driver/​src/​project.rs Avoids creating LLBC link jobs.
kani-driver/​src/​main.rs Stops standard flows after LLBC compilation.
kani-driver/​src/​autoharness/​mod.rs Stops autoharness after LLBC compilation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread kani-driver/src/main.rs Outdated
Comment thread kani-driver/src/args/mod.rs
Stopping after codegen with `-Z lean` skipped `determine_targets`, which
is where the driver rejects a `--harness` filter that matches nothing (and
missing filters under `--exact`); the compiler only filters its metadata,
so `kani -Z lean --harness typo` exited successfully having translated no
harness. Run `determine_targets` on the LLBC path too.

It also made `--export-json` and `--sarif` succeed without writing the
requested file, since only `verify_project` writes them. Reject both with
`-Z lean`, as `--only-codegen` already does for them, and cover the new
conflicts in the argument tests.

Both from Copilot's review of model-checking#4924 and model-checking#4925.

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
@feliperodri
feliperodri added this pull request to the merge queue Sep 30, 2026
@feliperodri feliperodri removed their assignment Sep 30, 2026
Merged via the queue into model-checking:main with commit a19532c Sep 30, 2026
33 checks passed
srivatsansamraj pushed a commit to srivatsansamraj/kani that referenced this pull request Sep 30, 2026
…cking#4925)

**Stacked on model-checking#4924**: the first two commits are model-checking#4924 and drop out once
it merges; only the last commit (`e251cab38`) is new here.

Make `kani-llbc-regression.sh` fail an llbc test whose Kani invocation
exits unsuccessfully, not only one whose output misses the expected
lines.

**Context.** Copilot pointed this out on model-checking#4920
([1](model-checking#4920 (comment)),
[2](model-checking#4920 (comment))):
compiletest's `expected` mode (`run_expected_test`) only checks that the
output contains the expected lines and ignores the exit status. That is
what many `expected` tests need, since they pin the output of a failing
verification. For the llbc suite it means a Kani run that prints the
expected LLBC and then fails (Charon reporting errors, a driver error)
still passes. `kani-llbc-regression.sh` is what CI's LLBC job runs, and
what the toolchain and Charon update jobs in model-checking#4920 use to decide between
a PR and an issue.

**The change.** A new opt-in compiletest flag, `--require-success`,
additionally fails an `expected` test whose Kani invocation exits
unsuccessfully. `kani-llbc-regression.sh` passes it for the llbc suite.
Other suites are unchanged.

**Manual testing.**
- Without model-checking#4924's fix, `--require-success` fails all 23 llbc tests (they
all exit 1), while without the flag all 23 pass: the flag catches what
the suite used to miss.
- With model-checking#4924, all 23 pass with `--require-success`, and
`kani-llbc-regression.sh` passes.
- fmt and both CI clippy invocations are clean.

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

---------

Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants