2

When I run

rustup target install wasm32-unknown-unknown

it states

info: downloading component 'rust-std' for 'wasm32-unknown-unknown'

This means that prebuilt binary components are being downloaded. Where is the source code of these components?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
sailing
  • 55
  • 4
  • You can find the source code of the Rust standard library [on GitHub](https://github.com/rust-lang/rust/tree/master/library/std). – Jesper Apr 06 '21 at 10:11

1 Answers1

5

You can install the rust-src rustup component for a toolchain, which will be located in $RUSTUP_INSTALLATION_DIRECTORY/toolchains/$TOOLCHAIN/lib/rustlib/src/rust.

This is the command:

rustup install rust-lang source code 

The official source code for the Rust project is on GitHub at https://github.com/rust-lang/rust/. The standard library is currently located in the library/std subdirectory, although this has changed over time.

See also:

mike rodent
  • 14,126
  • 11
  • 103
  • 157
Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
  • I got the lastest package for wasm32-unknown-unknown from [https://static.rust-lang.org/dist/channel-rust-stable.toml](https://static.rust-lang.org/dist/channel-rust-stable.toml,), and I found that they are all *.rlib. What should I do to compile these .rlib files by myself? – sailing Apr 16 '21 at 10:46
  • @sailing Assuming you mean "how do I compile *using* these rlibs", practically, you don't; you probably want to cross-compile. See [Can I install a library using Cargo without a Cargo.toml?](https://stackoverflow.com/q/36813893/155423) for steps to a technically correct answer. If you literally mean what you said, (a.k.a. how do you create them) you'd need to look at the `build-std` feature of Cargo. – Shepmaster Apr 22 '21 at 17:35