pub struct ObjectBuilder { /* private fields */ }Expand description
A builder for ObjectModule.
Implementations§
Source§impl ObjectBuilder
impl ObjectBuilder
Sourcepub fn new<V: Into<Vec<u8>>>(
isa: OwnedTargetIsa,
name: V,
libcall_names: Box<dyn Fn(LibCall) -> String + Send + Sync>,
) -> ModuleResult<Self>
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.
Sourcepub fn per_function_section(&mut self, per_function_section: bool) -> &mut Self
pub fn per_function_section(&mut self, per_function_section: bool) -> &mut Self
Set if every function should end up in their own section.
Sourcepub fn per_data_object_section(
&mut self,
per_data_object_section: bool,
) -> &mut Self
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.
Sourcepub fn unwind_info(&mut self, unwind_info: bool) -> &mut Self
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.