Skip to content

Fix target selection for MIR Linker - #1789

Merged
celinval merged 4 commits into
model-checking:mainfrom
celinval:issue-1764-integ
Oct 17, 2022
Merged

celinval merged 4 commits into
model-checking:mainfrom
celinval:issue-1764-integ

Conversation

@celinval

Copy link
Copy Markdown
Contributor

Description of changes:

When running MIR Linker with multiple targets (e.g., integration tests), we were failing to compile since the call to cargo rustc would have multiple targets.

Invoke separate calls for each target for now.

Resolved issues:

Resolves #1764

Related RFC:

Call-outs:

I was wondering if it's worth suppressing cargo's messages and printing our own (in a follow up PR). The output is not great right now since it just have some multiple cargo logs in sequence. For the test below, you would get the following:

Details
$ cargo kani --only-codegen
   Compiling all_harness v0.1.0 (/home/ANT.AMAZON.COM/celinval/workspace/kani-project/kani/tests/cargo-ui/ws-integ-tests/all_harness)
    Finished dev [unoptimized + debuginfo] target(s) in 0.92s
   Compiling all_harness v0.1.0 (/home/ANT.AMAZON.COM/celinval/workspace/kani-project/kani/tests/cargo-ui/ws-integ-tests/all_harness)
    Finished dev [unoptimized + debuginfo] target(s) in 0.85s
   Compiling in_src_harness v0.1.0 (/home/ANT.AMAZON.COM/celinval/workspace/kani-project/kani/tests/cargo-ui/ws-integ-tests/in_src_harness)
    Finished dev [unoptimized + debuginfo] target(s) in 0.79s
   Compiling in_src_harness v0.1.0 (/home/ANT.AMAZON.COM/celinval/workspace/kani-project/kani/tests/cargo-ui/ws-integ-tests/in_src_harness)
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
   Compiling integ_harness v0.1.0 (/home/ANT.AMAZON.COM/celinval/workspace/kani-project/kani/tests/cargo-ui/ws-integ-tests/integ_harness)
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
   Compiling integ_harness v0.1.0 (/home/ANT.AMAZON.COM/celinval/workspace/kani-project/kani/tests/cargo-ui/ws-integ-tests/integ_harness)
    Finished dev [unoptimized + debuginfo] target(s) in 0.81s

Testing:

  • How is this change tested? New test

  • Is this a refactor change? No

Checklist

  • Each commit message has a non-empty body, explaining why the change was made
  • Methods or procedures are documented
  • Regression or unit tests are included, or existing tests cover the modified code
  • My PR is restricted to a single feature or bugfix

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

When running MIR Linker with multiple targets (e.g., unit tests), we
were failing to compile since the call to `cargo rustc` would have
multiple targets.

Invoke separate calls for each target for now.
@celinval
celinval requested a review from a team as a code owner October 14, 2022 20:10

@tedinski tedinski 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.

What's left to solve #1448 ? Not asking for it in this PR, just curious.

I'm guessing we still just link all the generated goto binaries together, so the next step would be not doing that, and tracking which binary each proof harness is in?

Comment thread kani-driver/src/call_cargo.rs Outdated

/// Extract the targets inside a package.
/// If `--tests` is given, the list of targets will include any integration tests.
fn package_targets(args: &KaniArgs, package: &Package) -> Vec<Vec<String>> {

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.

Part of me wants a type here, but can you at least clarify what the return value is? e.g. this apprears to be arguments?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about creating a type, but it would end up being a bit messy, since you end up with 2 args for --tests and --bin but only one for --lib. This would create more branches later when translating it to arguments. So I ended up keeping it simple and just using Vec<Vec<_>>.

@celinval

Copy link
Copy Markdown
Contributor Author

What's left to solve #1448 ? Not asking for it in this PR, just curious.

I'm guessing we still just link all the generated goto binaries together, so the next step would be not doing that, and tracking which binary each proof harness is in?

Yes, linking is still a problem, but I think it might be the only one left. Note that I had to slightly change the names of the harnesses in each crate of the example, otherwise they would conflict with each other.

@celinval

Copy link
Copy Markdown
Contributor Author

I added a little enum. Let me know if that helps.

@celinval
celinval merged commit 91e2596 into model-checking:main Oct 17, 2022
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.

MIR Linker doesn't work with integration tests

2 participants