2

Looking at some crates in https://crates.io/ I found that rand is the most downloaded crate and looking in it's dependencies I found the libc crate and in it's dependencies I found the rustc-std-workspace-core which has 0 dependencies with this description: "Explicitly empty crate for rust-lang/rust integration". I could not totally undestand what it means. Can someone explain in more details?

Michael Pacheco
  • 948
  • 1
  • 17
  • 25
  • 1
    The [README](https://github.com/rust-lang/rust/blob/master/library/rustc-std-workspace-core/README.md) file for the crate in the Rust repo provides a bit of additional context: _"Crates on crates.io that the standard library depend on need to depend on the rustc-std-workspace-core crate from crates.io, which is empty. We use [patch] to override it to this crate in this repository. As a result, crates on crates.io will draw a dependency edge to libcore, the version defined in this repository. That should draw all the dependency edges to ensure Cargo builds crates successfully!"_ – Brian61354270 May 31 '22 at 23:09
  • "This crate is a shim and empty crate which simply depends on libcore and reexports all of its contents" what is this libcore? I couldn't find any crate with this name – Michael Pacheco May 31 '22 at 23:48
  • 1
    `libcore`, or `core`, is the name of the crate that includes everything that is essential for Rust code and some more, and doesn't require an Operating System. It is like `std` but more primitive. – Chayim Friedman Jun 01 '22 at 00:14
  • But why can't I find then in crates.io? – Michael Pacheco Jun 01 '22 at 15:55
  • @MichaelPacheco You can't find what? – Chayim Friedman Jun 01 '22 at 18:42
  • The `libcore` and `core` crates. If you search for them in crates.io it will not return them. https://crates.io/search?q=libcore https://crates.io/search?q=core – Michael Pacheco Jun 02 '22 at 12:25

1 Answers1

2

std depends on the libc crate.

Being a dependency of std is... not easy. The way std is built is complicated, it is tightly coupled with the compiler and built with it twice, for bootstrapping.

You can see this dependency is only activated if the rustc-dep-of-std feature is enabled.

This dependency allows std to depend on crates.

See also Plan for removal of rustc-dep-of-std.

Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77