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