Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Kani to run on Apple M1 #1323

Merged
merged 3 commits into from
Jun 30, 2022
Merged

Conversation

ssoudan
Copy link
Contributor

@ssoudan ssoudan commented Jun 29, 2022

Description of changes:

Kani was building on M1 but refusing to perform verifications with the following error: error: Kani requires the target platform to be x86_64-unknown-linux-gnu or x86_64-apple-darwin, but it is arm64-apple-macosx11.0.0
error: aborting due to previous error.

Modified check_target() in compiler_interface.rs to accept 'arm64-apple-*', machine_model_from_session() in goto_ctx.rs to use the parameters for this target (added a small cpp in tools/sizeofs/main.cpp to generate these), and fixed a few tests that had hardcoded assumes on type sizes and alignements.

Resolved issues:

Resolves #1167

Call-outs:

Not covering any CI aspects.

Testing:

  • How is this change tested?
  • "cargo clean ; cargo build --workspace ; ./scripts/kani-regression.sh" tests are passing
  • generated a bundle and installed it with cargo-kani setup --use-local-bundle
  • Is this a refactor change?
  • nope

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.

* Modified check_target() in compiler_interface.rs to accept 'arm64-apple-*',
* machine_model_from_session() in goto_ctx.rs to use the parameters for this target
* added a small cpp in tools/sizeofs/main.cpp to generate these)
* fixed a few tests that had hardcoded assumes on type sizes and alignements.
@ssoudan ssoudan requested a review from a team as a code owner June 29, 2022 23:28
ssoudan added 2 commits June 30, 2022 08:22
Added copyright header to tools/sizeofs/main.cpp
Copy link
Contributor

@tedinski tedinski left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

I think I want to change some things, but they're more appropriate for a refactoring followup after I add arm64 linux as well...

Comment on lines +232 to +234
let is_x86_64_darwin_target = session.target.llvm_target.starts_with("x86_64-apple-");
// looking for `arm64-apple-*`
let is_arm64_darwin_target = session.target.llvm_target.starts_with("arm64-apple-");
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't your change, but ew. I wonder if there's a convenient way to look at the Rust target name here, not the LLVM one, because Rust-side this should be "darwin" consistently, I think.

Note to self for a refactoring follow-up...

long_double_width,
long_int_width,
long_long_int_width,
memory_operand_size: int_width / 8,
Copy link
Contributor

Choose a reason for hiding this comment

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

Good change.

Comment on lines +23 to +24
#[cfg(target_arch = "aarch64")]
assert_eq!(align_of_val(t), 16);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, note to self: wonder if this will be different on linux arm64.

@tedinski tedinski merged commit ee1d0c6 into model-checking:main Jun 30, 2022
@ssoudan ssoudan deleted the feature/m1 branch July 1, 2022 06:24
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.

Kani won't install on Apple M1
2 participants