Skip to content

Move NativeLib::filename to the rmeta-link archive member#156735

Open
mehdiakiki wants to merge 1 commit into
rust-lang:mainfrom
mehdiakiki:fix/rlib-digest
Open

Move NativeLib::filename to the rmeta-link archive member#156735
mehdiakiki wants to merge 1 commit into
rust-lang:mainfrom
mehdiakiki:fix/rlib-digest

Conversation

@mehdiakiki

@mehdiakiki mehdiakiki commented May 19, 2026

Copy link
Copy Markdown
Contributor

View all comments

Second PR in #138243
Moves NativeLib::filename out of rmeta into lib.rmeta-link archive 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 new MetadataLoader::get_rlib_native_lib_filenames patches it back on decode. Also bumped METADATA_VERSION from version 10 to 11. Added also new round trip test and existing bundled-libs tests still pass.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 19, 2026
@rustbot

rustbot commented May 19, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 19 candidates

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@mehdiakiki

Copy link
Copy Markdown
Contributor Author

r? @petrochenkov
cc @bjorn3

Comment thread tests/run-make/rlib-rmeta-link-native-lib-filenames/rmake.rs Outdated
Comment thread compiler/rustc_metadata/src/rmeta/mod.rs Outdated
Comment thread compiler/rustc_session/src/cstore.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/back/rmeta_link.rs Outdated
Comment thread compiler/rustc_codegen_ssa/src/back/link.rs Outdated
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 19, 2026
@mehdiakiki

Copy link
Copy Markdown
Contributor Author

Started working on it today. Should have it ready soon.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jun 29, 2026
@rustbot

rustbot commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot rustbot added the has-merge-commits PR has merge commits, merge with caution. label Jul 2, 2026
@rustbot

rustbot commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

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.

@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Jul 2, 2026
@petrochenkov petrochenkov added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 3, 2026
}

// FIXME: this is mostly a copy-paste of `DefaultMetadataLoader::get_rlib_metadata`.
pub fn read_from_path(target: &Target, path: &Path) -> Option<RmetaLink> {

@petrochenkov petrochenkov Jul 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we call this function we always do this

                    .map(|rl| {
                        rl.native_lib_filenames
                            .iter()
                            .map(|f| f.as_deref().map(Symbol::intern))
                            .collect()
                    })
                    .unwrap_or_default()

as well.

Could you merge that logic into this function, or add a second function doing read_from_path + the logic above.

View changes since the review

let relevant = native_libs.clone().filter(|lib| relevant_lib(sess, lib));
let relevant_libs: FxIndexSet<_> = relevant.filter_map(|lib| lib.filename).collect();
let native_libs = &crate_info.native_libraries[&cnum];
let filenames: Vec<Option<Symbol>> = if crate_may_have_bundled_libs(native_libs) {

@petrochenkov petrochenkov Jul 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let filenames: Vec<Option<Symbol>> = if crate_may_have_bundled_libs(native_libs) {
let bundled_filenames: Vec<Option<Symbol>> = if crate_may_have_bundled_libs(native_libs) {

View changes since the review

let native_libs = match cnum {
LOCAL_CRATE => &crate_info.used_libraries,
_ => &crate_info.native_libraries[&cnum],
let (native_libs, filenames): (&Vec<NativeLib>, Vec<Option<Symbol>>) = match cnum {

@petrochenkov petrochenkov Jul 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let (native_libs, filenames): (&Vec<NativeLib>, Vec<Option<Symbol>>) = match cnum {
let (native_libs, bundled_filenames): (&Vec<NativeLib>, Vec<Option<Symbol>>) = match cnum {

View changes since the review

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 3, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 3, 2026
Move NativeLib::filename to the rmeta-link archive member
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 3, 2026
@rust-bors

rust-bors Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 2f75410 (2f7541075058da7aa2a74d202935f2d3b0e07464)
Base parent: c397dae (c397dae808f70caebab1fc4e11b3edf7e59f58c7)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (2f75410): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (secondary -2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.8% [-6.4%, -2.6%] 4
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 485.944s -> 486.779s (0.17%)
Artifact size: 393.37 MiB -> 393.32 MiB (-0.01%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Jul 3, 2026
@mehdiakiki

Copy link
Copy Markdown
Contributor Author

Resolved the conflicts
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants