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

Miri subtree instructions #2561

Closed
wants to merge 5 commits into from
Closed
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
56 changes: 56 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,59 @@ see <https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html>.

With this, you should now have a working development setup! See
[above](#building-and-testing-miri) for how to proceed working on Miri.

### Syncing the miri subtree

Note: Never rebase a subtree sync (in either direction). Always redo the operation.

All of these operations happen *on a checkout of the rustc repo*. At no time do you
even need a checkout of the miri repo or run any commands in it.

#### Moving changes from the rustc repo to the miri repo

One time setup:

Add your own miri fork as `miri-your-fork` to your rustc checkout:

```
git remote add miri-your-fork git@github.com:your-name/miri.git
```

Every time:

Note: the first time you run this, `git subtree` builds a cache and this command may thusly take an hour or so.
Copy link
Member

Choose a reason for hiding this comment

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

An hour?!??? :(

I have many rustc checkouts. How can I make it share the cache between my checkouts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea, this worked faster for clippy and other repos...

Copy link
Member

Choose a reason for hiding this comment

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

If you use git worktree for creating the extra git checkouts I believe the subtree cache is shared. Not entirely sure though.

I have no idea, this worked faster for clippy and other repos...

The first common commit between rust and miri is from 2018 (when rust-lang/rust#46882 merged it into rustc as const eval engine). Git subtree has to walk all commits since then I believe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, that's not really useful... why doesn't it just walk the subtree_add_commit..HEAD range and rewrite those commits...


```
ulimit -Ss 1000000
wget https://raw.githubusercontent.com/gitgitgadget/git/fe2e4819b869725f870cd3ce99f1f8150fe17dc1/contrib/subtree/git-subtree.sh
sh git-subtree.sh push --prefix src/tools/miri/ miri-your-fork miri-subtree-sync
rm git-subtree.sh
```

Now you'll have a branch called `miri-subtree-sync` in your miri fork that you can use to open a PR to miri.
Do not rebase this branch. If there are conflicts with the miri repo, you need to use the merge strategy, even if this
is otherwise not permitted for other PRs to the miri repo.

#### Moving changes from the miri repo to the rustc repo

One time setup:

Add the main miri repo as `miri` to your rustc checkout:

```
git remote add miri https://github.com/rust-lang/miri.git
```

Every time:
Copy link
Member

Choose a reason for hiding this comment

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

Does this also need that cache or is this always fast(er)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is always fast, just a few seconds at most, does not get slower with time


```
ulimit -Ss 1000000
wget https://raw.githubusercontent.com/gitgitgadget/git/fe2e4819b869725f870cd3ce99f1f8150fe17dc1/contrib/subtree/git-subtree.sh
sh git-subtree.sh pull --prefix src/tools/miri/ miri master
rm git-subtree.sh
```

Now your currently checked out branch has a new merge commit that pulls in the miri changes. Use this to open a PR
against the rustc repo.
Do not rebase this branch. If there are conflicts with the rustc repo, you need to use the merge strategy, even if this
is otherwise not permitted for other PRs to the rustc repo.