12

I've seen rustup be referred to as a "toolchain installer", but it's hard to find an exact definition of what Rust considers a "toolchain" to be and what the scope is for the concept.

I already have the Rust compiler and Cargo installed. What more does rustup bring? Is it just a Rust-version-switcher?


As a .NET-developer, maybe there is there a parallel which makes it easier for me to grasp this concept?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Seb Nilsson
  • 26,200
  • 30
  • 103
  • 130
  • 2
    A terse definition is given in the [rustup README.md on Github](https://github.com/rust-lang/rustup#toolchain-specification): _"Many rustup commands deal with toolchains, a single installation of the Rust compiler. rustup supports multiple types of toolchains. The most basic track the official release channels: stable, beta and nightly; but rustup can also install toolchains from the official archives, for alternate host platforms, and from local builds."_I don't know if an exact definition exists, behind the generic notion of a [software toolchain](https://en.wikipedia.org/wiki/Toolchain) – Brian61354270 Jun 16 '20 at 21:00
  • 1
    You can run `rustup toolchain list` which in my case prints `stable-x86_64-unknown-linux-gnu (default)`. So you can think of the toolchain as a specific version of the compiler, the standard library and the accompanying tools such as clippy, cargo, etc – Svetlin Zarev Jun 16 '20 at 21:12

1 Answers1

18

A toolchain is a specific version of the collection of programs needed to compile a Rust application. It includes, but is not limited to:

  • The compiler, rustc
  • The dependency manager and build tool, cargo
  • The documentation generator, rustdoc
  • The static and/or dynamic libraries comprising the standard library for the default platform

There are additional components that can be installed, such as

  • Documentation
    • The Rust Programming Language
    • The standard library
    • Various books and references
  • The static and/or dynamic libraries comprising the standard library for additional platforms to cross-compile to
  • The source code for the standard library
  • Extra utilities
    • Code formatting via rustfmt
    • Extra lints via clippy
    • Undefined behavior checking via miri
    • Advanced editor support via rust-analyzer or the Rust Language Server

Rustup provides ways to install, remove, update, select and otherwise manage these toolchains and their associated pieces.

See also:

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
  • 1
    The linker is also part of the toolchain. It's significant enough to include in the list. – IInspectable Jun 17 '20 at 15:41
  • @IInspectable can you point me to which platforms rustup installs a linker for? My understanding is that Rust relies on the system linker (which is why you also have to install a C toolchain). – Shepmaster Jun 17 '20 at 15:45
  • That's my understanding too, but @linspectable's point is well taken, even if it's only to explain that this is one part that rustup doesn't handle. Especially since it can get messy when you're cross compiling. – dlu Feb 20 '21 at 00:17