Skip to content

Conversation

tommantonclery
Copy link

Fixes #16000.

When running cargo test --no-run on a proc-macro crate with a dev-dependency on a dylib, Cargo was incorrectly passing -C prefer-dynamic to the test harness.

That caused rustc to try to link both rlib and dylib forms of std and its transitive crates, resulting in errors like:

error: cannot satisfy dependencies so `std` only shows up once

What changed

  • Adjusted the logic in core/compiler so that -C prefer-dynamic is only applied when compiling an actual proc-macro crate.
  • Test harnesses (even for proc-macro crates) no longer receive -C prefer-dynamic.

Why

This resolves the duplicate std/core/alloc linkage errors and makes cargo test --no-run consistent with cargo build.

@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 Sep 30, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 30, 2025

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

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 30, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 30, 2025
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 S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo test fails to build when downstream crate declares crate-type = ["rlib", "dylib"]
3 participants