Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document -Z codegen-backend in the unstable book #77934

Merged
merged 4 commits into from
Oct 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/doc/unstable-book/src/compiler-flags/codegen-backend.md
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>`.
XAMPPRocky marked this conversation as resolved.
Show resolved Hide resolved

## Example
```rust
XAMPPRocky marked this conversation as resolved.
Show resolved Hide resolved
XAMPPRocky marked this conversation as resolved.
Show resolved Hide resolved
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)
}
```