-
Notifications
You must be signed in to change notification settings - Fork 891
Non host toolchains
Rust toolchains - that is 'rustc', 'cargo', the linker and other components, have two key architectures. The host that they run on, and the target that they compile for.
Rustup runs on a given host - say x86_64-pc-windows - and will default to installing toolchains that also run on that host - such as stable-x86_64-pc-windows-msvc. With such a toolchain, it is then possible to cross compile to other targets by adding a target, e.g. x86_64-sun-solaris
.
Sometimes crates won't cross compile correctly, in which case the only way to build for that target is to run the native toolchain - e.g. stable-x86_64-sun-solaris
, but to do that from a x86_64-pc-windows host requires some sort of emulation layer, which rustup doesn't have any awareness of or integration with.
Most of the time, adding a target is the appropriate thing users of rustup want; for cross compiling, using the cross
project takes care of the integration with emulation layers. However this nuance is often confusing when first encountered, and while we need to keep the capability - so that the cross
project can continue to work, most users should be steered towards rustup target add
.