CodegenBackend in rustc_codegen_ssa::traits::backend - Rust
Description: API documentation for the Rust `CodegenBackend` trait in crate `rustc_codegen_ssa`.

Skip to main content

## CodegenBackend

# Trait CodegenBackend

Source

    pub trait CodegenBackend {
    Show 21 methods    // Required methods
        fn name(&self) -> &'static str;
        fn target_cpu(&self, sess: &Session) -> String;
        fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>) -> Box<dyn Any>;
        fn join_codegen(
            &self,
            ongoing_codegen: Box<dyn Any>,
            sess: &Session,
            outputs: &OutputFilenames,
            crate_info: &CrateInfo,
        ) -> (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 fallback_intrinsics(&self) -> Vec<Symbol> { ... }
        fn thin_lto_supported(&self) -> bool { ... }
        fn has_zstd(&self) -> bool { ... }
        fn has_mnemonic(&self, _sess: &Session, _mnemonic: &str) -> bool { ... }
        fn metadata_loader(&self) -> Box<MetadataLoaderDyn> { ... }
        fn provide(&self, _providers: &mut Providers) { ... }
        fn print_pass_timings(&self) { ... }
        fn print_statistics(&self) { ... }
        fn print_statistics_json(&self) -> String { ... }
        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>) -> Box<dyn Any>

Source

#### fn join_codegen( &self, ongoing_codegen: Box<dyn Any>, sess: &Session, outputs: &OutputFilenames, crate_info: &CrateInfo, ) -> (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 fallback_intrinsics(&self) -> Vec<Symbol>

Returns a list of all intrinsics that this backend definitely does not replace, which means their fallback bodies can be MIR-inlined.

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 has_mnemonic(&self, _sess: &Session, _mnemonic: &str) -> bool

Value printed by `--print=backend-has-mnemonic:...`.

Used by compiletest to determine whether tests involving `asm!()` 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 print_statistics_json(&self) -> String

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

## Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

## Implementors§