Closed
Description
Problem
When running cargo rustc --crate-type cdylib -Z unstable-options
, I see errors that dependencies were expected to be available in rlib
format. If I put the crate-type in the Cargo.toml
, I don't see these errors.
Output:
~/code/test.rs $ cargo rustc --crate-type cdylib -Z unstable-options
Compiling scratchpad v0.0.0 (/home/sean/code/test.rs)
error: crate `http` required to be available in rlib format, but was not found in this form
Steps
Here's a minimal repro:
- Make a new crate, using any simple dependency.
http = "*"
works. - In
lib.rs
, addpub extern "C" fn yeet() { println!("{:?}", http::StatusCode::OK) }
. - Run
cargo rustc --crate-type cdylib -Z unstable-options
.
I originally discovered this by trying to convert hyper to use it:
- Removing the
[lib]
andcrate-type = ["cdylib", "staticlib", "lib"]
lines. - Run
cargo rustc --crate-type cdylib -Z unstable-options
.
Possible Solution(s)
No response
Notes
- If I keep the line in
Cargo.toml
, then hyper builds properly. - When making a minimal repro, I noticed that it works without a dependency, and it also works with a dependency that isn't used. You must use the dependency in the file.
Version
cargo 1.60.0-nightly (25fcb13 2022-02-01)
release: 1.60.0-nightly
commit-hash: 25fcb135d02ea897ce894b67ae021f48107d522b
commit-date: 2022-02-01
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Ubuntu 16.04 (xenial) [64-bit]