rustc_codegen_ssa: Refactor ArchiveEntry to include entry kind#157263
rustc_codegen_ssa: Refactor ArchiveEntry to include entry kind#157263petrochenkov wants to merge 1 commit into
ArchiveEntry to include entry kind#157263Conversation
| .map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?; | ||
| let metadata_link = | ||
| skip.as_ref().and_then(|_| rmeta_link::read(&archive, &archive_map, &archive_path)); | ||
| let metadata_link = rmeta_link::read(&archive, &archive_map, &archive_path); |
There was a problem hiding this comment.
We always try to read the link-metadata now.
Right now skip happens to be always Some for Rust rlibs and always None for native libs, so the previous optimization happened to be correct.
We could potentially reinstate the optimization and add a comment saying that skip must always be Some for Rust rlibs, but it's probably not that useful for performance in practice.
There was a problem hiding this comment.
A native lib could contain a file that could be interpreted as link-metadata. Decoding metadata may panic, not just return an error, so we shouldn't attempt to parse the link-metadata for non-rlibs at all.
There was a problem hiding this comment.
Okay, I'll add an extra flag telling whether it's a rlib.
| } | ||
|
|
||
| // Skip objects for bundled libs. | ||
| if bundled_libs.contains(&Symbol::intern(fname)) { |
There was a problem hiding this comment.
From this function we can see that it would be also useful to track at least ArchiveEntryKind::Rmeta and ArchiveEntryKind::BundledNativeLib.
But in general, it would probably make sense to get rid of ArchiveEntryKind::Other and keep the full "entry name -> entry kind" table in the link-metadata.
Needed for #155338 in particular.
r? @bjorn3