Skip to content

Commit

Permalink
fix aarch64 build
Browse files Browse the repository at this point in the history
  • Loading branch information
realFlowControl committed Feb 17, 2025
1 parent ab95361 commit 2b05c45
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
16 changes: 5 additions & 11 deletions crashtracker/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,18 @@ fn main() {
"x86_64-unknown-linux-gnu"| "x86_64-unknown-linux-musl" => "x86_64",
"i686-unknown-linux-gnu"|"i586-unknown-linux-gnu" => "x86",
"arm-unknown-linux-gnueabihf" => "arm",
"aarch64-unknown-linux-gnu" => "aarch64",
_ => ""
};
if link_lib_arch.is_empty() {
println!("cargo:warning=target {} is unsupported",target);
return;
}

println!("cargo:rustc-link-search=native=/usr/local/lib");
println!("cargo:rustc-link-search=native=/usr/lib");
#[cfg(target_arch = "x86_64")]
println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
if target.contains("musl") {
// possibly lzma compressed symbol tables. Do we really need it ?
println!("cargo:rustc-link-lib=static=lzma");
println!("cargo:rustc-link-lib=static=unwind");
}
else {
println!("cargo:rustc-link-lib=static=unwind-{}", link_lib_arch);
println!("cargo:rustc-link-lib=static=unwind");
}
}
println!("cargo:rustc-link-lib=static=unwind-{}", link_lib_arch);
println!("cargo:rustc-link-lib=static=unwind");
}
12 changes: 6 additions & 6 deletions crashtracker/src/collector/emitters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::ffi::CStr;
#[cfg(target_arch = "x86_64")]
use crate::collector::libunwind_x86_64 as libunwind;

#[cfg(target_arch = "arm")]
#[cfg(target_arch = "aarch64")]
use crate::collector::libunwind_arm as libunwind;

use libunwind::{UnwCursor, UnwContext, unw_init_local, unw_step, unw_get_reg, unw_get_proc_name, UNW_REG_IP, UNW_REG_SP};
Expand Down Expand Up @@ -107,7 +107,7 @@ fn emit_backtrace_libuwnind(
if unw_init_local(&mut cursor, context) != 0 {
writeln!(w, "{{ \"error\": \"Failed to initialize cursor from context\" }}")?;
writeln!(w, "{DD_CRASHTRACK_END_STACKTRACE}")?;
w.flush()?;
w.flush()?;
return Err(anyhow::anyhow!("Failed to initialize cursor from context"));
}

Expand All @@ -134,7 +134,7 @@ fn emit_backtrace_libuwnind(
symbol_address = ip - offset;
}
// we could also retrieve the elf offsets using the libunwind APIs if needed.
writeln!(w, "{{ \"ip\": \"{:#x}\", \"sp\": \"{:#x}\", \"symbol_address\": \"{:#x}\", \"function\": \"{}\", \"offset\": \"0x{:x}\" }}",
writeln!(w, "{{ \"ip\": \"{:#x}\", \"sp\": \"{:#x}\", \"symbol_address\": \"{:#x}\", \"function\": \"{}\", \"offset\": \"0x{:x}\" }}",
ip, sp, symbol_address, func_name, offset)?;
} else {
writeln!(w, "{{ \"ip\": \"{:#x}\", \"sp\": \"{:#x}\" }}", ip, sp)?;
Expand All @@ -148,7 +148,7 @@ fn emit_backtrace_libuwnind(
writeln!(w, "{DD_CRASHTRACK_END_STACKTRACE}")?;
}

w.flush()?;
w.flush()?;
Ok(())
}

Expand Down Expand Up @@ -180,7 +180,7 @@ pub(crate) fn emit_crashreport(
// https://doc.rust-lang.org/src/std/backtrace.rs.html#332
// Do this last, so even if it crashes, we still get the other info.
if config.resolve_frames != StacktraceCollection::Disabled {
if config.stacktrace_unwinding == StackTraceUnwinding::Backtrace {
if config.stacktrace_unwinding == StackTraceUnwinding::Backtrace {
unsafe { emit_backtrace_by_frames(pipe, config.resolve_frames)? };
} else {
emit_backtrace_libuwnind(pipe, ucontext, config.resolve_frames == StacktraceCollection::EnabledWithInprocessSymbols)?;
Expand Down Expand Up @@ -343,4 +343,4 @@ fn emit_text_file(w: &mut impl Write, path: &str) -> anyhow::Result<()> {
writeln!(w, "\n{DD_CRASHTRACK_END_FILE} \"{path}\"")?;
w.flush()?;
Ok(())
}
}
4 changes: 2 additions & 2 deletions crashtracker/src/collector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ pub use additional_tags::{
#[cfg(target_arch = "x86_64")]
pub mod libunwind_x86_64;

#[cfg(target_arch = "arm")]
#[cfg(target_arch = "aarch64")]
pub mod libunwind_arm;

pub use api::*;
pub use counters::{begin_op, end_op, reset_counters, OpTypes};
pub use crash_handler::{update_config, update_metadata};
pub use spans::{clear_spans, clear_traces, insert_span, insert_trace, remove_span, remove_trace};
pub use spans::{clear_spans, clear_traces, insert_span, insert_trace, remove_span, remove_trace};

0 comments on commit 2b05c45

Please sign in to comment.