about summary refs log tree commit diff
diff options
context:
space:
mode:
authorErin Power <erin.power@embark-studios.com>2020-10-14 14:34:47 +0200
committerErin Power <erin.power@embark-studios.com>2020-10-14 14:34:47 +0200
commitc50a04bba3a9d08323b69789f8d567376a82189d (patch)
tree18d5e6f4b06923b1702468519bf9301b8b0b2088
parent5565241f65cf402c3dbcb55dd492f172c473d4ce (diff)
downloadrust-c50a04bba3a9d08323b69789f8d567376a82189d.tar.gz
rust-c50a04bba3a9d08323b69789f8d567376a82189d.zip
Document -Z codegen-backend in the unstable book
-rw-r--r--src/doc/unstable-book/src/compiler-flags/codegen-backend.md28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/codegen-backend.md b/src/doc/unstable-book/src/compiler-flags/codegen-backend.md
new file mode 100644
index 00000000000..28f173cb0f3
--- /dev/null
+++ b/src/doc/unstable-book/src/compiler-flags/codegen-backend.md
@@ -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)
+}
+```