X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=Readme.md;h=dad8ed90b53b8307fb1c4b72d40b15a59c2878bd;hb=d480d9ee3b8bf1b07f85fee1605df1a106c50530;hp=ba56e576498684fad0953769afd0a274f6c40914;hpb=fd3be6d4920a2aef5db17f0e4abc90dcf1e14f2d;p=rust.git diff --git a/Readme.md b/Readme.md index ba56e576498..dad8ed90b53 100644 --- a/Readme.md +++ b/Readme.md @@ -1,54 +1,75 @@ -# WIP Cranelift codegen backend for rust +# Cranelift codegen backend for rust -> â â â Certain kinds of FFI don't work yet. â â â +The goal of this project is to create an alternative codegen backend for the rust compiler based on [Cranelift](https://github.com/bytecodealliance/wasmtime/blob/main/cranelift). +This has the potential to improve compilation times in debug mode. +If your project doesn't use any of the things listed under "Not yet supported", it should work fine. +If not please open an issue. -## Building +## Building and testing ```bash $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git $ cd rustc_codegen_cranelift -$ ./prepare.sh # download and patch sysroot src and install hyperfine for benchmarking -$ ./test.sh --release +$ ./y.rs prepare # download and patch sysroot src and install hyperfine for benchmarking +$ ./y.rs build ``` -## Usage - -`$cg_clif_dir` is the directory you cloned this repo into in the following instruction. - -### Cargo +To run the test suite replace the last command with: ```bash -$ CHANNEL="release" $cg_clif_dir/cargo.sh run +$ ./test.sh ``` -If you compiled cg_clif in debug mode (aka you didn't pass `--release` to `./test.sh`) you should use `CHANNEL="debug"` instead or omit `CHANNEL="release"` completely. +This will implicitly build cg_clif too. Both `y.rs build` and `test.sh` accept a `--debug` argument to +build in debug mode. -### Rustc +Alternatively you can download a pre built version from [GHA]. It is listed in the artifacts section +of workflow runs. Unfortunately due to GHA restrictions you need to be logged in to access it. -> You should prefer using the Cargo method. +[GHA]: https://github.com/bjorn3/rustc_codegen_cranelift/actions?query=branch%3Amaster+event%3Apush+is%3Asuccess + +## Usage + +rustc_codegen_cranelift can be used as a near-drop-in replacement for `cargo build` or `cargo run` for existing projects. + +Assuming `$cg_clif_dir` is the directory you cloned this repo into and you followed the instructions (`y.rs prepare` and `y.rs build` or `test.sh`). + +In the directory with your project (where you can do the usual `cargo build`), run: ```bash -$ rustc +$(cat $cg_clif_dir/rust-toolchain) -Cpanic=abort -Zcodegen-backend=$cg_clif_dir/target/release/librustc_codegen_cranelift.so --sysroot $cg_clif_dir/build_sysroot/sysroot my_crate.rs +$ $cg_clif_dir/build/cargo build ``` -## Env vars - -