Skip to content

fix: no_std fix use without unwind #9977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cranelift/codegen/src/isa/pulley_shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ where
})
}

#[cfg(feature = "unwind")]
fn emit_unwind_info(
&self,
_result: &crate::CompiledCode,
Expand Down
1 change: 1 addition & 0 deletions cranelift/codegen/src/isa/unwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod winx64;
pub mod winarm64;

/// CFA-based unwind information used on SystemV.
#[cfg(feature = "unwind")]
pub type CfaUnwindInfo = systemv::UnwindInfo;

/// Expected unwind info type.
Expand Down
2 changes: 2 additions & 0 deletions cranelift/codegen/src/isa/x64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mod lower;
mod pcc;
pub mod settings;

#[cfg(feature = "unwind")]
pub use inst::unwind::systemv::create_cie;

/// An X64 backend.
Expand Down Expand Up @@ -184,6 +185,7 @@ impl TargetIsa for X64Backend {
}

/// Emit unwind info for an x86 target.
#[cfg(feature = "unwind")]
pub fn emit_unwind_info(
buffer: &MachBufferFinalized<Final>,
kind: crate::isa::unwind::UnwindInfoKind,
Expand Down
5 changes: 5 additions & 0 deletions cranelift/codegen/src/machinst/vcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,8 +1158,13 @@ impl<I: VCodeInst> VCode<I> {
let slot = alloc.as_stack().unwrap();
let slot_offset = self.abi.get_spillslot_offset(slot);
let slot_base_to_caller_sp_offset = self.abi.slot_base_to_caller_sp_offset();

#[cfg(feature = "unwind")]
let caller_sp_to_cfa_offset =
crate::isa::unwind::systemv::caller_sp_to_cfa_offset();
#[cfg(not(feature = "unwind"))]
let caller_sp_to_cfa_offset = 0; // TODO is this right?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe compute_value_labels_ranges should be made to return ValueLabelsRanges::default(); when the unwind feature is disabled? Except for values which just so happen to be in registers, I don't think it is possible to generate valid debuginfo for locals when the unwind table is not also emitted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arguably, the register values are just as 'meaningless' in the no-unwind case as you need the unwind info to recover them (unless you are willing to disassemble code to guide your unwinder). Ultimately, the debug info production 'feature' is tightly coupled to the unwinding feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked compute_value_labels_ranges as available with the unwind feature too and made the Default changes at its only callsite, I think that's clearer than having the function exist but return a meaningless default value.


// NOTE: this is a negative offset because it's relative to the caller's SP
let cfa_to_sp_offset =
-((slot_base_to_caller_sp_offset + caller_sp_to_cfa_offset) as i64);
Expand Down
Loading