Skip to content

Commit d8445b1

Browse files
committed
Add Rustup installation instructions to README
Now that cranelift is distributed with Rustup, I find myself constantly searching for the rust-lang/rust#81746 PR. I think that it would be useful to also describe the Rustup installation/usage instructions here in README.
1 parent 82487a9 commit d8445b1

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

Readme.md

+40-9
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,48 @@ This has the potential to improve compilation times in debug mode.
55
If your project doesn't use any of the things listed under "Not yet supported", it should work fine.
66
If not please open an issue.
77

8+
## Download using Rustup
9+
10+
The Cranelift codegen backend is distributed in nightly builds on Linux and x86_64 macOS. If you want to
11+
install it using Rustup, you can do that by running:
12+
13+
```bash
14+
$ rustup component add rustc-codegen-cranelift-preview --toolchain nightly
15+
```
16+
17+
Once it is installed, you can enable it with one of the following approaches:
18+
- `CARGO_PROFILE_DEV_CODEGEN_BACKEND=cranelift cargo +nightly build -Zcodegen-backend`
19+
- `RUSTFLAGS="-Zcodegen-backend=cranelift" cargo +nightly build`
20+
- Add the following to `.cargo/config.toml`:
21+
```toml
22+
[unstable]
23+
codegen-backend = true
24+
25+
[profile.dev]
26+
codegen-backend = "cranelift"
27+
```
28+
- Add the following to `Cargo.toml`:
29+
```toml
30+
# This line needs to come before anything else in Cargo.toml
31+
cargo-features = ["codegen-backend"]
32+
33+
[profile.dev]
34+
codegen-backend = "cranelift"
35+
```
36+
37+
## Precompiled builds
38+
39+
You can also download a pre-built version from the [releases] page.
40+
Extract the `dist` directory in the archive anywhere you want.
41+
If you want to use `cargo clif build` instead of having to specify the full path to the `cargo-clif` executable, you can add the `bin` subdirectory of the extracted `dist` directory to your `PATH`.
42+
(tutorial [for Windows](https://stackoverflow.com/a/44272417), and [for Linux/MacOS](https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path/26059#26059)).
43+
44+
[releases]: https://github.com/rust-lang/rustc_codegen_cranelift/releases/tag/dev
45+
846
## Building and testing
947

48+
If you want to build the backend manually, you can download it from GitHub and build it yourself:
49+
1050
```bash
1151
$ git clone https://github.com/rust-lang/rustc_codegen_cranelift
1252
$ cd rustc_codegen_cranelift
@@ -22,15 +62,6 @@ $ ./test.sh
2262

2363
For more docs on how to build and test see [build_system/usage.txt](build_system/usage.txt) or the help message of `./y.sh`.
2464

25-
## Precompiled builds
26-
27-
Alternatively you can download a pre built version from the [releases] page.
28-
Extract the `dist` directory in the archive anywhere you want.
29-
If you want to use `cargo clif build` instead of having to specify the full path to the `cargo-clif` executable, you can add the `bin` subdirectory of the extracted `dist` directory to your `PATH`.
30-
(tutorial [for Windows](https://stackoverflow.com/a/44272417), and [for Linux/MacOS](https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path/26059#26059)).
31-
32-
[releases]: https://github.com/rust-lang/rustc_codegen_cranelift/releases/tag/dev
33-
3465
## Usage
3566

3667
rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects.

0 commit comments

Comments
 (0)