Skip to content

Commit b1961ba

Browse files
committed
Sync from rust d59363ad0b6391b7fc5bbb02c9ccf9300eef3753
2 parents 62e6035 + 04dca8f commit b1961ba

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Readme.md

+26
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,32 @@ This will build your project with rustc_codegen_cranelift instead of the usual L
4747

4848
For additional ways to use rustc_codegen_cranelift like the JIT mode see [usage.md](docs/usage.md).
4949

50+
## Building and testing with changes in rustc code
51+
52+
This is useful when changing code in `rustc_codegen_cranelift` as part of changing [main Rust repository](https://github.com/rust-lang/rust/).
53+
This can happen, for example, when you are implementing a new compiler intrinsic.
54+
55+
Instruction below uses `$RustCheckoutDir` as substitute for any folder where you cloned Rust repository.
56+
57+
You need to do this steps to successfully compile and use the cranelift backend with your changes in rustc code:
58+
59+
1. `cd $RustCheckoutDir`
60+
2. Run `python x.py setup` and choose option for compiler (`b`).
61+
3. Build compiler and necessary tools: `python x.py build --stage=2 compiler library/std src/tools/rustdoc src/tools/rustfmt`
62+
* (Optional) You can also build cargo by adding `src/tools/cargo` to previous command.
63+
4. Copy exectutable files from `./build/host/stage2-tools/<your hostname triple>/release`
64+
to `./build/host/stage2/bin/`. Note that you would need to do this every time you rebuilt `rust` repository.
65+
5. Copy cargo from another toolchain: `cp $(rustup which cargo) .build/<your hostname triple>/stage2/bin/cargo`
66+
* Another option is to build it at step 3 and copy with other executables at step 4.
67+
6. Link your new `rustc` to toolchain: `rustup toolchain link stage2 ./build/host/stage2/`.
68+
7. (Windows only) compile y.rs: `rustc +stage2 -O y.rs`.
69+
8. You need to prefix every `./y.rs` (or `y` if you built `y.rs`) command by `rustup run stage2` to make cg_clif use your local changes in rustc.
70+
71+
* `rustup run stage2 ./y.rs prepare`
72+
* `rustup run stage2 ./y.rs build`
73+
* (Optional) run tests: `rustup run stage2 ./y.rs test`
74+
9. 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`.
75+
5076
## Configuration
5177

5278
See the documentation on the `BackendConfig` struct in [config.rs](src/config.rs) for all

src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
361361
self.instance.subst_mir_and_normalize_erasing_regions(
362362
self.tcx,
363363
ty::ParamEnv::reveal_all(),
364-
ty::EarlyBinder(value),
364+
ty::EarlyBinder::bind(value),
365365
)
366366
}
367367

0 commit comments

Comments
 (0)