rustc_codegen_ssa::traits::statics

Trait StaticCodegenMethods

source
pub trait StaticCodegenMethods: BackendTypes {
    // Required methods
    fn static_addr_of(
        &self,
        cv: Self::Value,
        align: Align,
        kind: Option<&str>,
    ) -> Self::Value;
    fn codegen_static(&self, def_id: DefId);
    fn add_used_global(&self, global: Self::Value);
    fn add_compiler_used_global(&self, global: Self::Value);
}

Required Methods§

source

fn static_addr_of( &self, cv: Self::Value, align: Align, kind: Option<&str>, ) -> Self::Value

source

fn codegen_static(&self, def_id: DefId)

source

fn add_used_global(&self, global: Self::Value)

Mark the given global value as “used”, to prevent the compiler and linker from potentially removing a static variable that may otherwise appear unused.

source

fn add_compiler_used_global(&self, global: Self::Value)

Same as add_used_global(), but only prevent the compiler from potentially removing an otherwise unused symbol. The linker is still permitted to drop it.

This corresponds to the documented semantics of the #[used] attribute, although on some targets (non-ELF), we may use add_used_global for #[used] statics instead.

Implementors§