rust/src/librustc_codegen_utils/codegen_backend.rs

55 lines
1.7 KiB
Rust
Raw Normal View History

2017-09-16 17:27:29 +02:00
//! The Rust compiler.
//!
//! # Note
//!
//! This API is completely unstable and subject to change.
#![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;
use syntax::symbol::Symbol;
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;
use rustc::middle::cstore::{EncodedMetadata, MetadataLoader};
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 {
fn init(&self, _sess: &Session) {}
fn print(&self, _req: PrintRequest, _sess: &Session) {}
fn target_features(&self, _sess: &Session) -> Vec<Symbol> { vec![] }
fn print_passes(&self) {}
fn print_version(&self) {}
fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] }
2017-09-16 17:27:29 +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<'_>);
fn codegen_crate<'tcx>(
&self,
2019-06-14 00:48:52 +03:00
tcx: TyCtxt<'tcx>,
metadata: EncodedMetadata,
need_metadata_module: bool,
rx: mpsc::Receiver<Box<dyn Any + Send>>,
) -> Box<dyn Any>;
/// This is called on the returned `Box<dyn Any>` from `codegen_backend`
///
/// # Panics
///
/// 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(
&self,
ongoing_codegen: Box<dyn Any>,
2017-09-16 17:27:29 +02:00
sess: &Session,
dep_graph: &DepGraph,
outputs: &OutputFilenames,
) -> Result<(), ErrorReported>;
2017-09-16 17:27:29 +02:00
}