rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.35k stars 12.72k forks source link

rustc could provide more help for debugging no_std duplicate_lang item errors #60561

Closed brenzi closed 5 years ago

brenzi commented 5 years ago

I'm currently porting crates to support no_std to use them with https://github.com/baidu/rust-sgx-sdk

The Problem: any sub-dependency can break no_std, resulting in an error like this:

error: duplicate lang item in crate `std`: `f32_runtime`.
  |
  = note: first defined in crate `sgx_tstd`.

error: duplicate lang item in crate `std`: `f64_runtime`.
  |
  = note: first defined in crate `sgx_tstd`.

error: duplicate lang item in crate `std`: `panic_impl`.
  |
  = note: first defined in crate `sgx_tstd`.

error: duplicate lang item in crate `std`: `oom`.
  |
  = note: first defined in crate `sgx_trts`.

The compiler doesn't give me any hint, which (sub)dependency causes this issue. Like this it is very annoying and time-consuming to sort out such errors.

Would it be possible that rustc gives us a hint to colliding crates?

Maybe something like https://github.com/sfackler/cargo-tree could help visualizing no_std crates automatically?

BaoshanPang commented 5 years ago

I am seeing this problem too, it is really painful to figure out what's the problem.