-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dylib crate fails to compile #138339
Comments
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. |
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
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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 |
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 [build]
rustflags = ["-C", "prefer-dynamic"] |
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. |
bisects to #83070 -> rust-lang/cargo#9252
The demo does indeed build fine when the package is explicitly specified ( > cargo clean
> cargo build # doesn't work, as shown in OP
Compiling engine v0.1.0 (..)
Compiling editor v0.1.0 (..)
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: could not compile `editor` (bin "editor") due to 13 previous errors
> cargo build -p editor # still doesn't work
Compiling editor v0.1.0 (H:\work\my\trash\rust-mini\demo\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: could not compile `editor` (bin "editor") due to 13 previous errors
# however if we don't run the "wrong" command, then:
> cargo clean
> cargo build -p editor # succeeds now
Compiling engine v0.1.0 (...)
Compiling editor v0.1.0 (....)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.76s 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 |
Thank you! I tried this, and it works now. |
I tried this code and run: demo.zip
Code
lib.rs
cargo.toml
main.rs
cargo.toml
workspace.cargo.toml
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
Tools
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: