-
Notifications
You must be signed in to change notification settings - Fork 98
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,10 +350,10 @@ impl MetadataLoader for GotocMetadataLoader { | |
|
||
/// Builds a machine model which is required by CBMC | ||
fn machine_model_from_session(sess: &Session) -> MachineModel { | ||
// The model assumes a `x86_64-unknown-linux-gnu` or `x86_64-apple-darwin` | ||
// platform. We check the target platform in function `check_target` from | ||
// src/kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs and | ||
// error if it is not any of the ones we expect. | ||
// The model assumes a `x86_64-unknown-linux-gnu`, `x86_64-apple-darwin` | ||
// or `aarch64-apple-darwin` platform. We check the target platform in function | ||
// `check_target` from src/kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs | ||
// and error if it is not any of the ones we expect. | ||
let architecture = &sess.target.arch; | ||
let pointer_width = sess.target.pointer_width.into(); | ||
|
||
|
@@ -372,45 +372,90 @@ fn machine_model_from_session(sess: &Session) -> MachineModel { | |
|
||
// The values below cannot be obtained from the session so they are | ||
// hardcoded using standard ones for the supported platforms | ||
let bool_width = 8; | ||
let char_is_unsigned = false; | ||
let char_width = 8; | ||
let double_width = 64; | ||
let float_width = 32; | ||
let int_width = 32; | ||
let long_double_width = 128; | ||
let long_int_width = 64; | ||
let long_long_int_width = 64; | ||
let memory_operand_size = 4; | ||
let null_is_zero = true; | ||
let short_int_width = 16; | ||
let single_width = 32; | ||
let wchar_t_is_unsigned = false; | ||
let wchar_t_width = 32; | ||
let word_size = 32; | ||
let rounding_mode = RoundingMode::ToNearest; | ||
|
||
MachineModel { | ||
architecture: architecture.to_string(), | ||
alignment, | ||
bool_width, | ||
char_is_unsigned, | ||
char_width, | ||
double_width, | ||
float_width, | ||
int_width, | ||
is_big_endian, | ||
long_double_width, | ||
long_int_width, | ||
long_long_int_width, | ||
memory_operand_size, | ||
null_is_zero, | ||
pointer_width, | ||
rounding_mode, | ||
short_int_width, | ||
single_width, | ||
wchar_t_is_unsigned, | ||
wchar_t_width, | ||
word_size, | ||
// see /tools/sizeofs/main.cpp. | ||
// For reference, the definition in CBMC: | ||
//https://github.com/diffblue/cbmc/blob/develop/src/util/config.cpp | ||
match architecture.as_ref() { | ||
"x86_64" => { | ||
let bool_width = 8; | ||
let char_is_unsigned = false; | ||
let char_width = 8; | ||
let double_width = 64; | ||
let float_width = 32; | ||
let int_width = 32; | ||
let long_double_width = 128; | ||
let long_int_width = 64; | ||
let long_long_int_width = 64; | ||
let short_int_width = 16; | ||
let single_width = 32; | ||
let wchar_t_is_unsigned = false; | ||
let wchar_t_width = 32; | ||
|
||
MachineModel { | ||
architecture: architecture.to_string(), | ||
alignment, | ||
bool_width, | ||
char_is_unsigned, | ||
char_width, | ||
double_width, | ||
float_width, | ||
int_width, | ||
is_big_endian, | ||
long_double_width, | ||
long_int_width, | ||
long_long_int_width, | ||
memory_operand_size: int_width / 8, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good change. |
||
null_is_zero: true, | ||
pointer_width, | ||
rounding_mode: RoundingMode::ToNearest, | ||
short_int_width, | ||
single_width, | ||
wchar_t_is_unsigned, | ||
wchar_t_width, | ||
word_size: int_width, | ||
} | ||
} | ||
"aarch64" => { | ||
let bool_width = 8; | ||
let char_is_unsigned = true; | ||
let char_width = 8; | ||
let double_width = 64; | ||
let float_width = 32; | ||
let int_width = 32; | ||
let long_double_width = 64; | ||
let long_int_width = 64; | ||
let long_long_int_width = 64; | ||
let short_int_width = 16; | ||
let single_width = 32; | ||
let wchar_t_is_unsigned = false; | ||
let wchar_t_width = 32; | ||
|
||
MachineModel { | ||
architecture: architecture.to_string(), | ||
alignment, | ||
bool_width, | ||
char_is_unsigned, | ||
char_width, | ||
double_width, | ||
float_width, | ||
int_width, | ||
is_big_endian, | ||
long_double_width, | ||
long_int_width, | ||
long_long_int_width, | ||
memory_operand_size: int_width / 8, | ||
null_is_zero: true, | ||
pointer_width, | ||
rounding_mode: RoundingMode::ToNearest, | ||
short_int_width, | ||
single_width, | ||
wchar_t_is_unsigned, | ||
wchar_t_width, | ||
word_size: int_width, | ||
} | ||
} | ||
_ => { | ||
panic!("Unsupported architecture: {}", architecture); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,10 @@ impl T for A {} | |
fn check_align_simple() { | ||
let a = A { id: 0 }; | ||
let t: &dyn T = &a; | ||
#[cfg(target_arch = "x86_64")] | ||
assert_eq!(align_of_val(t), 8); | ||
#[cfg(target_arch = "aarch64")] | ||
assert_eq!(align_of_val(t), 16); | ||
Comment on lines
+23
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
assert_eq!(align_of_val(&t), 8); | ||
} | ||
|
||
|
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
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...