From 48aac03507cf70c6a3c724ec356afd620122c20e Mon Sep 17 00:00:00 2001 From: pjsier Date: Mon, 27 Sep 2021 19:47:03 -0500 Subject: [PATCH 1/2] resolve target triple before calling can_run --- src/cli/rustup_mode.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cli/rustup_mode.rs b/src/cli/rustup_mode.rs index 0c4eaf53e2..ae1cef77e6 100644 --- a/src/cli/rustup_mode.rs +++ b/src/cli/rustup_mode.rs @@ -17,9 +17,7 @@ use super::{ self_update::{check_rustup_update, SelfUpdateMode}, }; use crate::cli::errors::CLIError; -use crate::dist::dist::{ - PartialTargetTriple, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc, -}; +use crate::dist::dist::{PartialTargetTriple, PartialToolchainDesc, Profile, TargetTriple}; use crate::dist::manifest::Component; use crate::errors::RustupError; use crate::process; @@ -959,8 +957,8 @@ fn update(cfg: &mut Cfg, m: &ArgMatches<'_>) -> Result { if toolchain_has_triple { let host_arch = TargetTriple::from_host_or_build(); - if let Ok(toolchain_desc) = ToolchainDesc::from_str(name) { - let target_triple = toolchain_desc.target; + if let Ok(partial_toolchain_desc) = PartialToolchainDesc::from_str(name) { + let target_triple = partial_toolchain_desc.resolve(&host_arch)?.target; if !forced && !host_arch.can_run(&target_triple)? { err!("DEPRECATED: future versions of rustup will require --force-non-host to install a non-host toolchain as the default."); warn!( From f3b444b82bd80b9472102e11446c32e00cb67414 Mon Sep 17 00:00:00 2001 From: pjsier Date: Mon, 8 Nov 2021 16:16:11 -0600 Subject: [PATCH 2/2] add test for update partial target triple --- tests/cli-rustup.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/cli-rustup.rs b/tests/cli-rustup.rs index f7ff77d701..4fbc879fc5 100644 --- a/tests/cli-rustup.rs +++ b/tests/cli-rustup.rs @@ -2147,6 +2147,31 @@ warning: If you meant to build software to target that platform, perhaps try `ru }); } +#[test] +fn dont_warn_on_partial_build() { + setup(&|config| { + let triple = this_host_triple(); + let arch = triple.split('-').next().unwrap(); + let mut cmd = clitools::cmd( + config, + "rustup", + &["toolchain", "install", &format!("nightly-{}", arch)], + ); + clitools::env(config, &mut cmd); + let out = cmd.output().unwrap(); + assert!(out.status.success()); + let stderr = String::from_utf8(out.stderr).unwrap(); + assert!(stderr.contains(&format!( + r"info: syncing channel updates for 'nightly-{0}'", + triple + ))); + assert!(!stderr.contains(&format!( + r"warning: toolchain 'nightly-{0}' may not be able to run on this system.", + arch + ))); + }) +} + /// Checks that `rust-toolchain.toml` files are considered #[test] fn rust_toolchain_toml() {