pub trait CodegenBackend {
// Required methods
fn locale_resource(&self) -> &'static str;
fn codegen_crate<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
metadata: EncodedMetadata,
need_metadata_module: bool,
) -> Box<dyn Any>;
fn join_codegen(
&self,
ongoing_codegen: Box<dyn Any>,
sess: &Session,
outputs: &OutputFilenames,
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>);
// Provided methods
fn init(&self, _sess: &Session) { ... }
fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session) { ... }
fn target_features_cfg(
&self,
_sess: &Session,
_allow_unstable: bool,
) -> Vec<Symbol> { ... }
fn print_passes(&self) { ... }
fn print_version(&self) { ... }
fn metadata_loader(&self) -> Box<MetadataLoaderDyn> { ... }
fn provide(&self, _providers: &mut Providers) { ... }
fn link(
&self,
sess: &Session,
codegen_results: CodegenResults,
outputs: &OutputFilenames,
) { ... }
fn supports_parallel(&self) -> bool { ... }
}
Required Methods§
Sourcefn locale_resource(&self) -> &'static str
fn locale_resource(&self) -> &'static str
Locale resources for diagnostic messages - a string the content of the Fluent resource.
Called before init
so that all other functions are able to emit translatable diagnostics.
fn codegen_crate<'tcx>( &self, tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need_metadata_module: bool, ) -> Box<dyn Any>
Sourcefn join_codegen(
&self,
ongoing_codegen: Box<dyn Any>,
sess: &Session,
outputs: &OutputFilenames,
) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>)
fn join_codegen( &self, ongoing_codegen: Box<dyn Any>, sess: &Session, outputs: &OutputFilenames, ) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>)
This is called on the returned Box<dyn Any>
from codegen_crate
§Panics
Panics when the passed Box<dyn Any>
was not returned by codegen_crate
.
Provided Methods§
fn init(&self, _sess: &Session)
fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session)
Sourcefn target_features_cfg(
&self,
_sess: &Session,
_allow_unstable: bool,
) -> Vec<Symbol>
fn target_features_cfg( &self, _sess: &Session, _allow_unstable: bool, ) -> Vec<Symbol>
Returns the features that should be set in cfg(target_features)
.
RUSTC_SPECIFIC_FEATURES should be skipped here, those are handled outside codegen.
fn print_passes(&self)
fn print_version(&self)
Sourcefn metadata_loader(&self) -> Box<MetadataLoaderDyn>
fn metadata_loader(&self) -> Box<MetadataLoaderDyn>
The metadata loader used to load rlib and dylib metadata.
Alternative codegen backends may want to use different rlib or dylib formats than the default native static archives and dynamic libraries.
fn provide(&self, _providers: &mut Providers)
Sourcefn link(
&self,
sess: &Session,
codegen_results: CodegenResults,
outputs: &OutputFilenames,
)
fn link( &self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames, )
This is called on the returned CodegenResults
from join_codegen
.
Sourcefn supports_parallel(&self) -> bool
fn supports_parallel(&self) -> bool
Returns true
if this backend can be safely called from multiple threads.
Defaults to true
.