|
| 1 | +This crate is regularly synced with its mirror in the rustc repo at `compiler/rustc_smir`. |
| 2 | + |
| 3 | +We use `git subtree` for this to preserve commits and allow the rustc repo to |
| 4 | +edit these crates without having to touch this repo. This keeps the crates compiling |
| 5 | +while allowing us to independently work on them here. The effort of keeping them in |
| 6 | +sync is pushed entirely onto us, without affecting rustc workflows negatively. |
| 7 | +This may change in the future, but changes to policy should only be done via a |
| 8 | +compiler team MCP. |
| 9 | + |
| 10 | +## Instructions for working on this crate locally |
| 11 | + |
| 12 | +Since the crate is the same in the rustc repo and here, the dependencies on rustc_* crates |
| 13 | +will only either work here or there, but never in both places at the same time. Thus we use |
| 14 | +optional dependencies on the rustc_* crates, requiring local development to use |
| 15 | + |
| 16 | +``` |
| 17 | +cargo build --no-default-features -Zavoid-dev-deps |
| 18 | +``` |
| 19 | + |
| 20 | +in order to compile successfully. |
| 21 | + |
| 22 | +## Instructions for syncing |
| 23 | + |
| 24 | +### Updating this repository |
| 25 | + |
| 26 | +In the rustc repo, execute |
| 27 | + |
| 28 | +``` |
| 29 | +git subtree push --prefix=compiler/rustc_smir url_to_your_fork_of_project_stable_mir some_feature_branch |
| 30 | +``` |
| 31 | + |
| 32 | +and then open a PR of your `some_feature_branch` against https://github.com/rust-lang/project-stable-mir |
| 33 | + |
| 34 | +### Updating the rustc library |
| 35 | + |
| 36 | +First we need to bump our stack limit, as the rustc repo otherwise quickly hits that: |
| 37 | + |
| 38 | +``` |
| 39 | +ulimit -s 60000 |
| 40 | +``` |
| 41 | + |
| 42 | +#### Maximum function recursion depth (1000) reached |
| 43 | + |
| 44 | +Then we need to disable `dash` as the default shell for sh scripts, as otherwise we run into a |
| 45 | +hard limit of a recursion depth of 1000: |
| 46 | + |
| 47 | +``` |
| 48 | +sudo dpkg-reconfigure dash |
| 49 | +``` |
| 50 | + |
| 51 | +and then select `No` to disable dash. |
| 52 | + |
| 53 | + |
| 54 | +#### Patching your `git worktree` |
| 55 | + |
| 56 | +The regular git worktree does not scale to repos of the size of the rustc repo. |
| 57 | +So download the `git-subtree.sh` from https://github.com/gitgitgadget/git/pull/493/files and run |
| 58 | + |
| 59 | +``` |
| 60 | +sudo cp --backup /path/to/patched/git-subtree.sh /usr/lib/git-core/git-subtree |
| 61 | +sudo chmod --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree |
| 62 | +sudo chown --reference=/usr/lib/git-core/git-subtree~ /usr/lib/git-core/git-subtree |
| 63 | +``` |
| 64 | + |
| 65 | +#### Actually doing a sync |
| 66 | + |
| 67 | +In the rustc repo, execute |
| 68 | + |
| 69 | +``` |
| 70 | +git subtree pull --prefix=compiler/rustc_smir https://github.com/rust-lang/project-stable-mir smir |
| 71 | +``` |
| 72 | + |
| 73 | +Note: only ever sync to rustc from the project-stable-mir's `smir` branch. Do not sync with your own forks. |
| 74 | + |
| 75 | +Then open a PR against rustc just like a regular PR. |
0 commit comments