From b8bbbe38d1b2dadae1b66efb49a36c713d5b6dfe Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 16 Sep 2020 16:57:52 +0200 Subject: [PATCH] Remove cfg-if dependency --- Cargo.lock | 1 - Cargo.toml | 1 - src/debuginfo/unwind.rs | 45 +++++++++++++++++++++-------------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c669c87a73..d522fc8da24 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -317,7 +317,6 @@ name = "rustc_codegen_cranelift" version = "0.1.0" dependencies = [ "ar", - "cfg-if", "cranelift-codegen", "cranelift-frontend", "cranelift-module", diff --git a/Cargo.toml b/Cargo.toml index 5962356beea..6250dc8573b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ object = { version = "0.21.1", default-features = false, features = ["read", "st ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } indexmap = "1.0.2" -cfg-if = "0.1.10" libloading = { version = "0.6.0", optional = true } # Uncomment to use local checkout of cranelift diff --git a/src/debuginfo/unwind.rs b/src/debuginfo/unwind.rs index 5fc68990b2a..4c23f75be69 100644 --- a/src/debuginfo/unwind.rs +++ b/src/debuginfo/unwind.rs @@ -94,33 +94,34 @@ impl<'tcx> UnwindContext<'tcx> { // ======================================================================= // Everything after this line up to the end of the file is loosly based on // https://github.com/bytecodealliance/wasmtime/blob/4471a82b0c540ff48960eca6757ccce5b1b5c3e4/crates/jit/src/unwind/systemv.rs - cfg_if::cfg_if! { - if #[cfg(target_os = "macos")] { - // On macOS, `__register_frame` takes a pointer to a single FDE - let start = eh_frame.as_ptr(); - let end = start.add(eh_frame.len()); - let mut current = start; + #[cfg(target_os = "macos")] + { + // On macOS, `__register_frame` takes a pointer to a single FDE + let start = eh_frame.as_ptr(); + let end = start.add(eh_frame.len()); + let mut current = start; - // Walk all of the entries in the frame table and register them - while current < end { - let len = std::ptr::read::(current as *const u32) as usize; + // Walk all of the entries in the frame table and register them + while current < end { + let len = std::ptr::read::(current as *const u32) as usize; - // Skip over the CIE - if current != start { - __register_frame(current); - registrations.push(current as usize); - } - - // Move to the next table entry (+4 because the length itself is not inclusive) - current = current.add(len + 4); + // Skip over the CIE + if current != start { + __register_frame(current); + registrations.push(current as usize); } - } else { - // On other platforms, `__register_frame` will walk the FDEs until an entry of length 0 - let ptr = eh_frame.as_ptr(); - __register_frame(ptr); - registrations.push(ptr as usize); + + // Move to the next table entry (+4 because the length itself is not inclusive) + current = current.add(len + 4); } } + #[cfg(not(target_os = "macos"))] + { + // On other platforms, `__register_frame` will walk the FDEs until an entry of length 0 + let ptr = eh_frame.as_ptr(); + __register_frame(ptr); + registrations.push(ptr as usize); + } Some(UnwindRegistry { _frame_table: eh_frame,