rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

Cannot use `#[lang = "start"]` on playground

Open jyn514 opened this issue 5 years ago • 2 comments

I am shocked - shocked! - to find that no one has tried this before. https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=08a07ced4b7ba6afcdf8a4bd68487015

error[E0152]: found duplicate lang item `start`
 --> src/lib.rs:7:1
  |
7 | fn _start() {
  | ^^^^^^^^^^^
  |
  = note: the lang item is first defined in crate `std`.
  = note: first definition in `std` loaded from /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7edd956e9d8d05ea.rlib
  = note: second definition in the local crate (`playground`)

I expect you're passing --extern std=/playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-7edd956e9d8d05ea.rlib or something like that. I don't have suggestions for fixing it, this is just to vex you that sysroots are painful. Others must share my pain!!

jyn514 avatar Nov 18 '20 05:11 jyn514

Same for lang items in core:

error[E0152]: found duplicate lang item `sized`
  --> src/lib.rs:14:1
   |
14 | trait X {}
   | ^^^^^^^^^^
   |
   = note: the lang item is first defined in crate `core` (which `std` depends on)
   = note: first definition in `core` loaded from /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-2675a9a46b5cec89.rlib
   = note: second definition in the local crate (`playground`)

jyn514 avatar Nov 18 '20 05:11 jyn514

This is probably due to fact that playground has hundreds of crates that are always available and at least one of those crates links to the standard library.

I’ve seen similar errors outside the playground when trying to do no-std work but something accidentally brought in std.

shepmaster avatar Nov 18 '20 12:11 shepmaster