Skip to content

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

Closed
@Arnavion

Description

@Arnavion

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions