compiler-explorer icon indicating copy to clipboard operation
compiler-explorer copied to clipboard

Rust Crate support

Open partouf opened this issue 2 years ago • 5 comments

A list of the available Crate binaries: https://conan.compiler-explorer.com/libraries_rust.html

Some notes:

  • Rust libraries are supported through pre-built binaries for the default platform x86_64.
  • None of the libraries are available for other platforms, and they will not be built automatically.
  • We have not tested all the libraries. If anything seems out of the ordinary, let us know so that we can investigate.
  • Be sure to select the library you want to use and then also use extern crate cratename; in your code

The crate binaries are mostly built by Cargo with the --all-features option. This means that either the create successfully built with all features are enabled, or it failed to build and the crate is not available. We have a limited selection of crates without any features enabled because --all-features failed to build, but not yet consistently.

partouf avatar Jun 11 '22 16:06 partouf

Thanks a lot for this!

Be sure to select the library you want to use and then also use extern crate cratename; in your code

Or compile with --edition=2021 instead (or --edition=2018). Maybe this should be the default: https://github.com/compiler-explorer/compiler-explorer/issues/3765.

I also noticed the crates do not seem to be available in nightly nor beta: https://github.com/compiler-explorer/compiler-explorer/issues/3766.

ojeda avatar Jun 11 '22 17:06 ojeda

I hit a somewhat confusing issue: I tried using rand on CE, got to discover the libraries feature (I'd never used it before), enabled rand, and... it kept failing with messages like

error[E0432]: unresolved import `rand`
 --> <source>:4:5
  |
4 | use rand::random;
  |    ^^^^ maybe a missing crate `rand`?

or

error: extern location for rand does not exist: rand/build/debug/librand.rlib
 --> <source>:4:5

Turns out the issue is the libraries feature currently does not work at all for 1.62 (I assume the crates haven't been built / rebuilt for it?), 1.61 works.

Also maybe some help / assistance could be provided when the error is E0432 or whatever mess the second one is? Not sure if it's possible to easily get this information in a programmatic form from the compiler though.

Aside from these, it seems to work well 👍

masklinn avatar Jul 12 '22 15:07 masklinn

The 1.62 version for rand has indeed not been built. This is mainly because of --all-features - we might have to see if we can switch it off for rand. (the 1.61 was built and uploaded manually as rand was one of the first libraries I tried out)

partouf avatar Jul 12 '22 15:07 partouf

Oh, there's actually something wrong with our buildprocess as well

partouf avatar Jul 12 '22 16:07 partouf

1.62 crates should be there now

partouf avatar Jul 13 '22 18:07 partouf

Noting for anyone from Google - Using rustc 1.62 still works for using the top 100 crates.

Since this is still an active issue, it should also be noted that we unfortunately can't use any nightly or unstable features (like std::hint::black_box) with external crates.

chrismooredev avatar Dec 23 '22 21:12 chrismooredev

Currently, crates work only for Rust 1.62 and this behavior is not documented apart from this issue, which makes it hard to discover, and makes using extern crates very cumbersome. Is it the intended behavior?

krtab avatar Aug 10 '23 14:08 krtab

Currently, crates work only for Rust 1.62 and this behavior is not documented apart from this issue, which makes it hard to discover, and makes using extern crates very cumbersome. Is it the intended behavior?

its just broken, its being discussed here https://github.com/compiler-explorer/compiler-explorer/issues/4404

partouf avatar Aug 10 '23 14:08 partouf