Move NativeLib::filename to the rmeta-link archive member#156735
Move NativeLib::filename to the rmeta-link archive member#156735mehdiakiki wants to merge 1 commit into
Conversation
|
rustbot has assigned @dingxiangfei2009. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
053432f to
8f96681
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
8f96681 to
5a93c75
Compare
|
r? @petrochenkov |
| let needle_b = b"native_dep_b"; | ||
| assert!( | ||
| rmeta_link.windows(needle_a.len()).any(|w| w == needle_a), | ||
| "lib.rmeta-link missing native_dep_a" |
There was a problem hiding this comment.
I don't think we need a test making sure that filename lives in the .rmeta-link file specifically.
We rather need tests making sure that -Zpacked_bundled_libs works, and we have some of those. If this test doesn't add something new compared to them, then it can be removed.
| /// N.B., increment this if you change the format of metadata such that | ||
| /// the rustc version can't be found to compare with `rustc_version()`. | ||
| const METADATA_VERSION: u8 = 10; | ||
| const METADATA_VERSION: u8 = 11; |
There was a problem hiding this comment.
This PR doesn't do anything requiring changing this.
| pub name: Symbol, | ||
| /// If packed_bundled_libs enabled, actual filename of library is stored. | ||
| #[stable_hash(ignore)] | ||
| pub filename: Option<Symbol>, |
There was a problem hiding this comment.
The goal of the change is to remove this field entirely, and read the .rmeta-link file only during linking, not from fn get_native_libraries.
| let mut decoder = MemDecoder::new(data, 0).ok()?; | ||
| let rust_object_files = Vec::<String>::decode(&mut decoder); | ||
| Some(RmetaLink { rust_object_files }) | ||
| std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { |
There was a problem hiding this comment.
What is the motivation for this change?
Currently the compiler can ICE if corrupted metadata is given to it, that's considered ok.
| let native_lib_filenames: Vec<(String, String)> = crate_info | ||
| .used_libraries | ||
| .iter() | ||
| .filter_map(|lib| Some((lib.name.to_string(), lib.filename?.to_string()))) |
There was a problem hiding this comment.
Library name is not a reliable key here, the library's index in the native_libraries vector would be more reliable.
5a93c75 to
3b0d8b8
Compare
|
Started working on it today. Should have it ready soon. |
3b0d8b8 to
e923f64
Compare
This comment has been minimized.
This comment has been minimized.
e923f64 to
2414bd9
Compare
This comment has been minimized.
This comment has been minimized.
2414bd9 to
b0da354
Compare
This comment has been minimized.
This comment has been minimized.
b0da354 to
92610ca
Compare
This comment has been minimized.
This comment has been minimized.
92610ca to
70f18ca
Compare
This comment has been minimized.
This comment has been minimized.
70f18ca to
578ba56
Compare
This comment has been minimized.
This comment has been minimized.
578ba56 to
c514597
Compare
Second PR in #138243
Moves
NativeLib::filenameout ofrmetaintolib.rmeta-linkarchive member that was introduced in the first PR. Filename is a link time only data so requiring a full metadata decode should be avoided. It is stored as(name, filename)pairs keyed by name, the newMetadataLoader::get_rlib_native_lib_filenamespatches it back on decode. Also bumpedMETADATA_VERSIONfrom version 10 to 11. Added also new round trip test and existing bundled-libs tests still pass.