Skip to content
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

Can't find crate with hyper crate as a dependency #1705

Closed
saruman9 opened this issue Feb 10, 2021 · 4 comments · Fixed by #1710
Closed

Can't find crate with hyper crate as a dependency #1705

saruman9 opened this issue Feb 10, 2021 · 4 comments · Fixed by #1710
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-bug Category: This is a bug.

Comments

@saruman9
Copy link

MCVE

Cargo.toml:

[dependencies]
hyper = "0.14.4"

Error

...
Compiling hyper v0.14.4
error[E0463]: can't find crate for `http`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.4/src/lib.rs:61:9
   |
61 | pub use http;
   |         ^^^^ can't find crate

error: aborting due to previous error
@RalfJung RalfJung added A-cargo Area: affects the cargo wrapper (cargo miri) C-bug Category: This is a bug. labels Feb 10, 2021
@RalfJung
Copy link
Member

RalfJung commented Feb 10, 2021

Thanks for the report! I can reproduce this locally by adding hyper = "0.14.4" as a dependency to test-cargo-miri.

This has something to do with the tricks we pull to do a check-only-build (even when cargo instructs us to do a full build). When I disable those hacks and set XARGO_CHECK=xargo, the issue disappears.

@ghost
Copy link

ghost commented Feb 13, 2021

Copy and paste the --extern flag patching from phase_cargo_runner fixes it.

Looks like hyper is crate-type = ["lib", "staticlib", "cdylib"], so Cargo decided to pass --extern http=*.rlib instead of ---extern http=*.rmeta to the compiler, but the .rlib file is only a stub.

When compiling a normal library crate (--extern http=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libhttp-8f0bd6ee31f077df.rmeta):

   Compiling http-body v0.4.0
     Running `/my/home/directory/.cargo/bin/cargo-miri rustc --crate-name http_body --edition=2018 /my/home/directory/.cargo/registry/src/github.com-1ecc6299db9ec823/http-body-0.4.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=337265441ef817f9 -C extra-filename=-337265441ef817f9 --out-dir /my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -L dependency=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps -L dependency=/my/home/directory/test/target/debug/deps --extern bytes=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libbytes-1d5567e2f5a1134e.rmeta --extern http=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libhttp-8f0bd6ee31f077df.rmeta --cap-lints allow`

When compiling hyper (--extern http=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libhttp-8f0bd6ee31f077df.rlib):

   Compiling hyper v0.14.4
     Running `/my/home/directory/.cargo/bin/cargo-miri rustc --crate-name hyper --edition=2018 /my/home/directory/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --crate-type staticlib --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=e94fca59305eb7e5 -C extra-filename=-e94fca59305eb7e5 --out-dir /my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -L dependency=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps -L dependency=/my/home/directory/test/target/debug/deps --extern bytes=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libbytes-1d5567e2f5a1134e.rlib --extern futures_channel=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libfutures_channel-c72291d81e1388d0.rlib --extern futures_core=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libfutures_core-8f7fda7189341b19.rlib --extern futures_util=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libfutures_util-02a2f8b4ea5749fe.rlib --extern http=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libhttp-8f0bd6ee31f077df.rlib --extern http_body=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libhttp_body-337265441ef817f9.rlib --extern httparse=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libhttparse-ed6a4484bb6973e2.rlib --extern httpdate=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libhttpdate-2de7a2619b361c51.rlib --extern itoa=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libitoa-d2103d7afec2bb0a.rlib --extern pin_project=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libpin_project-78c29d1e79103c3b.rlib --extern tokio=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libtokio-1d8facee1ff9abd1.rlib --extern tower_service=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libtower_service-552fa253e40b0dce.rlib --extern tracing=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libtracing-11b8bc06a31d69ae.rlib --extern want=/my/home/directory/test/target/x86_64-unknown-linux-gnu/debug/deps/libwant-363c7da803b56a4f.rlib --cap-lints allow`

@RalfJung
Copy link
Member

Copy and paste the --extern flag patching from phase_cargo_runner fixes it.

Interesting, and good find!
#1671 moves that code into a helper function, so looks like we should just call that function in yet another place.

@RalfJung
Copy link
Member

@hyd-dev points out that a similar issue arises with a small modification of an existing testcase. Just leaving this note here to hopefully make sure a test is added for that as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo Area: affects the cargo wrapper (cargo miri) C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants