-
Notifications
You must be signed in to change notification settings - Fork 134
Add rmc-compiler binary to drive rust compilation #722
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
Conversation
scripts/rmc-rustc
Outdated
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.
what is ${RMCFLAGS} here. I mean, I can search this diff, but there should be a comment saying what's happening here.
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.
Sure
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.
It's set by rmc.py because cargo does some funny stuff with RUSTFLAGS.
|
Also, if I'm not mistaken, if we eliminate our remaining use of |
For sure! This change reduced the CI in about 10min. @adpaco-aws and I are working on the second piece. After that, we should be able to prune our repository, remove the bootstrap script and no longer depend on the rust upstream. :) |
Follow the instructions to compile the code using cargo. Need to investigate how to use rustup for std and how to manage rustc version. We need to match the version of rustc that we consume and that we use to compile the code.
Next: Need to move rmc codegen crate.
Still need to fix the change we made to CodegenBackend trait.
Note: Still need to add options to rustc_codegen_rmc
\o/\o/
We would like to allow users to enable / disable the rmc configuraiton in our prelude libraries. Cargo can only do that if the configuration uses feature statement. Hence, I replaced #[cfg(rmc)] by \#[cfg(feature = rmc)]. Note that we only need this because we use regular rustc to pre-compile our libraries.
This is a temporary fix to ensure that our libraries are compiled with the same version as the rmc-compiler. We can remove this once we have a proper workspace configured.
- Add support to the rmc codegen flags - Fix cargo regression (NEED TO DO BETTER)
Instead of building the libraries as part of the build dependencies, we now build them using the build.rs script.
tedinski
left a comment
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.
LGTM. Think DSN should review too?
I think it would be nice to have someone else reviewing it. Let me ping @danielsn. |
danielsn
left a comment
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.
Some questions, but LGTM
| //! | ||
| //! Speical [id]s include: | ||
| //! 1. [Empty] and [Nil] behaves like [null]. | ||
| #![feature(rustc_private)] |
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.
What does this do?
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.
It allow us to use rustc crates.
src/rmc-compiler/src/main.rs
Outdated
| ); | ||
| let sysroot = sysroot_path(args.value_of("sysroot")).unwrap(); | ||
| rustc_args.push(String::from("--sysroot")); | ||
| rustc_args.push(sysroot.to_string_lossy().to_string()); |
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.
Is to_string_lossy what we want here? If there are non-valid characters, shouldn't we just fail?
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.
Sure. We can fail.
src/rmc-compiler/README.md
Outdated
|
|
||
| ### Notes for developers: | ||
|
|
||
| This binary can be build like a regular cargo package. There is no need to |
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.
built
- Replace lossy translation of args by error check. - Add more comments. - Fix typo.
Conflicts:
Cargo.lock
compiler/cbmc/Cargo.toml
danielsn
left a comment
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.
I think there is an issue where you meant to say . and write .. for a directory path. Not sure, but blocking merge till we look at it
src/rmc-compiler/build.rs
Outdated
|
|
||
| macro_rules! path_str { | ||
| ($input:expr) => { | ||
| &$input.iter().collect::<PathBuf>().to_string_lossy().into_owned() |
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.
Did we want to do a lossy conversion, or to fail fast here?
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.
Sure, I can fall fast.
This change introduces a new compilation driver (rmc-compiler) that no longer depends on a modified version of the rust compiler, neither depends on the bootstrap script. The rmc-compiler binary can be build using regular cargo build and can be used as a replacement to rustc with additional options that allow us to compile rust into goto-c.
This change introduces a new compilation driver (rmc-compiler) that no longer depends on a modified version of the rust compiler, neither depends on the bootstrap script. The rmc-compiler binary can be build using regular cargo build and can be used as a replacement to rustc with additional options that allow us to compile rust into goto-c.
Description of changes:
I have created a new compilation driver (rmc-compiler) that no longer depends on a modified version of the rust compiler, neither depends on the bootstrap script.
Resolved issues:
Resolves #42 and #658
Call-outs:
I'm not quite happy with a few things in this change, but it is getting way too big to manage in a separate branch. It is also getting quite big to be reviewed. Thus, I created the following issues to track a few improvements:
Testing:
How is this change tested? All our tests.
Is this a refactor change? Yes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.