Skip to content

Conversation

@celinval
Copy link
Contributor

@celinval celinval commented Dec 29, 2021

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

  • 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.

@celinval celinval requested a review from a team as a code owner December 29, 2021 23:54
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

Copy link
Contributor Author

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.

@tedinski
Copy link
Contributor

Also, if I'm not mistaken, if we eliminate our remaining use of x.py (just compiletest and dashboard/bookrunner, right?) CI runtimes are about to be outstanding!

@celinval
Copy link
Contributor Author

Also, if I'm not mistaken, if we eliminate our remaining use of x.py (just compiletest and dashboard/bookrunner, right?) CI runtimes are about to be outstanding!

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
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.
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.

LGTM. Think DSN should review too?

@celinval
Copy link
Contributor Author

celinval commented Jan 3, 2022

LGTM. Think DSN should review too?

I think it would be nice to have someone else reviewing it. Let me ping @danielsn.

Copy link
Contributor

@danielsn danielsn left a 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)]
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do?

Copy link
Contributor Author

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.

);
let sysroot = sysroot_path(args.value_of("sysroot")).unwrap();
rustc_args.push(String::from("--sysroot"));
rustc_args.push(sysroot.to_string_lossy().to_string());
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. We can fail.


### Notes for developers:

This binary can be build like a regular cargo package. There is no need to
Copy link
Contributor

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
Copy link
Contributor

@danielsn danielsn left a 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


macro_rules! path_str {
($input:expr) => {
&$input.iter().collect::<PathBuf>().to_string_lossy().into_owned()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@danielsn danielsn self-requested a review January 7, 2022 17:38
@celinval celinval merged commit 1534ee4 into model-checking:main Jan 7, 2022
@adpaco-aws adpaco-aws mentioned this pull request Jan 12, 2022
tedinski added a commit to tedinski/rmc that referenced this pull request Jan 18, 2022
tedinski pushed a commit to tedinski/rmc that referenced this pull request Apr 26, 2022
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.
tedinski pushed a commit that referenced this pull request Apr 27, 2022
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.
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.

Compiler interface: remove need to patch upstream API

3 participants