Open lylythechosenone opened 2 weeks ago
To make this more concrete, the only thing missing is an ability to fetch the rust-src
component (as it is in rustup) along with a given toolchain. This was possible with rust_repositories
, but does not seem to be possible with newer versions of rules_rust
. Once those sources are available, it is as simple as making rust_library
targets, making a rust_stdlib_filegroup
, and creating a custom toolchain.
I have created a proof-of-concept exposing this component in lylythechosenone/rules_rust. It seems to work correctly. However, downloading rust_src
is useless for most users, so it would be nice to make it optional. I'll await a contributor's response on how exactly to do that.
After playing with this a bit, it seems like more components would be needed. rust_toolchain_repository
and rust_toolchain
both take an exec_triple
field, and it seems like it would be quite difficult to determine the exec triple in a MODULE
file. It would be nice to contain this all inside of rules_rust
in a simple build_std
flag on rust_toolchain_repository
or register_rust_toolchains
. I may make another proof-of-concept implementing this soon, but I very much want contributor input on this issue.
@krasimirgg I think you have experience of bootstrapping a libstd with rules_rust, right?
Goals
Build libcore, liballoc, and their dependencies from source using
rules_rust
, preferably with bzlmod.Reasoning
When compiling to bare-metal targets, as well as custom targets, one is required to recompile the standard library from source. Currently, this is not well-supported by
rules_rust
.Prior art
In bazel-rust-cross, @colatkinson implemented this using
rust_repositories
, although that rule is now deprecated. In #2068, @daivinhtran made a first attempt at this, although it was quite bulky. It also manually downloaded the rust source files.