|
1 | 1 | # `compiler-builtins`
|
2 | 2 |
|
3 |
| -> Porting `compiler-rt` intrinsics to Rust |
| 3 | +This crate provides external symbols that the compiler expects to be available when |
| 4 | +building Rust projects, typically software routines for basic operations that do not |
| 5 | +have hardware support. It is largely a port of LLVM's [`compiler-rt`]. |
4 | 6 |
|
5 |
| -See [rust-lang/rust#35437][0]. |
| 7 | +It is distributed as part of Rust's sysroot. |
6 | 8 |
|
7 |
| -[0]: https://github.com/rust-lang/rust/issues/35437 |
8 |
| - |
9 |
| -## When and how to use this crate? |
10 |
| - |
11 |
| -If you are working with a target that doesn't have binary releases of std |
12 |
| -available via rustup (this probably means you are building the core crate |
13 |
| -yourself) and need compiler-rt intrinsics (i.e. you are probably getting linker |
14 |
| -errors when building an executable: `undefined reference to __aeabi_memcpy`), |
15 |
| -you can use this crate to get those intrinsics and solve the linker errors. To |
16 |
| -do that, add this crate somewhere in the dependency graph of the crate you are |
17 |
| -building: |
18 |
| - |
19 |
| -```toml |
20 |
| -# Cargo.toml |
21 |
| -[dependencies] |
22 |
| -compiler_builtins = { git = "https://github.com/rust-lang/compiler-builtins" } |
23 |
| -``` |
24 |
| - |
25 |
| -```rust |
26 |
| -extern crate compiler_builtins; |
27 |
| - |
28 |
| -// ... |
29 |
| -``` |
30 |
| - |
31 |
| -If you still get an "undefined reference to $INTRINSIC" error after that change, |
32 |
| -that means that we haven't ported `$INTRINSIC` to Rust yet! Please open [an |
33 |
| -issue] with the name of the intrinsic and the LLVM triple (e.g. |
34 |
| -thumbv7m-none-eabi) of the target you are using. That way we can prioritize |
35 |
| -porting that particular intrinsic. |
36 |
| - |
37 |
| -If you've got a C compiler available for your target then while we implement |
38 |
| -this intrinsic you can temporarily enable a fallback to the actual compiler-rt |
39 |
| -implementation as well for unimplemented intrinsics: |
40 |
| - |
41 |
| -```toml |
42 |
| -[dependencies.compiler_builtins] |
43 |
| -git = "https://github.com/rust-lang/compiler-builtins" |
44 |
| -features = ["c"] |
45 |
| -``` |
46 |
| - |
47 |
| -[an issue]: https://github.com/rust-lang/compiler-builtins/issues |
| 9 | +[`compiler-rt`]: https://github.com/llvm/llvm-project/tree/1b1dc505057322f4fa1110ef4f53c44347f52986/compiler-rt |
48 | 10 |
|
49 | 11 | ## Contributing
|
50 | 12 |
|
|
0 commit comments