]> git.lizzy.rs Git - rust.git/blob - Readme.md
320ea0fa67f65d09df75e1867295418b9846bebb
[rust.git] / Readme.md
1 # Work in progress cranelift codegen backend for rust
2
3 > ⚠⚠⚠ This doesn't do anything useful yet ⚠⚠⚠
4
5 ## Building
6
7 ```bash
8 $ git clone https://github.com/bjorn3/rustc_codegen_cranelift.git
9 $ cd rustc_codegen_cranelift
10 $ rustup override set nightly
11 $ git submodule update --init
12 $ cargo build
13 ```
14
15 ## Usage
16
17 ```bash
18 $ rustc -Zcodegen-backend=$(pwd)/target/debug/librustc_codegen_cranelift.so my_crate.rs --crate-type lib -Og
19 ```
20
21 > You must compile with `-Og`, because checked binops are not yet supported.
22
23 ## Building libcore
24
25 ```bash
26 $ rustup component add rust-src
27 $ ./prepare_libcore.sh
28 $ ./build.sh
29 ```
30
31 > ⚠⚠⚠ You will get a panic because of unimplemented stuff ⚠⚠⚠
32
33 ## Not yet supported
34
35 * Checked binops
36 * Statics
37 * Drop glue
38
39 * Building libraries
40 * Other call abi's
41 * Unsized types
42 * Slice indexing
43 * Sub slice
44 * Closures
45 * Some rvalue's
46
47 * Inline assembly
48 * Custom sections
49
50 ## Known errors
51
52 * cranelift-module api seems to be used wrong, thus causing panic for some consts
53 * cranelift-codegen doesn't have encodings for some instructions for types smaller than I32
54
55 ```
56 [...]
57 warning: DefId(0/0:128 ~ lib[8787]::f64[0]::{{impl}}[0]::classify[0]):
58 fn f64::<impl at ./target/libcore/src/libcore/num/f64.rs:156:1: 490:2>::classify(_1: f64) -> num::FpCategory{
59 [...]
60 }
61 warning: stmt _3 = _1
62 warning: stmt _5 = BitAnd(move _6, const Unevaluated(DefId(0/0:130 ~ lib[8787]::f64[0]::{{impl}}[0]::classify[0]::MAN_MASK[0]), []):u64)
63 thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:345:21
64 stack backtrace:
65 [...]
66   10: <core::option::Option<T>>::unwrap
67              at /checkout/src/libcore/macros.rs:20
68   11: rustc_codegen_cranelift::constant::trans_constant
69              at src/constant.rs:26
70 [...]
71 ```