5 //! This API is completely unstable and subject to change.
7 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
9 #![feature(box_syntax)]
14 use syntax::symbol::Symbol;
15 use rustc::session::Session;
16 use rustc::util::common::ErrorReported;
17 use rustc::session::config::{OutputFilenames, PrintRequest};
18 use rustc::ty::TyCtxt;
19 use rustc::ty::query::Providers;
20 use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
21 use rustc::dep_graph::DepGraph;
23 pub use rustc_data_structures::sync::MetadataRef;
25 pub trait CodegenBackend {
26 fn init(&self, _sess: &Session) {}
27 fn print(&self, _req: PrintRequest, _sess: &Session) {}
28 fn target_features(&self, _sess: &Session) -> Vec<Symbol> { vec![] }
29 fn print_passes(&self) {}
30 fn print_version(&self) {}
31 fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] }
33 fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync>;
34 fn provide(&self, _providers: &mut Providers<'_>);
35 fn provide_extern(&self, _providers: &mut Providers<'_>);
36 fn codegen_crate<'tcx>(
39 metadata: EncodedMetadata,
40 need_metadata_module: bool,
41 rx: mpsc::Receiver<Box<dyn Any + Send>>,
44 /// This is called on the returned `Box<dyn Any>` from `codegen_backend`
48 /// Panics when the passed `Box<dyn Any>` was not returned by `codegen_backend`.
49 fn join_codegen_and_link(
51 ongoing_codegen: Box<dyn Any>,
54 outputs: &OutputFilenames,
55 ) -> Result<(), ErrorReported>;