Skip to content

Commit

Permalink
adopt object changes
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Jul 21, 2024
1 parent 6c431ba commit 8f1ce89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Option<PathBuf>> {
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),
Expand Down Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?;
Expand Down

0 comments on commit 8f1ce89

Please sign in to comment.