Skip to content

Commit 7cdec71

Browse files
committed
Move the rustc testing section out of the readme
To make the readme a bit easier to read.
1 parent e782915 commit 7cdec71

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

Readme.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,7 @@ For additional ways to use rustc_codegen_cranelift like the JIT mode see [usage.
101101

102102
## Building and testing with changes in rustc code
103103

104-
This is useful when changing code in `rustc_codegen_cranelift` as part of changing [main Rust repository](https://github.com/rust-lang/rust/).
105-
This can happen, for example, when you are implementing a new compiler intrinsic.
106-
107-
Instruction below uses `$RustCheckoutDir` as substitute for any folder where you cloned Rust repository.
108-
109-
You need to do this steps to successfully compile and use the cranelift backend with your changes in rustc code:
110-
111-
1. `cd $RustCheckoutDir`
112-
2. Run `python x.py setup` and choose option for compiler (`b`).
113-
3. Build compiler and necessary tools: `python x.py build --stage=2 compiler library/std src/tools/rustdoc src/tools/rustfmt`
114-
* (Optional) You can also build cargo by adding `src/tools/cargo` to previous command.
115-
4. Copy cargo from a nightly toolchain: `cp $(rustup +nightly which cargo) ./build/host/stage2/bin/cargo`. Note that you would need to do this every time you rebuilt `rust` repository.
116-
5. Link your new `rustc` to toolchain: `rustup toolchain link stage2 ./build/host/stage2/`.
117-
6. (Windows only) compile the build system: `rustc +stage2 -O build_system/main.rs -o y.exe`.
118-
7. You need to prefix every `./y.sh` (or `y` if you built `build_system/main.rs` as `y`) command by `rustup run stage2` to make cg_clif use your local changes in rustc.
119-
* `rustup run stage2 ./y.sh prepare`
120-
* `rustup run stage2 ./y.sh build`
121-
* (Optional) run tests: `rustup run stage2 ./y.sh test`
122-
8. Now you can use your cg_clif build to compile other Rust programs, e.g. you can open any Rust crate and run commands like `$RustCheckoutDir/compiler/rustc_codegen_cranelift/dist/cargo-clif build --release`.
123-
124-
You can also set `rust-analyzer.rustc.source` to your rust workspace to get rust-analyzer to understand your changes.
104+
See [rustc_testing.md](docs/rustc_testing.md).
125105

126106
## Not yet supported
127107

docs/rustc_testing.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Building and testing with changes in rustc code
2+
3+
This is useful when changing code in `rustc_codegen_cranelift` as part of changing [main Rust repository](https://github.com/rust-lang/rust/).
4+
This can happen, for example, when you are implementing a new compiler intrinsic.
5+
6+
Instruction below uses `$RustCheckoutDir` as substitute for any folder where you cloned Rust repository.
7+
8+
You need to do this steps to successfully compile and use the cranelift backend with your changes in rustc code:
9+
10+
1. `cd $RustCheckoutDir`
11+
2. Run `python x.py setup` and choose option for compiler (`b`).
12+
3. Build compiler and necessary tools: `python x.py build --stage=2 compiler library/std src/tools/rustdoc src/tools/rustfmt`
13+
* (Optional) You can also build cargo by adding `src/tools/cargo` to previous command.
14+
4. Copy cargo from a nightly toolchain: `cp $(rustup +nightly which cargo) ./build/host/stage2/bin/cargo`. Note that you would need to do this every time you rebuilt `rust` repository.
15+
5. Link your new `rustc` to toolchain: `rustup toolchain link stage2 ./build/host/stage2/`.
16+
6. (Windows only) compile the build system: `rustc +stage2 -O build_system/main.rs -o y.exe`.
17+
7. You need to prefix every `./y.sh` (or `y` if you built `build_system/main.rs` as `y`) command by `rustup run stage2` to make cg_clif use your local changes in rustc.
18+
* `rustup run stage2 ./y.sh prepare`
19+
* `rustup run stage2 ./y.sh build`
20+
* (Optional) run tests: `rustup run stage2 ./y.sh test`
21+
8. Now you can use your cg_clif build to compile other Rust programs, e.g. you can open any Rust crate and run commands like `$RustCheckoutDir/compiler/rustc_codegen_cranelift/dist/cargo-clif build --release`.
22+
23+
You can also set `rust-analyzer.rustc.source` to your rust workspace to get rust-analyzer to understand your changes.

0 commit comments

Comments
 (0)