From 79f2379c525ccc2f93ba239b48ddcdca9f098943 Mon Sep 17 00:00:00 2001 From: klensy Date: Sun, 21 Jul 2024 13:56:16 +0300 Subject: [PATCH] adopt object changes --- .../rustc_codegen_ssa/src/back/archive.rs | 22 +++++++++++-------- compiler/rustc_codegen_ssa/src/back/link.rs | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index ae649cd77c420..57d0cf5e12445 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -110,13 +110,11 @@ impl<'a> ArArchiveBuilder<'a> { } fn try_filter_fat_archs( - archs: object::read::Result<&[impl FatArch]>, + archs: &[impl FatArch], target_arch: object::Architecture, archive_path: &Path, archive_map_data: &[u8], ) -> io::Result> { - let archs = archs.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?; - let desired = match archs.iter().find(|a| a.architecture() == target_arch) { Some(a) => a, None => return Ok(None), @@ -146,17 +144,23 @@ pub fn try_extract_macho_fat_archive( _ => return Ok(None), }; - match object::macho::FatHeader::parse(&*archive_map) { - Ok(h) if h.magic.get(object::endian::BigEndian) == object::macho::FAT_MAGIC => { - let archs = object::macho::FatHeader::parse_arch32(&*archive_map); + if let Ok(h) = object::read::macho::MachOFatFile32::parse(&*archive_map) { + if h.header().magic.get(object::endian::BigEndian) == object::macho::FAT_MAGIC { + let archs = h.arches(); try_filter_fat_archs(archs, target_arch, archive_path, &*archive_map) + } else { + Ok(None) } - Ok(h) if h.magic.get(object::endian::BigEndian) == object::macho::FAT_MAGIC_64 => { - let archs = object::macho::FatHeader::parse_arch64(&*archive_map); + } else if let Ok(h) = object::read::macho::MachOFatFile64::parse(&*archive_map) { + if h.header().magic.get(object::endian::BigEndian) == object::macho::FAT_MAGIC_64 { + let archs = h.arches(); try_filter_fat_archs(archs, target_arch, archive_path, &*archive_map) + } else { + Ok(None) } + } else { // Not a FatHeader at all, just return None. - _ => Ok(None), + Ok(None) } } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 8c582fac0d824..f7460a64d0afb 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -700,7 +700,7 @@ fn link_dwarf_object(sess: &Session, cg_results: &CodegenResults, executable_out .truncate(true) .open(dwp_out_filename)?, ); - let mut output_stream = object::write::StreamingBuffer::new(output_stream); + let mut output_stream = thorin::object::write::StreamingBuffer::new(output_stream); package.finish()?.emit(&mut output_stream)?; output_stream.result()?; output_stream.into_inner().flush()?;