Skip to main content

## CodegenBackend

# Trait CodegenBackend

Source

    pub trait CodegenBackend {
    Show 18 methods    // Required methods
        fn name(&self) -> &'static str;
        fn target_cpu(&self, sess: &Session) -> String;
        fn codegen_crate<'tcx>(
            &self,
            tcx: TyCtxt<'tcx>,
            crate_info: &CrateInfo,
        ) -> Box<dyn Any>;
        fn join_codegen(
            &self,
            ongoing_codegen: Box<dyn Any>,
            sess: &Session,
            outputs: &OutputFilenames,
        ) -> (CompiledModules, 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 supported_crate_types(&self, _sess: &Session) -> Vec<CrateType> { ... }
        fn print_passes(&self) { ... }
        fn print_version(&self) { ... }
        fn replaced_intrinsics(&self) -> Vec<Symbol> { ... }
        fn thin_lto_supported(&self) -> bool { ... }
        fn has_zstd(&self) -> bool { ... }
        fn metadata_loader(&self) -> Box<MetadataLoaderDyn> { ... }
        fn provide(&self, _providers: &mut Providers) { ... }
        fn print_pass_timings(&self) { ... }
        fn print_statistics(&self) { ... }
        fn link(
            &self,
            sess: &Session,
            compiled_modules: CompiledModules,
            crate_info: CrateInfo,
            metadata: EncodedMetadata,
            outputs: &OutputFilenames,
        ) { ... }
    }

## Required Methods§

Source

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

Source

#### fn target_cpu(&self, sess: &Session) -> String

Source

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

Source

#### fn join_codegen( &self, ongoing_codegen: Box<dyn Any>, sess: &Session, outputs: &OutputFilenames, ) -> (CompiledModules, 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 supported_crate_types(&self, _sess: &Session) -> Vec<CrateType>

Source

#### fn print_passes(&self)

Source

#### fn print_version(&self)

Source

#### fn replaced_intrinsics(&self) -> Vec<Symbol>

Returns a list of all intrinsics that this backend definitely replaces, which means their fallback bodies do not need to be monomorphized.

Source

#### fn thin_lto_supported(&self) -> bool

Is ThinLTO supported by this backend?

Source

#### fn has_zstd(&self) -> bool

Value printed by `--print=backend-has-zstd`.

Used by compiletest to determine whether tests involving zstd compression (e.g. `-Zdebuginfo-compression=zstd`) should be executed or skipped.

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 print_pass_timings(&self)

Source

#### fn print_statistics(&self)

Source

#### fn link( &self, sess: &Session, compiled_modules: CompiledModules, crate_info: CrateInfo, metadata: EncodedMetadata, outputs: &OutputFilenames, )

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

## Implementors§