Skip to content

Commit c50a04b

Browse files
committed
Document -Z codegen-backend in the unstable book
1 parent 5565241 commit c50a04b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# `codegen-backend`
2+
3+
The tracking issue for this feature is: [#77933](https://github.com/rust-lang/rust/issues/77933).
4+
5+
------------------------
6+
7+
This feature allows you to specify a path to a dynamic library to use as rustc's
8+
code generation backend at runtime.
9+
10+
Set the `-Zcodegen-backend=<path>` compiler flag to specify the location of the
11+
backend. The library must contain a function named `__rustc_codegen_backend`
12+
with a signature of `fn() -> Box<dyn rustc_codegen_ssa::traits::CodegenBackend>`.
13+
14+
## Example
15+
```rust
16+
use rustc_codegen_ssa::traits::CodegenBackend;
17+
18+
struct MyBackend;
19+
20+
impl CodegenBackend for MyBackend {
21+
// Implement codegen methods
22+
}
23+
24+
#[no_mangle]
25+
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
26+
Box::new(MyBackend)
27+
}
28+
```

0 commit comments

Comments
 (0)