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

Add intrinsics and Arbitrary support for no_core #3230

Merged
merged 29 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
48defa8
Shift intrinsics and arbitrary to kani_core
jaisnan May 31, 2024
d4e9a7b
Add contracts to scope of user crate
jaisnan Jun 3, 2024
e231f9d
Fix duplicated definitions error
celinval Jun 4, 2024
32ef011
Add one macro to rule them all...
celinval Jun 4, 2024
4d9b7fe
Merge branch 'add-3152' of https://github.com/jaisnan/kani into add-f…
jaisnan Jun 5, 2024
8103dd5
Add flag to disable test addition to std-regression script
jaisnan Jun 5, 2024
33eb53a
comment out flag for custom rust source
jaisnan Jun 5, 2024
d6e8dd0
Add flag to regression
jaisnan Jun 5, 2024
e093376
undo changes to arbitrary
jaisnan Jun 5, 2024
78328ed
Commit till the point of compiling std-lib
jaisnan Jun 6, 2024
b08dc9c
Merge branch 'add-fix-3152' of https://github.com/jaisnan/kani into a…
jaisnan Jun 6, 2024
63f3ea6
Merge branch 'main' of https://github.com/model-checking/kani into ad…
jaisnan Jun 6, 2024
4614e65
get core to compile everything but proof_for_contract
jaisnan Jun 7, 2024
18a556e
Add -Zfunction-contracts and cfg(no_core)
jaisnan Jun 7, 2024
b465652
Merge branch 'main' of https://github.com/model-checking/kani into tm…
jaisnan Jun 7, 2024
3566f9e
cargo fmt
jaisnan Jun 10, 2024
13c27cd
Merge branch 'tmp-branch-3152' into add-fix-3152
jaisnan Jun 10, 2024
e6a8189
Merge branch 'main' of https://github.com/model-checking/kani into ad…
jaisnan Jun 10, 2024
57dda05
Merge branch 'main' of https://github.com/model-checking/kani into ad…
jaisnan Jun 10, 2024
985adca
Add changes to the point where proof_for_Contract works as well.
jaisnan Jun 10, 2024
b211bac
Merge branch 'main' into add-fix-3152
jaisnan Jun 10, 2024
ce6cd61
Revert changes, and cleanup
jaisnan Jun 10, 2024
fb3b9c4
Merge branch 'main' of https://github.com/model-checking/kani into ad…
jaisnan Jun 10, 2024
752c7e9
Merge branch 'main' into add-fix-3152
jaisnan Jun 10, 2024
e0b1693
Remove -Z function contract; Add some tests related to function contr…
jaisnan Jun 10, 2024
219bee7
Merge branch 'add-fix-3152' of https://github.com/jaisnan/kani into a…
jaisnan Jun 10, 2024
a1f3a43
replace kani with kani_core
jaisnan Jun 10, 2024
e96d4a7
Add basic comments
jaisnan Jun 10, 2024
cbcbb72
Fix regression test for verify_std
jaisnan Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add -Zfunction-contracts and cfg(no_core)
  • Loading branch information
jaisnan committed Jun 7, 2024
commit 18a556e4589b8a8bcc8a9ba24c42bbb817c8bdc6
4 changes: 4 additions & 0 deletions kani-driver/src/call_cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl KaniSession {
let mut rustc_args = self.kani_rustc_flags(LibConfig::new_no_core(lib_path));
rustc_args.push(to_rustc_arg(self.kani_compiler_flags()).into());
rustc_args.push(self.reachability_arg().into());
rustc_args.push(to_rustc_arg(vec!["--ignore-global-asm".to_string()]).into());
rustc_args.push(to_rustc_arg(vec!["-Zfunction-contracts".to_string()]).into());
celinval marked this conversation as resolved.
Show resolved Hide resolved
rustc_args.push(to_rustc_arg(vec!["--enable-stubbing".to_string()]).into());


let mut cargo_args: Vec<OsString> = vec!["build".into()];
cargo_args.append(&mut cargo_config_args());
Expand Down
27 changes: 26 additions & 1 deletion library/kani_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,30 @@ macro_rules! kani_intrinsics {
#[allow(clippy::empty_loop)]
loop {}
}
};

pub mod internal {
/// A way to break the ownerhip rules. Only used by contracts where we can
/// guarantee it is done safely.
#[inline(never)]
#[doc(hidden)]
#[rustc_diagnostic_item = "KaniUntrackedDeref"]
pub fn untracked_deref<T>(_: &T) -> T {
todo!()
}

/// CBMC contracts currently has a limitation where `free` has to be in scope.
/// However, if there is no dynamic allocation in the harness, slicing removes `free` from the
/// scope.
///
/// Thus, this function will basically translate into:
/// ```c
/// // This is a no-op.
/// free(NULL);
/// ```
#[inline(never)]
#[doc(hidden)]
#[rustc_diagnostic_item = "KaniInitContracts"]
pub fn init_contracts() {}
}
}
}
4 changes: 2 additions & 2 deletions library/kani_macros/src/sysroot/contracts/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ pub fn make_unsafe_argument_copies(
let arg_values = renaming_map.keys();
(
quote!(#(let #arg_names = kani::internal::untracked_deref(&#arg_values);)*),
#[cfg(feature = "no_core")]
quote!(#(crate::mem::block(#also_arg_names);)*),
#[cfg(not(feature = "no_core"))]
quote!(#(std::mem::forget(#also_arg_names);)*),
#[cfg(feature = "no_core")]
quote!(#(core::mem::forget(#also_arg_names);)*),
)
}

Expand Down