Create an RMC crate and load it as part of rmc-rustc#597
Create an RMC crate and load it as part of rmc-rustc#597celinval merged 6 commits intomodel-checking:mainfrom
Conversation
- Create an rmc crate (model-checking#231). - Used rust compliant names for the functions (model-checking#589). - Changed rmc-rustc to inject the rmc prelude as part of the compilation as well as other rmc configuration flags. - Added options to rmc-rustc to print binary path and flags so it can be used in other scripts.
RMC code generation was creating artifacts even if rustc was run with -Z no-codegen. I changed the codegen to check for this option before writing the json files. This issue was uncovered by my change to move the rmc flags to rmc-rustc. This script is used during compiletest. In the check stage, the test runs rustc with --no-codegen.
adpaco-aws
left a comment
There was a problem hiding this comment.
This is awesome! Some comments.
| ./x.py build -i --stage 1 library/std | ||
|
|
||
| - name: Build RMC Library | ||
| run: bash -x ./scripts/setup/build_rmc_lib.sh |
There was a problem hiding this comment.
Is there any advantage to having -x written here and not in the script itself?
There was a problem hiding this comment.
I was wondering if this script will be helpful for users to build RMC library. In this case, we can keep the trace turned off by default, but still turn them on in the CI. What do you think?
| // "path.o" | ||
| let base_filename = outputs.path(OutputType::Object); | ||
| // No output should be generated if user selected no_codegen. | ||
| if !sess.opts.debugging_opts.no_codegen && sess.opts.output_types.should_codegen() { |
There was a problem hiding this comment.
Does this need to be in the same PR?
There was a problem hiding this comment.
Yes. The regression will fail if this is not here.
There was a problem hiding this comment.
I can submit a separate PR and merge it first if that makes more sense.
There was a problem hiding this comment.
adpaco-aws
left a comment
There was a problem hiding this comment.
LGTM! My only concern now is that compiling the RMC library is necessary to use these predicates, so we should update the documentation accordingly. But we can have that in a follow-up PR.
| ./x.py build -i --stage 1 library/std | ||
|
|
||
| - name: Build RMC Library | ||
| run: bash -x ./scripts/setup/build_rmc_lib.sh |
Good point. I'll submit a PR for that! |
| /// ``` | ||
| #[inline(never)] | ||
| #[rustc_diagnostic_item = "RmcNonDet"] | ||
| pub fn nondet<T>() -> T { |
There was a problem hiding this comment.
This really needs to be marked as unsafe as callers need to ensure all of the type's invariants are met.
There was a problem hiding this comment.
I have pushed this code already, but I created #607 to capture the work to fix this. Thanks
| /// ``` | ||
| #[inline(never)] | ||
| #[rustc_diagnostic_item = "RmcAssume"] | ||
| pub fn assume(_cond: bool) {} |
There was a problem hiding this comment.
For a better docs and IDE experience, it would be preferable to do something like:
pub fn assume(cond: bool) {
let _ = cond;
}Same goes for the other arguments.
There was a problem hiding this comment.
Sure. I'll fix this next time I push some updates to this crate. Thanks for the suggestion.
) * Adding support to new rmc prelude definitions - Create an rmc crate (model-checking#231). - Used rust compliant names for the functions (model-checking#589). - Changed rmc-rustc to inject the rmc prelude as part of the compilation as well as other rmc configuration flags. - Added options to rmc-rustc to print binary path and flags so it can be used in other scripts. * Add a script to build rmc library * Update tests to use new injected prelude.
* Adding support to new rmc prelude definitions - Create an rmc crate (#231). - Used rust compliant names for the functions (#589). - Changed rmc-rustc to inject the rmc prelude as part of the compilation as well as other rmc configuration flags. - Added options to rmc-rustc to print binary path and flags so it can be used in other scripts. * Add a script to build rmc library * Update tests to use new injected prelude.
Description of changes:
Users should now be able to use
rmc::nondet(),rmc::assume(bool)andrmc::expect_failas part of their test harnesses. RMC will automatically load the rmc library as part of any crate compilation.Resolved issues:
Resolves #231 and #589.
Call-outs:
This PR also include updates to enable this change.
Testing:
How is this change tested? In all tests that were updated.
Is this a refactor change? No
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.