Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document -Z codegen-backend in the unstable book
- Loading branch information
1 parent
5565241
commit c50a04b
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/doc/unstable-book/src/compiler-flags/codegen-backend.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# `codegen-backend` | ||
|
||
The tracking issue for this feature is: [#77933](https://github.com/rust-lang/rust/issues/77933). | ||
|
||
------------------------ | ||
|
||
This feature allows you to specify a path to a dynamic library to use as rustc's | ||
code generation backend at runtime. | ||
|
||
Set the `-Zcodegen-backend=<path>` compiler flag to specify the location of the | ||
backend. The library must contain a function named `__rustc_codegen_backend` | ||
with a signature of `fn() -> Box<dyn rustc_codegen_ssa::traits::CodegenBackend>`. | ||
|
||
## Example | ||
```rust | ||
use rustc_codegen_ssa::traits::CodegenBackend; | ||
|
||
struct MyBackend; | ||
|
||
impl CodegenBackend for MyBackend { | ||
// Implement codegen methods | ||
} | ||
|
||
#[no_mangle] | ||
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> { | ||
Box::new(MyBackend) | ||
} | ||
``` |