diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-10-15 07:32:36 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-15 07:32:36 +0900 |
| commit | 0cf86c2e8a5d5ac653ded607611b424bbd3f571e (patch) | |
| tree | 704ec7ead978fc7dce69f59256a1d6a692c715dc /src | |
| parent | b3f95124900a2d94e7f1eb5f8302d9c9d0858be2 (diff) | |
| parent | 6ae5f36d0d4527224295fbcd26ddbd70072cd6b8 (diff) | |
| download | rust-0cf86c2e8a5d5ac653ded607611b424bbd3f571e.tar.gz rust-0cf86c2e8a5d5ac653ded607611b424bbd3f571e.zip | |
Rollup merge of #77934 - XAMPPRocky:codegen-backend-docs, r=jonas-schievink
Document -Z codegen-backend in the unstable book ### [Rendered](https://github.com/XAMPPRocky/rust/blob/codegen-backend-docs/src/doc/unstable-book/src/compiler-flags/codegen-backend.md) Companion PR to #77933 tracking issue. cc @bjorn3
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/unstable-book/src/compiler-flags/codegen-backend.md | 31 |
1 files changed, 31 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..878c894a6ca --- /dev/null +++ b/src/doc/unstable-book/src/compiler-flags/codegen-backend.md @@ -0,0 +1,31 @@ +# `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 be of crate type `dylib` and must contain a function +named `__rustc_codegen_backend` with a signature of `fn() -> Box<dyn rustc_codegen_ssa::traits::CodegenBackend>`. + +## Example +See also the [`hotplug_codegen_backend`](https://github.com/rust-lang/rust/tree/master/src/test/run-make-fulldeps/hotplug_codegen_backend) test +for a full example. + +```rust,ignore +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) +} +``` |
