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 |
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.
c514597 to
45ee197
Compare
This comment has been minimized.
This comment has been minimized.
45ee197 to
9a7ad42
Compare
|
@rustbot ready |
|
@bjorn3 |
| } | ||
| } | ||
|
|
||
| fn get_rlib_native_lib_filenames(&self, target: &Target, path: &Path) -> Vec<Option<String>> { |
There was a problem hiding this comment.
This trait currently has methods for getting the whole metadata blob, not some specific fields from it.
If we are working with MetadataLoader at all, then the added method should be something like fn get_rlib_link_metadata.
There was a problem hiding this comment.
Note that rust_object_files are currently read from link-time metadata without involving MetadataLoader.
I think we should do the same thing for native_lib_filenames now.
There was a problem hiding this comment.
rust_object_files is read by the link code and individual codegen backends, while native_lib_filenames is read by common code too that an individual codegen backend can't override. I do agree with having get_rlib_link_metadata rather than get_rlib_native_lib_filenames. The MetadataLoader should treat everything as opaque blobs rather than deserialize it.
There was a problem hiding this comment.
while
native_lib_filenamesis read by common code too
Not actually, it's only read by code in link.rs, unlike other parts of NativeLib.
| self.metas[cnum].as_ref().unwrap_or_else(|| panic!("Failed to get crate data for {cnum:?}")) | ||
| } | ||
|
|
||
| pub(crate) fn metadata_loader(&self) -> &MetadataLoaderDyn { |
There was a problem hiding this comment.
This method can be inlined and removed.
| native_libraries: Default::default(), | ||
| native_libraries_filenames: Default::default(), | ||
| used_libraries: tcx.native_libraries(LOCAL_CRATE).iter().map(Into::into).collect(), | ||
| used_libraries_filenames: local_native_lib_filenames(tcx), |
There was a problem hiding this comment.
It is still too early to read the link-time metadata here, it only needs to be read in link.rs.
|
I didn't have time to look at some parts, but they'll likely need to be reworked anyway due to #156735 (comment). |
|
Reminder, once the PR becomes ready for a review, use |
It would be a necessity for any external backend that wants to support an object file format or static library format that rustc doesn't. |
|
Don't remember if it was asked already, but would it be possible and make sense to move the entire |
So the difference is that the filename is only used by link.rs code #156735 (comment), but other parts of (*) Although didn't check if this is true for all the other parts. |
|
I will be moving the symbol export calculation to the link phase as soon as I have moved LTO there (which would then also allow and require moving the list of exported symbols from the rmeta to rmeta-link). Only the actual link step and LTO need the list of exported symbols. |
|
Ok read the full discussion. will proceed to totally separate link time vs compile time path then. |
9a7ad42 to
cc47698
Compare
View all comments
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.