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

Synchronize smir crate with rust-lang/rust #5

Merged
merged 5 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
11 changes: 7 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ version = "0.0.0"
edition = "2021"

[dependencies]
rustc_middle = { path = "../rustc_middle" }
rustc_driver = { path = "../rustc_driver" }
rustc_borrowck = { path = "../rustc_borrowck" }
rustc_interface = { path = "../rustc_interface" }
rustc_middle = { path = "../rustc_middle", optional = true }
rustc_driver = { path = "../rustc_driver", optional = true }
rustc_borrowck = { path = "../rustc_borrowck", optional = true }
rustc_interface = { path = "../rustc_interface", optional = true }

[features]
default = ["rustc_middle", "rustc_driver", "rustc_borrowck", "rustc_interface"]
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ sync is pushed entirely onto us, without affecting rustc workflows negatively.
This may change in the future, but changes to policy should only be done via a
compiler team MCP.

## Instructions for working on this crate locally

Since the crate is the same in the rustc repo and here, the dependencies on rustc_* crates
will only either work here or there, but never in both places at the same time. Thus we use
optional dependencies on the rustc_* crates, requiring local development to use

```
cargo build --no-default-features -Zavoid-dev-deps
```

in order to compile successfully.

## Instructions for syncing

### Updating this repository
Expand All @@ -19,8 +31,38 @@ git subtree push --prefix=compiler/rustc_smir url_to_your_fork_of_project_stable

and then open a PR of your `some_feature_branch` against https://github.com/rust-lang/project-stable-mir

### Updating the rustc librar
### Updating the rustc library

First we need to bump our stack limit, as the rustc repo otherwise quickly hits that:

```
ulimit -s 60000
```

#### Maximum function recursion depth (1000) reached

Then we need to disable `dash` as the default shell for sh scripts, as otherwise we run into a
hard limit of a recursion depth of 1000:

```
sudo dpkg-reconfigure dash
```

and then select `No` to disable dash.


#### Patching your `git worktree`

The regular git worktree does not scale to repos of the size of the rustc repo.
So download the `git-subtree.sh` from https://github.com/gitgitgadget/git/pull/493/files and run

```
sudo cp --backup /path/to/patched/git-subtree.sh /usr/lib/git-core/git-subtree
sudo chmod --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
sudo chown --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree
```

#### Actually doing a sync

In the rustc repo, execute

Expand Down
3 changes: 3 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2022-06-01"
components = [ "rustfmt", "rustc-dev" ]
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
//! The WIP stable interface to rustc internals.
//!
//! For more information see https://github.com/rust-lang/project-stable-mir
//!
//! # Note
//!
//! This API is still completely unstable and subject to change.

#![doc(
html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/",
test(attr(allow(unused_variables), deny(warnings)))
)]

#![cfg_attr(not(feature = "default"), feature(rustc_private))]

pub mod mir;

pub mod very_unstable;
2 changes: 1 addition & 1 deletion src/mir.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub use rustc_middle::mir::{
pub use crate::very_unstable::middle::mir::{
visit::MutVisitor, AggregateKind, AssertKind, BasicBlock, BasicBlockData, BinOp, BindingForm,
BlockTailInfo, Body, BorrowKind, CastKind, ClearCrossCrate, Constant, ConstantKind,
CopyNonOverlapping, Coverage, FakeReadCause, Field, GeneratorInfo, ImplicitSelfKind,
Expand Down
31 changes: 22 additions & 9 deletions src/very_unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@
//! Only use rustc_smir in your dependencies and use the reexports here instead of
//! directly referring to the unstable crates.

pub use rustc_borrowck as borrowck;
pub use rustc_driver as driver;
pub use rustc_hir as hir;
pub use rustc_interface as interface;
pub use rustc_middle as middle;
pub use rustc_mir_dataflow as dataflow;
pub use rustc_mir_transform as transform;
pub use rustc_serialize as serialize;
pub use rustc_trait_selection as trait_selection;
macro_rules! crates {
($($rustc_name:ident -> $name:ident,)*) => {
$(
#[cfg(not(feature = "default"))]
pub extern crate $rustc_name as $name;
#[cfg(feature = "default")]
pub use $rustc_name as $name;
)*
}
}

crates! {
rustc_borrowck -> borrowck,
rustc_driver -> driver,
rustc_hir -> hir,
rustc_interface -> interface,
rustc_middle -> middle,
rustc_mir_dataflow -> dataflow,
rustc_mir_transform -> transform,
rustc_serialize -> serialize,
rustc_trait_selection -> trait_selection,
}