2017-09-16 17:27:29 +02:00
|
|
|
//! The Rust compiler.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
|
|
|
|
2019-02-05 14:37:15 +01:00
|
|
|
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
2017-09-16 17:27:29 +02:00
|
|
|
|
2017-09-23 14:46:15 +02:00
|
|
|
use std::any::Any;
|
2019-03-01 16:53:21 +01:00
|
|
|
use std::sync::mpsc;
|
2017-09-18 17:37:57 +02:00
|
|
|
|
|
|
|
use syntax::symbol::Symbol;
|
2018-12-08 20:30:23 +01:00
|
|
|
use rustc::session::Session;
|
|
|
|
use rustc::util::common::ErrorReported;
|
2019-03-01 16:53:21 +01:00
|
|
|
use rustc::session::config::{OutputFilenames, PrintRequest};
|
2017-09-23 14:46:15 +02:00
|
|
|
use rustc::ty::TyCtxt;
|
2018-06-13 16:44:43 +03:00
|
|
|
use rustc::ty::query::Providers;
|
2019-04-26 17:22:36 +10:00
|
|
|
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
|
2017-12-19 18:01:19 +01:00
|
|
|
use rustc::dep_graph::DepGraph;
|
2017-09-16 17:27:29 +02:00
|
|
|
|
2018-03-03 06:17:06 +01:00
|
|
|
pub use rustc_data_structures::sync::MetadataRef;
|
|
|
|
|
2018-05-08 16:10:16 +03:00
|
|
|
pub trait CodegenBackend {
|
2018-01-22 07:29:24 -08:00
|
|
|
fn init(&self, _sess: &Session) {}
|
2017-10-30 18:42:21 +01:00
|
|
|
fn print(&self, _req: PrintRequest, _sess: &Session) {}
|
|
|
|
fn target_features(&self, _sess: &Session) -> Vec<Symbol> { vec![] }
|
2018-01-22 07:29:24 -08:00
|
|
|
fn print_passes(&self) {}
|
|
|
|
fn print_version(&self) {}
|
|
|
|
fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] }
|
2017-09-16 17:27:29 +02:00
|
|
|
|
2018-07-11 17:39:49 +02:00
|
|
|
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync>;
|
2019-02-08 21:06:07 +09:00
|
|
|
fn provide(&self, _providers: &mut Providers<'_>);
|
|
|
|
fn provide_extern(&self, _providers: &mut Providers<'_>);
|
2019-06-11 23:35:39 +03:00
|
|
|
fn codegen_crate<'tcx>(
|
2017-10-30 18:42:21 +01:00
|
|
|
&self,
|
2019-06-14 00:48:52 +03:00
|
|
|
tcx: TyCtxt<'tcx>,
|
2019-04-26 17:22:36 +10:00
|
|
|
metadata: EncodedMetadata,
|
|
|
|
need_metadata_module: bool,
|
2019-06-12 00:11:55 +03:00
|
|
|
rx: mpsc::Receiver<Box<dyn Any + Send>>,
|
2018-07-11 17:39:49 +02:00
|
|
|
) -> Box<dyn Any>;
|
2017-10-30 18:42:21 +01:00
|
|
|
|
2018-07-11 17:39:49 +02:00
|
|
|
/// This is called on the returned `Box<dyn Any>` from `codegen_backend`
|
2017-10-30 18:42:21 +01:00
|
|
|
///
|
|
|
|
/// # Panics
|
|
|
|
///
|
2018-07-11 17:39:49 +02:00
|
|
|
/// Panics when the passed `Box<dyn Any>` was not returned by `codegen_backend`.
|
2018-05-08 16:10:16 +03:00
|
|
|
fn join_codegen_and_link(
|
2017-10-30 18:42:21 +01:00
|
|
|
&self,
|
2018-07-11 17:39:49 +02:00
|
|
|
ongoing_codegen: Box<dyn Any>,
|
2017-09-16 17:27:29 +02:00
|
|
|
sess: &Session,
|
2017-10-30 18:42:21 +01:00
|
|
|
dep_graph: &DepGraph,
|
|
|
|
outputs: &OutputFilenames,
|
2018-12-08 20:30:23 +01:00
|
|
|
) -> Result<(), ErrorReported>;
|
2017-09-16 17:27:29 +02:00
|
|
|
}
|