mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
4c21a3bc2a
Ever since we added a Cargo-based build system for the compiler the
standard library has always been a little special, it's never been able
to depend on crates.io crates for runtime dependencies. This has been a
result of various limitations, namely that Cargo doesn't understand that
crates from crates.io depend on libcore, so Cargo tries to build crates
before libcore is finished.
I had an idea this afternoon, however, which lifts the strategy
from #52919 to directly depend on crates.io crates from the standard
library. After all is said and done this removes a whopping three
submodules that we need to manage!
The basic idea here is that for any crate `std` depends on it adds an
*optional* dependency on an empty crate on crates.io, in this case named
`rustc-std-workspace-core`. This crate is overridden via `[patch]` in
this repository to point to a local crate we write, and *that* has a
`path` dependency on libcore.
Note that all `no_std` crates also depend on `compiler_builtins`, but if
we're not using submodules we can publish `compiler_builtins` to
crates.io and all crates can depend on it anyway! The basic strategy
then looks like:
* The standard library (or some transitive dep) decides to depend on a
crate `foo`.
* The standard library adds
```toml
[dependencies]
foo = { version = "0.1", features = ['rustc-dep-of-std'] }
```
* The crate `foo` has an optional dependency on `rustc-std-workspace-core`
* The crate `foo` has an optional dependency on `compiler_builtins`
* The crate `foo` has a feature `rustc-dep-of-std` which activates these
crates and any other necessary infrastructure in the crate.
A sample commit for `dlmalloc` [turns out to be quite simple][commit].
After that all `no_std` crates should largely build "as is" and still be
publishable on crates.io! Notably they should be able to continue to use
stable Rust if necessary, since the `rename-dependency` feature of Cargo
is soon stabilizing.
As a proof of concept, this commit removes the `dlmalloc`,
`libcompiler_builtins`, and `libc` submodules from this repository. Long
thorns in our side these are now gone for good and we can directly
depend on crates.io! It's hoped that in the long term we can bring in
other crates as necessary, but for now this is largely intended to
simply make it easier to manage these crates and remove submodules.
This should be a transparent non-breaking change for all users, but one
possible stickler is that this almost for sure breaks out-of-tree
`std`-building tools like `xargo` and `cargo-xbuild`. I think it should
be relatively easy to get them working, however, as all that's needed is
an entry in the `[patch]` section used to build the standard library.
Hopefully we can work with these tools to solve this problem!
[commit]: 28ee12db81
61 lines
2.1 KiB
Plaintext
61 lines
2.1 KiB
Plaintext
[submodule "src/llvm"]
|
|
path = src/llvm
|
|
url = https://github.com/rust-lang/llvm.git
|
|
branch = master
|
|
[submodule "src/rust-installer"]
|
|
path = src/tools/rust-installer
|
|
url = https://github.com/rust-lang/rust-installer.git
|
|
[submodule "src/doc/nomicon"]
|
|
path = src/doc/nomicon
|
|
url = https://github.com/rust-lang-nursery/nomicon.git
|
|
[submodule "src/tools/cargo"]
|
|
path = src/tools/cargo
|
|
url = https://github.com/rust-lang/cargo.git
|
|
[submodule "src/doc/reference"]
|
|
path = src/doc/reference
|
|
url = https://github.com/rust-lang-nursery/reference.git
|
|
[submodule "src/doc/book"]
|
|
path = src/doc/book
|
|
url = https://github.com/rust-lang/book.git
|
|
[submodule "src/tools/rls"]
|
|
path = src/tools/rls
|
|
url = https://github.com/rust-lang-nursery/rls.git
|
|
[submodule "src/tools/clippy"]
|
|
path = src/tools/clippy
|
|
url = https://github.com/rust-lang-nursery/rust-clippy.git
|
|
[submodule "src/tools/rustfmt"]
|
|
path = src/tools/rustfmt
|
|
url = https://github.com/rust-lang-nursery/rustfmt.git
|
|
[submodule "src/tools/miri"]
|
|
path = src/tools/miri
|
|
url = https://github.com/solson/miri.git
|
|
[submodule "src/doc/rust-by-example"]
|
|
path = src/doc/rust-by-example
|
|
url = https://github.com/rust-lang/rust-by-example.git
|
|
[submodule "src/llvm-emscripten"]
|
|
path = src/llvm-emscripten
|
|
url = https://github.com/rust-lang/llvm.git
|
|
[submodule "src/stdsimd"]
|
|
path = src/stdsimd
|
|
url = https://github.com/rust-lang-nursery/stdsimd.git
|
|
[submodule "src/tools/lld"]
|
|
path = src/tools/lld
|
|
url = https://github.com/rust-lang/lld.git
|
|
[submodule "src/libbacktrace"]
|
|
path = src/libbacktrace
|
|
url = https://github.com/rust-lang-nursery/libbacktrace.git
|
|
[submodule "src/tools/lldb"]
|
|
path = src/tools/lldb
|
|
url = https://github.com/rust-lang-nursery/lldb.git
|
|
branch = rust-release-80-v2
|
|
[submodule "src/tools/clang"]
|
|
path = src/tools/clang
|
|
url = https://github.com/rust-lang-nursery/clang.git
|
|
branch = rust-release-80-v2
|
|
[submodule "src/doc/rustc-guide"]
|
|
path = src/doc/rustc-guide
|
|
url = https://github.com/rust-lang/rustc-guide.git
|
|
[submodule "src/doc/edition-guide"]
|
|
path = src/doc/edition-guide
|
|
url = https://github.com/rust-lang-nursery/edition-guide
|