-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-cratesArea: Crates and their interactions (like crate loading)Area: Crates and their interactions (like crate loading)A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-cargoRelevant to the cargo team, which will review and decide on the PR/issue.Relevant to the cargo team, which will review and decide on the PR/issue.
Description
I tried this code and run: demo.zip
Code
cargo run dev
Engine
lib.rs
pub fn run () {
println!("Hello from engine");
}
cargo.toml
[package]
name = "engine"
version = "0.1.0"
edition = "2024"
[dependencies]
[lib]
crate-type = ["dylib"]
Editor
main.rs
extern crate engine;
fn main() {
engine::run();
println!("Hello from editor");
}
cargo.toml
[package]
name = "editor"
version = "0.1.0"
edition = "2024"
[dependencies]
engine = {path = "../engine"}
workspace.cargo.toml
[workspace]
resolver = "2"
members = [ "editor","engine"]
I expected the dylib crate to work correctly as a dependency, allowing the binary to dynamically link to it and run without issues.
Instead, this happened:
Details
PS C:\Users\{}\Documents\Rust\development> cargo run dev
Compiling editor v0.1.0 (C:\Users\compl\Documents\Rust\development\editor)
error: cannot satisfy dependencies so `engine` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
= note: `engine` was unavailable as a static crate, preventing fully static linking
error: cannot satisfy dependencies so `core` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `alloc` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `compiler_builtins` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `rustc_std_workspace_core` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `unwind` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `cfg_if` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `hashbrown` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `rustc_std_workspace_alloc` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `std_detect` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `rustc_demangle` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `windows_targets` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: cannot satisfy dependencies so `panic_unwind` only shows up once
|
= help: having upstream crates all available in one format will likely make this go away
error: could not compile `editor` (bin "editor") due to 13 previous errors
Tools
rustc --version --verbose
:
rustc 1.87.0-nightly (9fb94b32d 2025-03-10)
binary: rustc
commit-hash: 9fb94b32df38073bf63d009df77ed10cb1c989d0
commit-date: 2025-03-10
host: x86_64-pc-windows-msvc
release: 1.87.0-nightly
LLVM version: 20.1.0
Metadata
Metadata
Assignees
Labels
A-cratesArea: Crates and their interactions (like crate loading)Area: Crates and their interactions (like crate loading)A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.S-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-cargoRelevant to the cargo team, which will review and decide on the PR/issue.Relevant to the cargo team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Noratrieb commentedon Mar 11, 2025
Thank you for the report! It would be useful to bisect the regression using cargo-bisect-rustc to make it easier to figure out what happened and ping the relevant people.
@rustbot label E-needs-bisection
moxian commentedon Mar 11, 2025
cargo-bisect-rustc output attached, but I appear to be too tired to intelligently triage it myself right now:
take2:
old incorrect bisection attempt. don't look
bjorn3 commentedon Mar 11, 2025
moxian commentedon Mar 11, 2025
Dotnet-x86 commentedon Mar 11, 2025
Still running
cargo bisect-rustc
but haven't found a working version yet.tgross35 commentedon Mar 11, 2025
Do you know this worked in a previous version? If not then you probably don't have to hunt for a working version, it may never have built correctly. If so, then you should be able to pass that version to cargo-bisect-rustc with
--start
.ChrisDenton commentedon Mar 11, 2025
The issue is you're mixing the static standard library with the dynamic standard library. You always need to use either one or the other.
If you want the dynamic version then add the rustflag
-C prefer-dynamic
. To do this, create the file.cargo/config.toml
and add this to it:ChrisDenton commentedon Mar 11, 2025
The demo did used to "just work" way back in 1.51 but I don't know why. Quite possibly 1.52 fixed a bug where duplicates weren't being detected.
moxian commentedon Mar 11, 2025
bisects to #83070 -> rust-lang/cargo#9252
The demo does indeed build fine when the package is explicitly specified (
cargo build -p editor
).Although... with caveats:
This statefulness and "build poisoning" is at leastsomewhat surprising, and I see no easy way to get ourselves out of the "broken" state sans a full rebuild.
@rustbot label: -E-needs-bisection +S-has-bisection +T-cargo -T-compiler +A-linkage
Dotnet-x86 commentedon Mar 12, 2025
Thank you! I tried this, and it works now.