Skip to content

Commit 7f537ce

Browse files
committed
add script and documentation for rebasing over a version bump
1 parent d5944e3 commit 7f537ce

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
### Updating the code forked form rustc
2+
3+
First, download the rust repository somewhere on your machine:
4+
5+
```
6+
git clone https://github.com/rust-lang/rust/
7+
```
8+
9+
Now `cd` back go the Verus repository that you want to apply the changes to. For the next step, you'll need to know the rustc version you're updating from and to. Run:
10+
11+
```
12+
./source/tools/update-rustc-forks.sh /path/to/rust <old> <new>
13+
```
14+
15+
Rust uses the version numbers as tags, so for example, if you're trying to update from 1.88.0 to 1.89.0, you can just do:
16+
17+
```
18+
./source/tools/update-rustc-forks.sh /path/to/rust 1.88.0 1.89.0
19+
```
20+
21+
This script will create a diff of all the relevant code and fetch it into your repository. If the script is successful, you'll see output like:
22+
23+
```
24+
Diff prepared. When you're ready to apply it, run:
25+
git cherry-pick <some commit hash>
26+
```
27+
28+
### Tips for resolving any conflicts
29+
30+
In our fork, all the dependencies from the `rustc_mir_build/Cargo.toml` file were moved to be `extern crate` lines in `rustc_mir_build/src/lib.rs` file. So if you see any conflicts in `Cargo.toml`, you may need to modify `lib.rs`.

source/tools/update-rustc-forks.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
RUST_DIR=$1
6+
BASE=$2
7+
UPDATED=$3
8+
9+
SCRIPT_DIR=$(dirname "$0")
10+
VERUS_DIR=$(realpath $SCRIPT_DIR/../..)
11+
12+
VERUS_TMP_DIR=$(mktemp -d)
13+
echo $VERUS_TMP_DIR
14+
15+
cd $VERUS_DIR
16+
GIT_CONFIG_USER_NAME=$(git config user.name)
17+
GIT_CONFIG_USER_EMAIL=$(git config user.email)
18+
19+
cd $VERUS_TMP_DIR
20+
git init
21+
22+
cd $RUST_DIR
23+
git checkout $BASE
24+
GIT_BASE_HASH=$(git rev-parse HEAD)
25+
26+
cd $VERUS_TMP_DIR
27+
mkdir source
28+
mkdir source/rustc_hir_typeck
29+
mkdir source/rustc_hir_typeck/src
30+
cp -r $RUST_DIR/compiler/rustc_mir_build $VERUS_TMP_DIR/source/
31+
cp -r $RUST_DIR/compiler/rustc_hir_typeck/src/upvar.rs $VERUS_TMP_DIR/source/rustc_hir_typeck/src/
32+
cp -r $RUST_DIR/compiler/rustc_hir_typeck/src/expr_use_visitor.rs $VERUS_TMP_DIR/source/rustc_hir_typeck/src/
33+
git add source
34+
git commit --author="nobody <nobody>" -m "base (from $BASE)"
35+
36+
cd $RUST_DIR
37+
git checkout $UPDATED
38+
GIT_UPDATED_HASH=$(git rev-parse HEAD)
39+
40+
cd $VERUS_TMP_DIR
41+
git rm -r source
42+
mkdir source
43+
mkdir source/rustc_hir_typeck
44+
mkdir source/rustc_hir_typeck/src
45+
cp -r $RUST_DIR/compiler/rustc_mir_build $VERUS_TMP_DIR/source/
46+
cp -r $RUST_DIR/compiler/rustc_hir_typeck/src/upvar.rs $VERUS_TMP_DIR/source/rustc_hir_typeck/src/
47+
cp -r $RUST_DIR/compiler/rustc_hir_typeck/src/expr_use_visitor.rs $VERUS_TMP_DIR/source/rustc_hir_typeck/src/
48+
git add source
49+
git commit --author="nobody <nobody>" -m "Updating forked Rust code: from $BASE ($GIT_BASE_HASH) to $UPDATED ($GIT_UPDATED_HASH)" -m "Diff generated by: update-rustc-forks.sh" -m "Applied by: $GIT_CONFIG_USER_NAME <$GIT_CONFIG_USER_EMAIL>"
50+
51+
GIT_COMMIT=$(git rev-parse HEAD)
52+
53+
cd $VERUS_DIR
54+
git fetch $VERUS_TMP_DIR/.git
55+
56+
echo ""
57+
echo "===="
58+
echo ""
59+
60+
echo "Diff prepared. When you're ready to apply it, run:"
61+
echo "git cherry-pick $GIT_COMMIT"
62+

0 commit comments

Comments
 (0)