Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rustup vs Cargo binaries

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?

like image 497
Zizheng Tai Avatar asked Jan 30 '17 23:01

Zizheng Tai


1 Answers

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.

like image 128
squiguy Avatar answered Nov 13 '22 19:11

squiguy