Skip to main content

ObjectBuilder

Struct ObjectBuilder 

Source
pub struct ObjectBuilder { /* private fields */ }
Expand description

A builder for ObjectModule.

Implementations§

Source§

impl ObjectBuilder

Source

pub fn new<V: Into<Vec<u8>>>( isa: OwnedTargetIsa, name: V, libcall_names: Box<dyn Fn(LibCall) -> String + Send + Sync>, ) -> ModuleResult<Self>

Create a new ObjectBuilder using the given Cranelift target, that can be passed to ObjectModule::new.

The libcall_names function provides a way to translate cranelift_codegen’s ir::LibCall enum to symbols. LibCalls are inserted in the IR as part of the legalization for certain floating point instructions, and for stack probes. If you don’t know what to use for this argument, use cranelift_module::default_libcall_names.

Source

pub fn per_function_section(&mut self, per_function_section: bool) -> &mut Self

Set if every function should end up in their own section.

Source

pub fn per_data_object_section( &mut self, per_data_object_section: bool, ) -> &mut Self

Set if every data object should end up in their own section.

Source

pub fn unwind_info(&mut self, unwind_info: bool) -> &mut Self

Emit a DWARF .eh_frame section describing the unwind information for each compiled function.

When enabled, ELF and COFF object files gain a .eh_frame section containing one Common Information Entry and one Frame Description Entry per function, suitable for unwinding by libgcc / libunwind.

On Windows targets cranelift emits .pdata/.xdata-style info rather than System V FDEs, so enabling this option is a silent no-op there. Mach-O __TEXT,__eh_frame emission is not yet implemented; calling finish on a Mach-O target with this enabled will panic with a descriptive error.

Only functions defined through Module::define_function are captured. Functions provided as pre-compiled bytes through Module::define_function_bytes are skipped, since their unwind information is not available to the backend.

Requires the unwind feature (enabled by default). Without it this method does not exist, mirroring cranelift-codegen’s gating of CompiledCode::create_unwind_info.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.