Repository navigation
rustup default doesn't show proper warning when architecture is not compatible #3972
Description
Activity
I think there may be some confusion here. There are two concepts in rustup, the toolchain host, and the standard library targets. It looks like you may have installed toolchains for other hosts, which won't run. You only need to install the toolchain for the host you are running on (so on WSL, it would be
stable-x86_64-unknown-linux-gnu). To cross compile, you only need to install the standard library target (rustup target add x86_64-pc-windows-gnu). There is more information at https://rust-lang.github.io/rustup/cross-compilation.html about how to install targets, and https://rust-lang.github.io/rustup/concepts/index.html for more on the different concepts in rustup.Just beware that cross compiling from linux to windows or macos is not particularly easy. This recent blogpost contains an overview of how to cross-compile to windows.
Reacted by York XiangThank you! I'll have a try a few hours later when I can reach my machine.
- changed the title
[-]rustup cross-compilation installation is broken[/-][+]`rustup default` doesn't show proper warning when architecture is not compatible[/+]on Aug 26, 2021 rustup run nightly-x86_64-unknown-linux-gnu cargo run --target=x86_64-pc-windows-gnuseems to do the job.But I still wonder if it is considerable that we change
rustup defaulta little bit so it can warn incompatible architectureThat would be a rustup bug. Could this issue be transferred?
Reacted by León Orell Valerian LiehrAttempting to transferr to rust-lang/rustup since this is an issue with the rustup tool...
@rustbot transfer rustup
Reacted by rami3lFWIW we do emit this warning for
rustup toolchain install:Lines 820 to 825 in 4207838
error!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain."); warn!("toolchain '{name}' may not be able to run on this system."); warn!( "If you meant to build software to target that platform, perhaps try `rustup target add {}` instead?", target_triple.to_string() ); > uname -mrs Darwin 23.5.0 arm64 > rustup toolchain install stable-unknown-linux-gnu --profile=minimal error: DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain. warn: toolchain 'stable-unknown-linux-gnu' may not be able to run on this system. warn: If you meant to build software to target that platform, perhaps try `rustup target add aarch64-unknown-linux-gnu` instead? info: syncing channel updates for 'stable-aarch64-unknown-linux-gnu' info: latest update on 2024-07-25, rust version 1.80.0 (051478957 2024-07-21) info: downloading component 'cargo' info: downloading component 'rust-std' ^C⏎
... it could be that this is not covered by
rustup defaultsomehow. So adding the same warning to that path should address this issue.Lines 703 to 706 in 4207838
async fn default_( cfg: &Cfg<'_>, toolchain: Option<MaybeResolvableToolchainName>, ) -> Result<utils::ExitCode> { ... calls:
rustup/src/toolchain/distributable.rs
Line 362 in 4207838
pub async fn install_if_not_installed( ... so it looks like extracting the warning to a separate function and call it at the beginning of
install_if_not_installed()above will do.However, this function clashes with
Cfg::ensure_installed, so it's better to unify them. I'll have a look later...
Fresh install rustup on my Windows Subsystem for Linux, choose
stable-x86_64-apple-darwintoolchainafter installation, run
rustcit reports~/.rustup/toolchains/stable-x86_64-apple-darwin/bin/rustc: 1: Syntax error: "(" unexpectedOr if you choose
stable-x86_64-pc-windows-gnu, runrustcafter installation,it reports
error: the 'rustc' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-gnu' toolchain