From f9cf98d7ef135c9079660526f0d9c981b18f71bb Mon Sep 17 00:00:00 2001 From: Niels Sascha Reedijk Date: Fri, 30 Jul 2021 12:43:46 +0000 Subject: Haiku-specific patches for Rust 1.54.0 diff --git a/Cargo.lock b/Cargo.lock index de110c5..6d83dac 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.14.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +checksum = "03345e98af8f3d786b6d9f656ccfa6ac316d954e92bc4841f0bba20789d5fb5a" dependencies = [ "compiler_builtins", "gimli", @@ -278,7 +278,6 @@ dependencies = [ "humantime 2.0.1", "ignore", "im-rc", - "itertools 0.10.0", "jobserver", "lazy_static", "lazycell", @@ -294,7 +293,7 @@ dependencies = [ "rand 0.8.3", "rustc-workspace-hack", "rustfix", - "semver 1.0.3", + "semver 0.10.0", "serde", "serde_ignored", "serde_json", @@ -1427,9 +1426,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" dependencies = [ "compiler_builtins", "rustc-std-workspace-alloc", @@ -1712,15 +1711,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d572918e350e82412fe766d24b15e6682fb2ed2bbe018280caa810397cb319" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "0.4.6" @@ -1946,9 +1936,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" +checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" dependencies = [ "cc", "libc", @@ -2294,7 +2284,6 @@ dependencies = [ "hex 0.4.2", "libc", "log", - "measureme", "rand 0.8.3", "rustc-workspace-hack", "rustc_version", @@ -2350,9 +2339,9 @@ dependencies = [ [[package]] name = "object" -version = "0.22.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" dependencies = [ "compiler_builtins", "rustc-std-workspace-alloc", @@ -4691,15 +4680,6 @@ dependencies = [ "serde", ] -[[package]] -name = "semver" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f3aac57ee7f3272d8395c6e4f502f434f0e289fcd62876f70daa008c20dcabe" -dependencies = [ - "serde", -] - [[package]] name = "semver-parser" version = "0.7.0" @@ -4883,8 +4863,7 @@ dependencies = [ [[package]] name = "socket2" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +source = "git+https://github.com/rust-lang/socket2?rev=2843d44a3440a2d4b65bb15be275ec2e3e80ee4e#2843d44a3440a2d4b65bb15be275ec2e3e80ee4e" dependencies = [ "libc", "winapi 0.3.9", @@ -4924,7 +4903,7 @@ dependencies = [ "hermit-abi", "libc", "miniz_oxide", - "object 0.22.0", + "object 0.24.0", "panic_abort", "panic_unwind", "profiler_builtins", diff --git a/Cargo.toml b/Cargo.toml index 327afe3..0dacd14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,5 +110,8 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } +# Temporary patch with build fix for Haiku +"socket2" = { git = "https://github.com/rust-lang/socket2", rev = "2843d44a3440a2d4b65bb15be275ec2e3e80ee4e" } + [patch."https://github.com/rust-lang/rust-clippy"] clippy_lints = { path = "src/tools/clippy/clippy_lints" } diff --git a/library/backtrace/Cargo.toml b/library/backtrace/Cargo.toml index 71db617..6f74b2d 100644 --- a/library/backtrace/Cargo.toml +++ b/library/backtrace/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "backtrace" -version = "0.3.57" +version = "0.3.59" authors = ["The Rust Project Developers"] +build = "build.rs" license = "MIT/Apache-2.0" readme = "README.md" repository = "https://github.com/rust-lang/backtrace-rs" @@ -21,8 +22,7 @@ exclude = ['crates/without_debuginfo', 'crates/macos_frames_test', 'crates/line- [dependencies] cfg-if = "1.0" rustc-demangle = "0.1.4" -backtrace-sys = { path = "crates/backtrace-sys", version = "0.1.35", optional = true, default_features = false } -libc = { version = "0.2.87", default-features = false } +libc = { version = "0.2.94", default-features = false } # Optionally enable the ability to serialize a `Backtrace`, controlled through # the `serialize-*` features below. @@ -35,43 +35,32 @@ cpp_demangle = { default-features = false, version = "0.3.0", optional = true } # Optional dependencies enabled through the `gimli-symbolize` feature, do not # use these features directly. -addr2line = { version = "0.14.1", optional = true, default-features = false } -miniz_oxide = { version = "0.4.0", optional = true, default-features = false } +addr2line = { version = "0.15.1", default-features = false } +miniz_oxide = { version = "0.4.0", default-features = false } [dependencies.object] -version = "0.23" -optional = true +version = "0.24" default-features = false features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] [target.'cfg(windows)'.dependencies] winapi = { version = "0.3.3", optional = true } +[build-dependencies] +# Only needed for Android, but cannot be target dependent +# https://github.com/rust-lang/cargo/issues/4932 +cc = "1.0.67" + [dev-dependencies] dylib-dep = { path = "crates/dylib-dep" } libloading = "0.6" [features] # By default libstd support and gimli-symbolize is used to symbolize addresses. -default = ["std", "gimli-symbolize"] +default = ["std"] # Include std support. This enables types like `Backtrace`. std = [] -#======================================= -# Methods of resolving symbols -# -# - gimli-symbolize: use the `gimli-rs/addr2line` crate to symbolicate -# addresses into file, line, and name using DWARF debug information. -# - libbacktrace: this feature activates the `backtrace-sys` dependency, -# building the libbacktrace library found in gcc repos. -# -# Note that MSVC unconditionally uses the dbghelp library to symbolize and won't -# be affected by feature selection here. Also note that it's highly unlikely you -# want to configure this. If you're having trouble getting backtraces it's -# likely best to open an issue. -gimli-symbolize = ["addr2line", "miniz_oxide", "object"] -libbacktrace = ["backtrace-sys/backtrace-sys"] - #======================================= # Methods of serialization # @@ -85,11 +74,13 @@ serialize-serde = ["serde"] # Only here for backwards compatibility purposes or for internal testing # purposes. New code should use none of these features. coresymbolication = [] +dbghelp = [] dladdr = [] +gimli-symbolize = [] kernel32 = [] -unix-backtrace = [] +libbacktrace = [] libunwind = [] -dbghelp = [] +unix-backtrace = [] verify-winapi = [ 'winapi/dbghelp', 'winapi/handleapi', @@ -126,7 +117,7 @@ edition = '2018' [[test]] name = "accuracy" -required-features = ["std", "gimli-symbolize"] +required-features = ["std"] edition = '2018' [[test]] diff --git a/library/backtrace/build.rs b/library/backtrace/build.rs new file mode 100644 index 0000000..812fbb1 --- /dev/null +++ b/library/backtrace/build.rs @@ -0,0 +1,41 @@ +extern crate cc; + +use std::env; + +fn main() { + match env::var("CARGO_CFG_TARGET_OS").unwrap_or_default().as_str() { + "android" => build_android(), + _ => {} + } +} + +fn build_android() { + let expansion = match cc::Build::new().file("src/android-api.c").try_expand() { + Ok(result) => result, + Err(e) => { + println!("failed to run C compiler: {}", e); + return; + } + }; + let expansion = match std::str::from_utf8(&expansion) { + Ok(s) => s, + Err(_) => return, + }; + println!("expanded android version detection:\n{}", expansion); + let marker = "APIVERSION"; + let i = match expansion.find(marker) { + Some(i) => i, + None => return, + }; + let version = match expansion[i + marker.len() + 1..].split_whitespace().next() { + Some(s) => s, + None => return, + }; + let version = match version.parse::() { + Ok(n) => n, + Err(_) => return, + }; + if version >= 21 { + println!("cargo:rustc-cfg=feature=\"dl_iterate_phdr\""); + } +} diff --git a/library/backtrace/crates/as-if-std/Cargo.toml b/library/backtrace/crates/as-if-std/Cargo.toml index b7cb2a8..36adc20 100644 --- a/library/backtrace/crates/as-if-std/Cargo.toml +++ b/library/backtrace/crates/as-if-std/Cargo.toml @@ -15,11 +15,11 @@ bench = false cfg-if = "1.0" rustc-demangle = "0.1.4" libc = { version = "0.2.45", default-features = false } -addr2line = { version = "0.14.1", default-features = false } +addr2line = { version = "0.15.1", default-features = false } miniz_oxide = { version = "0.4.0", default-features = false } [dependencies.object] -version = "0.22" +version = "0.24" default-features = false features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] diff --git a/library/backtrace/src/android-api.c b/library/backtrace/src/android-api.c new file mode 100644 index 0000000..1bfeadf --- /dev/null +++ b/library/backtrace/src/android-api.c @@ -0,0 +1,4 @@ +// Used from the build script to detect the value of the `__ANDROID_API__` +// builtin #define + +APIVERSION __ANDROID_API__ diff --git a/library/backtrace/src/capture.rs b/library/backtrace/src/capture.rs index 9bd6ce9..e0dd9c4 100644 --- a/library/backtrace/src/capture.rs +++ b/library/backtrace/src/capture.rs @@ -249,6 +249,15 @@ impl From> for Backtrace { } } +impl From for BacktraceFrame { + fn from(frame: crate::Frame) -> BacktraceFrame { + BacktraceFrame { + frame: Frame::Raw(frame), + symbols: None, + } + } +} + impl Into> for Backtrace { fn into(self) -> Vec { self.frames @@ -518,3 +527,29 @@ mod serde_impls { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_frame_conversion() { + let mut frames = vec![]; + crate::trace(|frame| { + let converted = BacktraceFrame::from(frame.clone()); + frames.push(converted); + true + }); + + let mut manual = Backtrace::from(frames); + manual.resolve(); + let frames = manual.frames(); + + for frame in frames { + println!("{:?}", frame.ip()); + println!("{:?}", frame.symbol_address()); + println!("{:?}", frame.module_base_address()); + println!("{:?}", frame.symbols()); + } + } +} diff --git a/library/backtrace/src/symbolize/gimli.rs b/library/backtrace/src/symbolize/gimli.rs index bcd362c..b7f4965 100644 --- a/library/backtrace/src/symbolize/gimli.rs +++ b/library/backtrace/src/symbolize/gimli.rs @@ -85,27 +85,13 @@ struct Context<'a> { impl<'data> Context<'data> { fn new(stash: &'data Stash, object: Object<'data>) -> Option> { - fn load_section<'data, S>(stash: &'data Stash, obj: &Object<'data>) -> S - where - S: gimli::Section>, - { - let data = obj.section(stash, S::section_name()).unwrap_or(&[]); - S::from(EndianSlice::new(data, Endian)) - } - - let dwarf = addr2line::Context::from_sections( - load_section(stash, &object), - load_section(stash, &object), - load_section(stash, &object), - load_section(stash, &object), - load_section(stash, &object), - load_section(stash, &object), - load_section(stash, &object), - load_section(stash, &object), - load_section(stash, &object), - gimli::EndianSlice::new(&[], Endian), - ) + let sections = gimli::Dwarf::load(|id| -> Result<_, ()> { + let data = object.section(stash, id.name()).unwrap_or(&[]); + Ok(EndianSlice::new(data, Endian)) + }) .ok()?; + let dwarf = addr2line::Context::from_dwarf(sections).ok()?; + Some(Context { dwarf, object }) } } @@ -154,6 +140,7 @@ cfg_if::cfg_if! { target_os = "linux", target_os = "fuchsia", target_os = "freebsd", + all(target_os = "android", feature = "dl_iterate_phdr"), ), not(target_env = "uclibc"), ))] { diff --git a/library/backtrace/src/symbolize/gimli/coff.rs b/library/backtrace/src/symbolize/gimli/coff.rs index 8a6995e..0c69c58 100644 --- a/library/backtrace/src/symbolize/gimli/coff.rs +++ b/library/backtrace/src/symbolize/gimli/coff.rs @@ -3,7 +3,7 @@ use core::convert::TryFrom; use object::pe::{ImageDosHeader, ImageSymbol}; use object::read::pe::{ImageNtHeaders, ImageOptionalHeader, SectionTable}; use object::read::StringTable; -use object::{Bytes, LittleEndian as LE}; +use object::LittleEndian as LE; #[cfg(target_pointer_width = "32")] type Pe = object::pe::ImageNtHeaders32; @@ -18,25 +18,25 @@ impl Mapping { } pub struct Object<'a> { - data: Bytes<'a>, + data: &'a [u8], sections: SectionTable<'a>, symbols: Vec<(usize, &'a ImageSymbol)>, strings: StringTable<'a>, } pub fn get_image_base(data: &[u8]) -> Option { - let data = Bytes(data); let dos_header = ImageDosHeader::parse(data).ok()?; - let (nt_headers, _, _) = dos_header.nt_headers::(data).ok()?; + let mut offset = dos_header.nt_headers_offset().into(); + let (nt_headers, _) = Pe::parse(data, &mut offset).ok()?; usize::try_from(nt_headers.optional_header().image_base()).ok() } impl<'a> Object<'a> { fn parse(data: &'a [u8]) -> Option> { - let data = Bytes(data); let dos_header = ImageDosHeader::parse(data).ok()?; - let (nt_headers, _, nt_tail) = dos_header.nt_headers::(data).ok()?; - let sections = nt_headers.sections(nt_tail).ok()?; + let mut offset = dos_header.nt_headers_offset().into(); + let (nt_headers, _) = Pe::parse(data, &mut offset).ok()?; + let sections = nt_headers.sections(data, offset).ok()?; let symtab = nt_headers.symbols(data).ok()?; let strings = symtab.strings(); let image_base = usize::try_from(nt_headers.optional_header().image_base()).ok()?; @@ -78,8 +78,7 @@ impl<'a> Object<'a> { .section_by_name(self.strings, name.as_bytes())? .1 .pe_data(self.data) - .ok()? - .0, + .ok()?, ) } diff --git a/library/backtrace/src/symbolize/gimli/elf.rs b/library/backtrace/src/symbolize/gimli/elf.rs index 41a30fe..ee311a8 100644 --- a/library/backtrace/src/symbolize/gimli/elf.rs +++ b/library/backtrace/src/symbolize/gimli/elf.rs @@ -29,7 +29,7 @@ pub struct Object<'a> { /// We could use a literal instead, but this helps ensure correctness. endian: NativeEndian, /// The entire file data. - data: Bytes<'a>, + data: &'a [u8], sections: SectionTable<'a, Elf>, strings: StringTable<'a>, /// List of pre-parsed and sorted symbols by base address. @@ -38,7 +38,6 @@ pub struct Object<'a> { impl<'a> Object<'a> { fn parse(data: &'a [u8]) -> Option> { - let data = object::Bytes(data); let elf = Elf::parse(data).ok()?; let endian = elf.endian().ok()?; let sections = elf.sections(endian, data).ok()?; @@ -90,7 +89,7 @@ impl<'a> Object<'a> { pub fn section(&self, stash: &'a Stash, name: &str) -> Option<&'a [u8]> { if let Some(section) = self.section_header(name) { - let mut data = section.data(self.endian, self.data).ok()?; + let mut data = Bytes(section.data(self.endian, self.data).ok()?); // Check for DWARF-standard (gABI) compression, i.e., as generated // by ld's `--compress-debug-sections=zlib-gabi` flag. @@ -131,7 +130,7 @@ impl<'a> Object<'a> { } }) .next()?; - let mut data = compressed_section.data(self.endian, self.data).ok()?; + let mut data = Bytes(compressed_section.data(self.endian, self.data).ok()?); if data.read_bytes(8).ok()?.0 != b"ZLIB\0\0\0\0" { return None; } diff --git a/library/backtrace/src/symbolize/gimli/libs_haiku.rs b/library/backtrace/src/symbolize/gimli/libs_haiku.rs index f80686a..87e023e 100644 --- a/library/backtrace/src/symbolize/gimli/libs_haiku.rs +++ b/library/backtrace/src/symbolize/gimli/libs_haiku.rs @@ -7,6 +7,7 @@ use super::mystd::borrow::ToOwned; use super::mystd::ffi::{CStr, OsStr}; +use super::mystd::mem::MaybeUninit; use super::mystd::os::unix::prelude::*; use super::{Library, LibrarySegment, Vec}; @@ -14,7 +15,7 @@ pub(super) fn native_libraries() -> Vec { let mut libraries: Vec = Vec::new(); unsafe { - let mut info = mem::MaybeUninit::::zeroed(); + let mut info = MaybeUninit::::zeroed(); let mut cookie: i32 = 0; // Load the first image to get a valid info struct let mut status = diff --git a/library/backtrace/src/symbolize/gimli/libs_macos.rs b/library/backtrace/src/symbolize/gimli/libs_macos.rs index 2b6b671..1c58a81 100644 --- a/library/backtrace/src/symbolize/gimli/libs_macos.rs +++ b/library/backtrace/src/symbolize/gimli/libs_macos.rs @@ -19,7 +19,7 @@ pub(super) fn native_libraries() -> Vec { fn native_library(i: u32) -> Option { use object::macho; use object::read::macho::{MachHeader, Segment}; - use object::{Bytes, NativeEndian}; + use object::NativeEndian; // Fetch the name of this library which corresponds to the path of // where to load it as well. @@ -47,7 +47,7 @@ fn native_library(i: u32) -> Option { header as *const _ as *const u8, mem::size_of_val(header) + header.sizeofcmds.get(endian) as usize, ); - (header.load_commands(endian, Bytes(data)).ok()?, endian) + (header.load_commands(endian, data).ok()?, endian) } macho::MH_MAGIC_64 => { let endian = NativeEndian; @@ -56,7 +56,7 @@ fn native_library(i: u32) -> Option { header as *const _ as *const u8, mem::size_of_val(header) + header.sizeofcmds.get(endian) as usize, ); - (header.load_commands(endian, Bytes(data)).ok()?, endian) + (header.load_commands(endian, data).ok()?, endian) } _ => return None, } diff --git a/library/backtrace/src/symbolize/gimli/macho.rs b/library/backtrace/src/symbolize/gimli/macho.rs index 4b96bf1..cdd24bd 100644 --- a/library/backtrace/src/symbolize/gimli/macho.rs +++ b/library/backtrace/src/symbolize/gimli/macho.rs @@ -20,7 +20,7 @@ impl Mapping { // First up we need to load the unique UUID which is stored in the macho // header of the file we're reading, specified at `path`. let map = super::mmap(path)?; - let (macho, data) = find_header(Bytes(&map))?; + let (macho, data) = find_header(&map)?; let endian = macho.endian().ok()?; let uuid = macho.uuid(endian, data).ok()??; @@ -40,7 +40,7 @@ impl Mapping { // file. This should have the symbol table for at least some // symbolication purposes. Mapping::mk(map, |data, stash| { - let (macho, data) = find_header(Bytes(data))?; + let (macho, data) = find_header(data)?; let endian = macho.endian().ok()?; let obj = Object::parse(macho, endian, data)?; Context::new(stash, obj) @@ -73,7 +73,7 @@ impl Mapping { let entry = entry.ok()?; let map = super::mmap(&entry.path())?; let candidate = Mapping::mk(map, |data, stash| { - let (macho, data) = find_header(Bytes(data))?; + let (macho, data) = find_header(data)?; let endian = macho.endian().ok()?; let entry_uuid = macho.uuid(endian, data).ok()??; if entry_uuid != uuid { @@ -91,7 +91,7 @@ impl Mapping { } } -fn find_header(mut data: Bytes<'_>) -> Option<(&'_ Mach, Bytes<'_>)> { +fn find_header(data: &'_ [u8]) -> Option<(&'_ Mach, &'_ [u8])> { use object::endian::BigEndian; let desired_cpu = || { @@ -108,6 +108,7 @@ fn find_header(mut data: Bytes<'_>) -> Option<(&'_ Mach, Bytes<'_>)> { } }; + let mut data = Bytes(data); match data .clone() .read::>() @@ -149,13 +150,13 @@ fn find_header(mut data: Bytes<'_>) -> Option<(&'_ Mach, Bytes<'_>)> { _ => return None, } - Mach::parse(data).ok().map(|h| (h, data)) + Mach::parse(data.0).ok().map(|h| (h, data.0)) } // This is used both for executables/libraries and source object files. pub struct Object<'a> { endian: NativeEndian, - data: Bytes<'a>, + data: &'a [u8], dwarf: Option<&'a [MachSection]>, syms: Vec<(&'a [u8], u64)>, syms_sort_by_name: bool, @@ -166,7 +167,7 @@ pub struct Object<'a> { } impl<'a> Object<'a> { - fn parse(mach: &'a Mach, endian: NativeEndian, data: Bytes<'a>) -> Option> { + fn parse(mach: &'a Mach, endian: NativeEndian, data: &'a [u8]) -> Option> { let is_object = mach.filetype(endian) == object::macho::MH_OBJECT; let mut dwarf = None; let mut syms = Vec::new(); @@ -181,7 +182,7 @@ impl<'a> Object<'a> { dwarf = segment.sections(endian, section_data).ok(); } } else if let Some(symtab) = command.symtab().ok()? { - let symbols = symtab.symbols::(endian, data).ok()?; + let symbols = symtab.symbols::(endian, data).ok()?; syms = symbols .iter() .filter_map(|nlist: &MachNlist| { @@ -230,7 +231,7 @@ impl<'a> Object<'a> { && §ion_name[2..] == &name[1..] } })?; - Some(section.data(self.endian, self.data).ok()?.0) + Some(section.data(self.endian, self.data).ok()?) } pub fn search_symtab<'b>(&'b self, addr: u64) -> Option<&'b [u8]> { @@ -299,9 +300,9 @@ fn object_mapping(path: &[u8]) -> Option { .members() .filter_map(Result::ok) .find(|m| m.name() == member_name)?; - Bytes(member.data()) + member.data(data).ok()? } - None => Bytes(data), + None => data, }; let (macho, data) = find_header(data)?; let endian = macho.endian().ok()?; diff --git a/library/backtrace/src/symbolize/mod.rs b/library/backtrace/src/symbolize/mod.rs index 961c63d..699d54e 100644 --- a/library/backtrace/src/symbolize/mod.rs +++ b/library/backtrace/src/symbolize/mod.rs @@ -471,17 +471,6 @@ cfg_if::cfg_if! { mod dbghelp; use dbghelp as imp; } else if #[cfg(all( - feature = "libbacktrace", - any(unix, all(windows, not(target_vendor = "uwp"), target_env = "gnu")), - not(target_os = "fuchsia"), - not(target_os = "emscripten"), - not(target_env = "uclibc"), - not(target_env = "libnx"), - ))] { - mod libbacktrace; - use libbacktrace as imp; - } else if #[cfg(all( - feature = "gimli-symbolize", any(unix, windows), not(target_vendor = "uwp"), not(target_os = "emscripten"), diff --git a/library/backtrace/tests/accuracy/main.rs b/library/backtrace/tests/accuracy/main.rs index a2aba07..54409c1 100644 --- a/library/backtrace/tests/accuracy/main.rs +++ b/library/backtrace/tests/accuracy/main.rs @@ -20,8 +20,6 @@ fn doit() { // Skip musl which is by default statically linked and doesn't support // dynamic libraries. !cfg!(target_env = "musl") - // Skip MinGW on libbacktrace which doesn't have support for DLLs. - && !(cfg!(windows) && cfg!(target_env = "gnu") && cfg!(feature = "libbacktrace")) // Skip Miri, since it doesn't support dynamic libraries. && !cfg!(miri) { diff --git a/library/backtrace/tests/smoke.rs b/library/backtrace/tests/smoke.rs index 0c990e0..683a6f0 100644 --- a/library/backtrace/tests/smoke.rs +++ b/library/backtrace/tests/smoke.rs @@ -1,38 +1,6 @@ use backtrace::Frame; use std::thread; -// Reflects the conditional compilation logic at end of src/symbolize/mod.rs -static NOOP: bool = false; -static DBGHELP: bool = !NOOP - && cfg!(all( - windows, - target_env = "msvc", - not(target_vendor = "uwp") - )); -static LIBBACKTRACE: bool = !NOOP - && !DBGHELP - && cfg!(all( - feature = "libbacktrace", - any( - unix, - all(windows, not(target_vendor = "uwp"), target_env = "gnu") - ), - not(target_os = "fuchsia"), - not(target_os = "emscripten"), - not(target_env = "uclibc"), - not(target_env = "libnx"), - )); -static GIMLI_SYMBOLIZE: bool = !NOOP - && !DBGHELP - && !LIBBACKTRACE - && cfg!(all( - feature = "gimli-symbolize", - any(unix, windows), - not(target_vendor = "uwp"), - not(target_os = "emscripten"), - )); -static MIRI_SYMBOLIZE: bool = cfg!(miri); - #[test] // FIXME: shouldn't ignore this test on i686-msvc, unsure why it's failing #[cfg_attr(all(target_arch = "x86", target_env = "msvc"), ignore)] @@ -159,8 +127,6 @@ fn smoke_test_frames() { } let mut resolved = 0; - let can_resolve = LIBBACKTRACE || GIMLI_SYMBOLIZE || MIRI_SYMBOLIZE; - let can_resolve_cols = GIMLI_SYMBOLIZE || MIRI_SYMBOLIZE; let mut name = None; let mut addr = None; @@ -175,31 +141,22 @@ fn smoke_test_frames() { line = sym.lineno(); file = sym.filename().map(|v| v.to_path_buf()); }); + assert!(resolved > 0); - // dbghelp doesn't always resolve symbols right now - match resolved { - 0 => return assert!(!can_resolve), - _ => {} - } - - if can_resolve { - let name = name.expect("didn't find a name"); + let name = name.expect("didn't find a name"); - // in release mode names get weird as functions can get merged - // together with `mergefunc`, so only assert this in debug mode - if cfg!(debug_assertions) { - assert!( - name.contains(expected_name), - "didn't find `{}` in `{}`", - expected_name, - name - ); - } + // in release mode names get weird as functions can get merged + // together with `mergefunc`, so only assert this in debug mode + if cfg!(debug_assertions) { + assert!( + name.contains(expected_name), + "didn't find `{}` in `{}`", + expected_name, + name + ); } - if can_resolve { - addr.expect("didn't find a symbol"); - } + addr.expect("didn't find a symbol"); if cfg!(debug_assertions) { let line = line.expect("didn't find a line number"); @@ -221,7 +178,9 @@ fn smoke_test_frames() { expected_line ); } - if can_resolve_cols { + + // dbghelp on MSVC doesn't support column numbers + if !cfg!(target_env = "msvc") { let col = col.expect("didn't find a column number"); if expected_col != 0 { assert!( @@ -321,9 +280,8 @@ fn sp_smoke_test() { let mut is_recursive_stack_references = false; backtrace::resolve(frame.ip(), |sym| { - is_recursive_stack_references |= (LIBBACKTRACE || GIMLI_SYMBOLIZE) - && sym - .name() + is_recursive_stack_references |= + sym.name() .and_then(|name| name.as_str()) .map_or(false, |name| { eprintln!("name = {}", name); diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 415d874..5751a1a 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -24,11 +24,11 @@ hashbrown = { version = "0.11", default-features = false, features = ['rustc-dep std_detect = { path = "../stdarch/crates/std_detect", default-features = false, features = ['rustc-dep-of-std'] } # Dependencies of the `backtrace` crate -addr2line = { version = "0.14.0", optional = true, default-features = false } +addr2line = { version = "0.15.1", optional = true, default-features = false } rustc-demangle = { version = "0.1.18", features = ['rustc-dep-of-std'] } miniz_oxide = { version = "0.4.0", optional = true, default-features = false } [dependencies.object] -version = "0.22" +version = "0.24" optional = true default-features = false features = ['read_core', 'elf', 'macho', 'pe', 'unaligned', 'archive'] diff --git a/src/llvm-project/llvm/lib/Support/CMakeLists.txt b/src/llvm-project/llvm/lib/Support/CMakeLists.txt index cdee114..1c805e3 100644 --- a/src/llvm-project/llvm/lib/Support/CMakeLists.txt +++ b/src/llvm-project/llvm/lib/Support/CMakeLists.txt @@ -36,6 +36,10 @@ elseif( CMAKE_HOST_UNIX ) if( FUCHSIA ) set(system_libs ${system_libs} zircon) endif() + if ( HAIKU ) + add_definitions(-D_BSD_SOURCE) + set(system_libs ${system_libs} bsd) + endif() endif( MSVC OR MINGW ) # Delay load shell32.dll if possible to speed up process startup. diff --git a/src/llvm-project/llvm/lib/Support/Unix/Program.inc b/src/llvm-project/llvm/lib/Support/Unix/Program.inc index fb56fa4..d42681f 100644 --- a/src/llvm-project/llvm/lib/Support/Unix/Program.inc +++ b/src/llvm-project/llvm/lib/Support/Unix/Program.inc @@ -452,8 +452,12 @@ ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait, if (ProcStat) { std::chrono::microseconds UserT = toDuration(Info.ru_utime); std::chrono::microseconds KernelT = toDuration(Info.ru_stime); +#ifndef __HAIKU__ uint64_t PeakMemory = static_cast(Info.ru_maxrss); *ProcStat = ProcessStatistics{UserT + KernelT, UserT, PeakMemory}; +#else + *ProcStat = ProcessStatistics{UserT + KernelT, UserT, 0}; +#endif } // Return the proper exit status. Detect error conditions diff --git a/src/llvm-project/llvm/tools/llvm-jitlink/CMakeLists.txt b/src/llvm-project/llvm/tools/llvm-jitlink/CMakeLists.txt index 90b4ca6..c9f9a53 100644 --- a/src/llvm-project/llvm/tools/llvm-jitlink/CMakeLists.txt +++ b/src/llvm-project/llvm/tools/llvm-jitlink/CMakeLists.txt @@ -24,6 +24,10 @@ add_llvm_tool(llvm-jitlink llvm-jitlink-macho.cpp ) +if(${CMAKE_SYSTEM_NAME} MATCHES "Haiku") + target_link_libraries(llvm-jitlink PRIVATE network) +endif() + if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") target_link_libraries(llvm-jitlink PRIVATE socket nsl) endif() diff --git a/src/llvm-project/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt b/src/llvm-project/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt index a183857..37af9a5 100644 --- a/src/llvm-project/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt +++ b/src/llvm-project/llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt @@ -12,6 +12,10 @@ add_llvm_utility(llvm-jitlink-executor ) message(${CMAKE_SYSTEM_NAME}) +if(${CMAKE_SYSTEM_NAME} MATCHES "Haiku") + target_link_libraries(llvm-jitlink-executor PRIVATE network) +endif() + if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") target_link_libraries(llvm-jitlink-executor PRIVATE socket) endif() -- 2.30.2