compiler-explorer
compiler-explorer copied to clipboard
Rust Crate support
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.
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.
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 👍
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)
Oh, there's actually something wrong with our buildprocess as well
1.62 crates should be there now
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.
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?
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