Skip to content

Can't compile crate that depends on a crate that depends on a proc_macro crate #37839

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Arnavion opened this issue Nov 17, 2016 · 3 comments
Closed
Assignees

Comments

@Arnavion
Copy link

Arnavion commented Nov 17, 2016

Windows 7 x64, with rust msvc compiled at 0172e46 as well as rustc 1.15.0-nightly (ba872f2 2016-11-17)

It seems a bin/lib crate that depends on a lib crate that in turn depends on a proc macro crate doesn't compile because rustc complains that the proc macro crate was compiled as a dylib.

I have a proc macro crate foo, a lib crate bar that depends on foo, and a bin crate baz that depends on bar. bar compiles fine and generates libbar.rlib, but baz fails to compile with:

error[E0462]: found staticlib `foo` instead of rlib or dylib which `bar` depends on
  --> src\main.rs:1:1
  |
1 | extern crate bar;
  | ^^^^^^^^^^^^^^^^^
  |
  = help: please recompile that crate using --crate-type lib
  = note: crate `foo` path #1: C:\Stuff\Sources\baz\target\debug\deps\foo-7f298898a71a7d96.dll.lib

Repro: https://github.com/Arnavion/rust-37839 Run cargo build under baz/


On Linux, since only a .so is generated (no .lib equivalent), the error is different but the cause is presumably the same.

error[E0463]: can't find crate for `foo` which `bar` depends on
 --> src/main.rs:1:1
  |
1 | extern crate bar;
  | ^^^^^^^^^^^^^^^^^ can't find crate

Note again that this error is when compiling baz. There is no problem when compiling bar.

@alexcrichton
Copy link
Member

This appears to be a regression in the range cae6ab1...0ed9519

cc @jseyfried any ideas?

@alexcrichton
Copy link
Member

Note that this isn't Windows-specific, I've reproduced on Linux.

@jseyfried
Copy link
Contributor

This was caused by #37542 -- should have used kind here (like this) instead of PathKind::Crate.
Fixed in #37846.

bors added a commit that referenced this issue Nov 18, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants