## CodegenBackend

# Trait CodegenBackend

Source

    pub trait CodegenBackend {
        // Required methods
        fn locale_resource(&self) -> &'static str;
        fn name(&self) -> &'static str;
        fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>) -> 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_config(&self, _sess: &Session) -> TargetConfig { ... }
        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,
            metadata: EncodedMetadata,
            outputs: &OutputFilenames,
        ) { ... }
    }

## Required Methods§

Source

#### 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.

Source

#### fn name(&self) -> &'static str

Source

#### fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Box<dyn Any>

Source

#### 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§

Source

#### fn init(&self, _sess: &Session)

Source

#### fn print(&self, _req: &PrintRequest, _out: &mut String, _sess: &Session)

Source

#### fn target_config(&self, _sess: &Session) -> TargetConfig

Collect target-specific options that should be set in `cfg(...)`, including `target_feature` and support for unstable float types.

Source

#### fn print_passes(&self)

Source

#### fn print_version(&self)

Source

#### 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.

Source

#### fn provide(&self, _providers: &mut Providers)

Source

#### fn link( &self, sess: &Session, codegen_results: CodegenResults, metadata: EncodedMetadata, outputs: &OutputFilenames, )

This is called on the returned `CodegenResults` from `join_codegen`.

## Implementors§