Skip to content

Fixed Compilation::deps_output only taking the last dep#17164

Merged
epage merged 2 commits into
rust-lang:masterfrom
ranger-ross:overwritten-deps
Jul 1, 2026
Merged

Fixed Compilation::deps_output only taking the last dep#17164
epage merged 2 commits into
rust-lang:masterfrom
ranger-ross:overwritten-deps

Conversation

@ranger-ross

Copy link
Copy Markdown
Member

What does this PR try to resolve?

This PR fixes a bug in the compilation logic that causes the compilation.dep_output being overwritten instead of appending the directories. (HashMap::insert called in a loop, causing only the last element to be added)

This is normally not reachable for most uses as dylibs are uplifted, so the uplifted dylibs usually land on the search path masking the bug. I believe its only a problem when __CARGO_DEFAULT_LIB_METADATA=1 is set as the metadata hash causing the bin or test to fail to find the dylib if there are more than one.

Reported in rust-lang/rust#158526

I guess this will further put pressure on the Windows PATH, it seems necessary for correctness. :-(

How to test and review this PR?

The change is fairly straight forward, just make the hashmap value a set so it could hold multiple paths.
I added a regression test that verifies cargo test runs for a crate with multiple dylibs.

cc: @yuzibo @HNO3Miracle (would appreciate if you would be able check if this change fixes your issue reported in rust-lang/rust#158526)

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 1, 2026
@rustbot

rustbot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

r? @epage

rustbot has assigned @epage.
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: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@epage epage enabled auto-merge July 1, 2026 16:52
@epage epage added this pull request to the merge queue Jul 1, 2026
@HNO3Miracle

Copy link
Copy Markdown
Contributor

Yes, this fixes the root cause of rust-lang/rust#158526 from my side.

I tested that locally with:

cargo test --test testsuite dylib_deps_output_overwrite -- --nocapture
cargo test --test testsuite dylib_deps_output -- --nocapture

Both passed.

The new dylib_deps_output_overwrite test uses -Zbuild-dir-new-layout and __CARGO_DEFAULT_LIB_METADATA=1, and it exercises two dylib dependencies at runtime, which matches the failure mode we hit in rust bootstrap. I have not rerun the full rust-lang/rust stage2 suite with this Cargo commit, but the targeted regression test covers the issue.

And rust-lang/rust#158530 would be closed. Thanks for your review!

Merged via the queue into rust-lang:master with commit 23ad0b2 Jul 1, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 1, 2026
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 2, 2026
Update cargo submodule

13 commits in a335d47ff8036918d3d548dabd513dc0444096a9..f40cc7a13a8ebe3dd0a35b1e0e37a1e26c8bb0e5
2026-06-26 20:39:41 +0000 to 2026-07-01 18:57:21 +0000
- chore(deps): update rust crate gix to 0.85.0 (rust-lang/cargo#17159)
- Fixed `Compilation::deps_output` only taking the last dep (rust-lang/cargo#17164)
- chore(deps): update taiki-e/install-action action to v2.82.7 (rust-lang/cargo#17163)
- chore(deps): update rust crate rusqlite to 0.40.0 (rust-lang/cargo#17162)
- chore(deps): update rust crate itertools to 0.15.0 (rust-lang/cargo#17160)
- chore(deps): update compatible (rust-lang/cargo#17156)
- chore(deps): update crate-ci/typos action to v1.48.0 (rust-lang/cargo#17158)
- chore(deps): update alpine docker tag to v3.24 (rust-lang/cargo#17157)
- chore(deps): update actions/checkout action to v6.0.3 (rust-lang/cargo#17155)
- chore: upgrade to [email protected] (rust-lang/cargo#17152)
- test(help): Don't hang on Mac with a custom man pager (rust-lang/cargo#17151)
- docs(lints): Add a false-positive example solution (rust-lang/cargo#17147)
- docs(lints): Reduce the superfluous whitespace by grouping bullet items (rust-lang/cargo#17146)

r? ghost
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 2, 2026
Update cargo submodule

13 commits in a335d47ff8036918d3d548dabd513dc0444096a9..f40cc7a13a8ebe3dd0a35b1e0e37a1e26c8bb0e5
2026-06-26 20:39:41 +0000 to 2026-07-01 18:57:21 +0000
- chore(deps): update rust crate gix to 0.85.0 (rust-lang/cargo#17159)
- Fixed `Compilation::deps_output` only taking the last dep (rust-lang/cargo#17164)
- chore(deps): update taiki-e/install-action action to v2.82.7 (rust-lang/cargo#17163)
- chore(deps): update rust crate rusqlite to 0.40.0 (rust-lang/cargo#17162)
- chore(deps): update rust crate itertools to 0.15.0 (rust-lang/cargo#17160)
- chore(deps): update compatible (rust-lang/cargo#17156)
- chore(deps): update crate-ci/typos action to v1.48.0 (rust-lang/cargo#17158)
- chore(deps): update alpine docker tag to v3.24 (rust-lang/cargo#17157)
- chore(deps): update actions/checkout action to v6.0.3 (rust-lang/cargo#17155)
- chore: upgrade to [email protected] (rust-lang/cargo#17152)
- test(help): Don't hang on Mac with a custom man pager (rust-lang/cargo#17151)
- docs(lints): Add a false-positive example solution (rust-lang/cargo#17147)
- docs(lints): Reduce the superfluous whitespace by grouping bullet items (rust-lang/cargo#17146)

r? ghost
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 3, 2026
Update cargo submodule

13 commits in a335d47ff8036918d3d548dabd513dc0444096a9..f40cc7a13a8ebe3dd0a35b1e0e37a1e26c8bb0e5
2026-06-26 20:39:41 +0000 to 2026-07-01 18:57:21 +0000
- chore(deps): update rust crate gix to 0.85.0 (rust-lang/cargo#17159)
- Fixed `Compilation::deps_output` only taking the last dep (rust-lang/cargo#17164)
- chore(deps): update taiki-e/install-action action to v2.82.7 (rust-lang/cargo#17163)
- chore(deps): update rust crate rusqlite to 0.40.0 (rust-lang/cargo#17162)
- chore(deps): update rust crate itertools to 0.15.0 (rust-lang/cargo#17160)
- chore(deps): update compatible (rust-lang/cargo#17156)
- chore(deps): update crate-ci/typos action to v1.48.0 (rust-lang/cargo#17158)
- chore(deps): update alpine docker tag to v3.24 (rust-lang/cargo#17157)
- chore(deps): update actions/checkout action to v6.0.3 (rust-lang/cargo#17155)
- chore: upgrade to [email protected] (rust-lang/cargo#17152)
- test(help): Don't hang on Mac with a custom man pager (rust-lang/cargo#17151)
- docs(lints): Add a false-positive example solution (rust-lang/cargo#17147)
- docs(lints): Reduce the superfluous whitespace by grouping bullet items (rust-lang/cargo#17146)

r? ghost
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 3, 2026
Update cargo submodule



13 commits in a335d47ff8036918d3d548dabd513dc0444096a9..f40cc7a13a8ebe3dd0a35b1e0e37a1e26c8bb0e5
2026-06-26 20:39:41 +0000 to 2026-07-01 18:57:21 +0000
- chore(deps): update rust crate gix to 0.85.0 (rust-lang/cargo#17159)
- Fixed `Compilation::deps_output` only taking the last dep (rust-lang/cargo#17164)
- chore(deps): update taiki-e/install-action action to v2.82.7 (rust-lang/cargo#17163)
- chore(deps): update rust crate rusqlite to 0.40.0 (rust-lang/cargo#17162)
- chore(deps): update rust crate itertools to 0.15.0 (rust-lang/cargo#17160)
- chore(deps): update compatible (rust-lang/cargo#17156)
- chore(deps): update crate-ci/typos action to v1.48.0 (rust-lang/cargo#17158)
- chore(deps): update alpine docker tag to v3.24 (rust-lang/cargo#17157)
- chore(deps): update actions/checkout action to v6.0.3 (rust-lang/cargo#17155)
- chore: upgrade to [email protected] (rust-lang/cargo#17152)
- test(help): Don't hang on Mac with a custom man pager (rust-lang/cargo#17151)
- docs(lints): Add a false-positive example solution (rust-lang/cargo#17147)
- docs(lints): Reduce the superfluous whitespace by grouping bullet items (rust-lang/cargo#17146)

r? ghost
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Jul 5, 2026
Update cargo submodule



13 commits in a335d47ff8036918d3d548dabd513dc0444096a9..f40cc7a13a8ebe3dd0a35b1e0e37a1e26c8bb0e5
2026-06-26 20:39:41 +0000 to 2026-07-01 18:57:21 +0000
- chore(deps): update rust crate gix to 0.85.0 (rust-lang/cargo#17159)
- Fixed `Compilation::deps_output` only taking the last dep (rust-lang/cargo#17164)
- chore(deps): update taiki-e/install-action action to v2.82.7 (rust-lang/cargo#17163)
- chore(deps): update rust crate rusqlite to 0.40.0 (rust-lang/cargo#17162)
- chore(deps): update rust crate itertools to 0.15.0 (rust-lang/cargo#17160)
- chore(deps): update compatible (rust-lang/cargo#17156)
- chore(deps): update crate-ci/typos action to v1.48.0 (rust-lang/cargo#17158)
- chore(deps): update alpine docker tag to v3.24 (rust-lang/cargo#17157)
- chore(deps): update actions/checkout action to v6.0.3 (rust-lang/cargo#17155)
- chore: upgrade to [email protected] (rust-lang/cargo#17152)
- test(help): Don't hang on Mac with a custom man pager (rust-lang/cargo#17151)
- docs(lints): Add a false-positive example solution (rust-lang/cargo#17147)
- docs(lints): Reduce the superfluous whitespace by grouping bullet items (rust-lang/cargo#17146)

r? ghost
@rustbot rustbot added this to the 1.98.0 milestone Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants