]> git.lizzy.rs Git - rust.git/blob - Readme.md
Rustup to rustc 1.45.0-nightly (7ced01a73 2020-04-30)
[rust.git] / Readme.md
1 # WIP Cranelift codegen backend for rust
2
3 > ⚠⚠⚠ Certain kinds of FFI don't work yet. ⚠⚠⚠
4
5 ## Building
6
7 ```bash
8 $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git
9 $ cd rustc_codegen_cranelift
10 $ ./prepare.sh # download and patch sysroot src and install hyperfine for benchmarking
11 $ ./test.sh --release
12 ```
13
14 ## Usage
15
16 `$cg_clif_dir` is the directory you cloned this repo into in the following instruction.
17
18 ### Cargo
19
20 ```bash
21 $ CHANNEL="release" $cg_clif_dir/cargo.sh run
22 ```
23
24 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.
25
26 ### Rustc
27
28 > You should prefer using the Cargo method.
29
30 ```bash
31 $ 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
32 ```
33
34 ## Env vars
35
36 <dl>
37     <dt>CG_CLIF_JIT</dt>
38     <dd>Enable JIT mode to immediately run a program instead of writing an executable file.</dd>
39     <dt>CG_CLIF_JIT_ARGS</dt>
40     <dd>When JIT mode is enable pass these arguments to the program.</dd>
41     <dt>CG_CLIF_INCR_CACHE_DISABLED</dt>
42     <dd>Don't cache object files in the incremental cache. Useful during development of cg_clif
43     to make it possible to use incremental mode for all analyses performed by rustc without caching
44     object files when their content should have been changed by a change to cg_clif.</dd>
45     <dt>CG_CLIF_DISPLAY_CG_TIME</dt>
46     <dd>Display the time it took to perform codegen for a crate</dd>
47 </dl>
48
49 ## Not yet supported
50
51 * Good non-rust abi support ([several problems](https://github.com/bjorn3/rustc_codegen_cranelift/issues/10))
52 * Checked binops ([some missing instructions in cranelift](https://github.com/bytecodealliance/wasmtime/issues/1044))
53 * Inline assembly ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1041), not coming soon)
54 * SIMD ([tracked here](https://github.com/bjorn3/rustc_codegen_cranelift/issues/171), some basic things work)