9

I just installed Rust with rustup on MacOS and noticed that there are two rustc and two cargo binaries:

  • ~/.cargo/bin/rustc (cargo)
  • ~/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rustc (cargo)

Their versions are exactly the same, but diff shows there exists some difference. So why are there two different rustc (cargo) binaries and which one should I use?

kmdreko
  • 42,554
  • 6
  • 57
  • 106
Zizheng Tai
  • 6,170
  • 28
  • 79

1 Answers1

12

The reason there are two files named rustc is because rustup is a toolchain multiplexer. It lets you install many versions of Rust and easily switch between them.

The binary installed at ~/.cargo/bin/rustc proxies to the current toolchain that you have selected. Each installed compiler is kept under the toolchains directory.

Although the compiler in the toolchains directory appears to be a smaller file, that's only because it's dynamically linked instead of statically linked.

More information can be found on rustup's README.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
squiguy
  • 32,370
  • 6
  • 56
  • 63