diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 7091d880dc..ffc96c1abb 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -1616,7 +1616,7 @@ impl MachTextSectionBuilder { } impl TextSectionBuilder for MachTextSectionBuilder { - fn append(&mut self, named: bool, func: &[u8], align: u32) -> u64 { + fn append(&mut self, named: bool, func: &[u8], align: Option) -> u64 { // Conditionally emit an island if it's necessary to resolve jumps // between functions which are too far away. let size = func.len() as u32; @@ -1624,7 +1624,7 @@ impl TextSectionBuilder for MachTextSectionBuilder { self.buf.emit_island_maybe_forced(self.force_veneers, size); } - self.buf.align_to(align); + self.buf.align_to(align.unwrap_or(I::LabelUse::ALIGN)); let pos = self.buf.cur_offset(); if named { self.buf.bind_label(MachLabel::from_block(self.next_func)); diff --git a/cranelift/codegen/src/machinst/mod.rs b/cranelift/codegen/src/machinst/mod.rs index e16dcce9a0..c2cdb4e32c 100644 --- a/cranelift/codegen/src/machinst/mod.rs +++ b/cranelift/codegen/src/machinst/mod.rs @@ -370,7 +370,7 @@ pub trait TextSectionBuilder { /// /// This function returns the offset at which the data was placed in the /// text section. - fn append(&mut self, labeled: bool, data: &[u8], align: u32) -> u64; + fn append(&mut self, labeled: bool, data: &[u8], align: Option) -> u64; /// Attempts to resolve a relocation for this function. /// diff --git a/crates/cranelift/src/compiler.rs b/crates/cranelift/src/compiler.rs index 7463c2fa45..a67790bb33 100644 --- a/crates/cranelift/src/compiler.rs +++ b/crates/cranelift/src/compiler.rs @@ -264,9 +264,11 @@ impl wasmtime_environ::Compiler for Compiler { traps.push(range.clone(), &func.traps); func_starts.push(range.start); if self.linkopts.padding_between_functions > 0 { - builder - .text - .append(false, &vec![0; self.linkopts.padding_between_functions], 1); + builder.text.append( + false, + &vec![0; self.linkopts.padding_between_functions], + Some(1), + ); } } diff --git a/crates/cranelift/src/obj.rs b/crates/cranelift/src/obj.rs index 63ae67c38e..05bde6d7f7 100644 --- a/crates/cranelift/src/obj.rs +++ b/crates/cranelift/src/obj.rs @@ -184,12 +184,12 @@ impl<'a> ObjectBuilder<'a> { /// that the function resides within the text section. fn append_func( &mut self, - wat: bool, + labeled: bool, name: Vec, func: &'a CompiledFunction, ) -> (SymbolId, Range) { let body_len = func.body.len() as u64; - let off = self.text.append(wat, &func.body, 1); + let off = self.text.append(labeled, &func.body, None); let symbol_id = self.obj.add_symbol(Symbol { name, @@ -215,7 +215,7 @@ impl<'a> ObjectBuilder<'a> { let unwind_size = info.emit_size(); let mut unwind_info = vec![0; unwind_size]; info.emit(&mut unwind_info); - let unwind_off = self.text.append(false, &unwind_info, 4); + let unwind_off = self.text.append(false, &unwind_info, Some(4)); self.windows_unwind_info.push(RUNTIME_FUNCTION { begin: u32::try_from(off).unwrap(), end: u32::try_from(off + body_len).unwrap(),