-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 WIP stable MIR crate #97385
Merged
Merged
Add WIP stable MIR crate #97385
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3e0c1c8
Add WIP stable MIR crate
oli-obk d9a3f5c
Add instructions
oli-obk fe76f03
Add additional crates to `very_unstable
xldenis e5b824c
Documentation never hurts
oli-obk 36f3c03
Update instructions
oli-obk 9da5e13
Rustfmt
oli-obk 615f8c5
record which nightly we support
oli-obk 9abcb5c
Make the crate work both in rustc and locally
oli-obk bec7538
Add 'compiler/rustc_smir/' from commit '9abcb5c7b574cf316eb23d3f46918…
oli-obk 9960cc1
Ship rustc_smir with rustc
oli-obk 0324ac8
List all crates used in crate source in Cargo.toml
oli-obk 7cba9ed
Rustfmt
oli-obk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "rustc_smir" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
rustc_borrowck = { path = "../rustc_borrowck", optional = true } | ||
rustc_driver = { path = "../rustc_driver", optional = true } | ||
rustc_hir = { path = "../rustc_hir", optional = true } | ||
rustc_interface = { path = "../rustc_interface", optional = true } | ||
rustc_middle = { path = "../rustc_middle", optional = true } | ||
rustc_mir_dataflow = { path = "../rustc_mir_dataflow", optional = true } | ||
rustc_mir_transform = { path = "../rustc_mir_transform", optional = true } | ||
rustc_serialize = { path = "../rustc_serialize", optional = true } | ||
rustc_trait_selection = { path = "../rustc_trait_selection", optional = true } | ||
|
||
[features] | ||
default = [ | ||
"rustc_borrowck", | ||
"rustc_driver", | ||
"rustc_hir", | ||
"rustc_interface", | ||
"rustc_middle", | ||
"rustc_mir_dataflow", | ||
"rustc_mir_transform", | ||
"rustc_serialize", | ||
"rustc_trait_selection", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
This crate is regularly synced with its mirror in the rustc repo at `compiler/rustc_smir`. | ||
|
||
We use `git subtree` for this to preserve commits and allow the rustc repo to | ||
edit these crates without having to touch this repo. This keeps the crates compiling | ||
while allowing us to independently work on them here. The effort of keeping them in | ||
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 | ||
|
||
In the rustc repo, execute | ||
|
||
``` | ||
git subtree push --prefix=compiler/rustc_smir url_to_your_fork_of_project_stable_mir some_feature_branch | ||
``` | ||
|
||
and then open a PR of your `some_feature_branch` against https://github.com/rust-lang/project-stable-mir | ||
|
||
### 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 | ||
|
||
``` | ||
git subtree pull --prefix=compiler/rustc_smir https://github.com/rust-lang/project-stable-mir smir | ||
``` | ||
|
||
Note: only ever sync to rustc from the project-stable-mir's `smir` branch. Do not sync with your own forks. | ||
|
||
Then open a PR against rustc just like a regular PR. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[toolchain] | ||
channel = "nightly-2022-06-01" | ||
components = [ "rustfmt", "rustc-dev" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//! 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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, | ||
InlineAsmOperand, Local, LocalDecl, LocalInfo, LocalKind, Location, MirPhase, MirSource, | ||
NullOp, Operand, Place, PlaceRef, ProjectionElem, ProjectionKind, Promoted, RetagKind, Rvalue, | ||
Safety, SourceInfo, SourceScope, SourceScopeData, SourceScopeLocalData, Statement, | ||
StatementKind, UnOp, UserTypeProjection, UserTypeProjections, VarBindingForm, VarDebugInfo, | ||
VarDebugInfoContents, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! This module reexports various crates and modules from unstable rustc APIs. | ||
//! Add anything you need here and it will get slowly transferred to a stable API. | ||
//! Only use rustc_smir in your dependencies and use the reexports here instead of | ||
//! directly referring to the unstable crates. | ||
|
||
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, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
After the PR is merged you need to subtree push it back into https://github.com/rust-lang/project-stable-mir to prevent conflicts when pulling back in again in some cases.