Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tracing_subscriber::{EnvFilter, Registry, reload::Handle};

use crate::{
config::Cfg,
dist::{DistOptions, TargetTriple, ToolchainDesc},
dist::{DistOptions, TargetTuple, ToolchainDesc},
errors::RustupError,
install::{InstallMethod, UpdateStatus},
process::Process,
Expand Down Expand Up @@ -510,8 +510,8 @@ pub(crate) fn ignorable_error(
/// - The `force_non_host` flag is set to `false`.
pub(crate) fn check_non_host_toolchain(
toolchain: String,
host_arch: &TargetTriple,
target_triple: &TargetTriple,
host_arch: &TargetTuple,
target_triple: &TargetTuple,
force_non_host: bool,
) -> Result<()> {
if force_non_host || host_arch.can_run(target_triple)? {
Expand All @@ -531,10 +531,10 @@ pub(crate) fn warn_if_host_is_emulated(process: &Process) {
if process.var("RUSTUP_CI").is_ok() {
return;
}
if TargetTriple::is_host_emulated() {
if TargetTuple::is_host_emulated() {
warn!(
"Rustup is not running natively. It's running under emulation of {}.",
TargetTriple::from_host_or_build(process)
TargetTuple::from_host_or_build(process)
);
warn!(
"For best compatibility and performance you should reinstall rustup for your native CPU."
Expand Down
18 changes: 9 additions & 9 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use crate::{
command, component_for_bin,
config::{ActiveSource, Cfg},
dist::{
AutoInstallMode, DistOptions, PartialToolchainDesc, Profile, TargetTriple,
AutoInstallMode, DistOptions, PartialToolchainDesc, Profile, TargetTuple,
download::DownloadCfg,
manifest::{Component, ComponentStatus, ManifestWithHash},
},
Expand Down Expand Up @@ -982,13 +982,13 @@ async fn update(
if !names.is_empty() {
for name in names {
// This needs another pass to fix it all up
if name.has_triple() {
let host_arch = TargetTriple::from_host_or_build(cfg.process);
let target_triple = name.clone().resolve(&host_arch)?.target;
if name.has_tuple() {
let host_arch = TargetTuple::from_host_or_build(cfg.process);
let target_tuple = name.clone().resolve(&host_arch)?.target;
common::check_non_host_toolchain(
Comment thread
motorailgun marked this conversation as resolved.
name.to_string(),
&host_arch,
&target_triple,
&target_tuple,
force_non_host,
)?;
}
Expand Down Expand Up @@ -1363,7 +1363,7 @@ async fn target_add(
.map(|target| {
Component::new(
"rust-std".to_string(),
Some(TargetTriple::new(target)),
Some(TargetTuple::new(target)),
false,
)
})
Expand All @@ -1386,7 +1386,7 @@ async fn target_remove(
.await?;

for target in targets {
let target = TargetTriple::new(target);
let target = TargetTuple::new(target);
let default_target = cfg.get_default_host_triple()?;
if target == default_target {
warn!(
Expand Down Expand Up @@ -1476,9 +1476,9 @@ async fn component_add(
fn get_target(
target: Option<String>,
distributable: &DistributableToolchain<'_>,
) -> Option<TargetTriple> {
) -> Option<TargetTuple> {
target
.map(TargetTriple::new)
.map(TargetTuple::new)
.or_else(|| Some(distributable.desc().target.clone()))
}

Expand Down
68 changes: 34 additions & 34 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use crate::{
},
config::Cfg,
dist::{
DistOptions, PartialToolchainDesc, Profile, TargetTriple, ToolchainDesc,
DistOptions, PartialToolchainDesc, Profile, TargetTuple, ToolchainDesc,
download::DownloadCfg,
},
download::download_file,
Expand Down Expand Up @@ -96,7 +96,7 @@ use windows::{delete_rustup_and_cargo_home, do_add_to_path, do_remove_from_path}
pub(crate) use windows::{run_update, self_replace};

pub(crate) struct InstallOpts<'a> {
pub default_host_triple: Option<String>,
pub default_host_tuple: Option<String>,
pub default_toolchain: Option<MaybeOfficialToolchainName>,
pub profile: Profile,
pub no_modify_path: bool,
Expand All @@ -108,7 +108,7 @@ pub(crate) struct InstallOpts<'a> {
impl InstallOpts<'_> {
fn install(self, cfg: &mut Cfg<'_>) -> Result<Option<ToolchainDesc>> {
let Self {
default_host_triple,
default_host_tuple,
default_toolchain,
profile,
no_modify_path: _no_modify_path,
Expand All @@ -119,12 +119,12 @@ impl InstallOpts<'_> {

cfg.set_profile(profile)?;

if let Some(default_host_triple) = &default_host_triple {
// Set host triple now as it will affect resolution of toolchain_str
info!("setting default host triple to {}", default_host_triple);
cfg.set_default_host_triple(default_host_triple.to_owned())?;
if let Some(default_host_tuple) = &default_host_tuple {
// Set host tuple now as it will affect resolution of toolchain_str
info!("setting default host tuple to {}", default_host_tuple);
cfg.set_default_host_triple(default_host_tuple.to_owned())?;
} else {
info!("default host triple is {}", cfg.get_default_host_triple()?);
info!("default host tuple is {}", cfg.get_default_host_triple()?);
}

let user_specified_something = default_toolchain.is_some()
Expand Down Expand Up @@ -195,12 +195,12 @@ impl InstallOpts<'_> {

writeln!(process.stdout().lock())?;

self.default_host_triple = Some(common::question_str(
"Default host triple?",
self.default_host_tuple = Some(common::question_str(
"Default host tuple?",
&self
.default_host_triple
.default_host_tuple
.take()
.unwrap_or_else(|| TargetTriple::from_host_or_build(process).to_string()),
.unwrap_or_else(|| TargetTuple::from_host_or_build(process).to_string()),
process,
)?);

Expand Down Expand Up @@ -232,18 +232,18 @@ impl InstallOpts<'_> {
fn validate(&self, process: &Process) -> Result<()> {
common::warn_if_host_is_emulated(process);

let host_triple = self
.default_host_triple
let host_tuple = self
.default_host_tuple
.as_ref()
.map(TargetTriple::new)
.unwrap_or_else(|| TargetTriple::from_host_or_build(process));
.map(TargetTuple::new)
.unwrap_or_else(|| TargetTuple::from_host_or_build(process));
let partial_channel = match &self.default_toolchain {
None | Some(MaybeOfficialToolchainName::None) => {
ResolvableToolchainName::try_from("stable")?
}
Some(MaybeOfficialToolchainName::Some(s)) => s.into(),
};
let resolved = partial_channel.resolve(&host_triple)?;
let resolved = partial_channel.resolve(&host_tuple)?;
trace!("Successfully resolved installation toolchain as: {resolved}");
Ok(())
}
Expand Down Expand Up @@ -567,8 +567,8 @@ pub(crate) async fn install(
anyhow!(
"Pre-checks for host and toolchain failed: {e}\n\
If you are unsure of suitable values, the 'stable' toolchain is the default.\n\
Valid host triples look something like: {}",
TargetTriple::from_host_or_build(cfg.process)
Valid host tuples look something like: {}",
TargetTuple::from_host_or_build(cfg.process)
)
})?;

Expand Down Expand Up @@ -740,7 +740,7 @@ fn check_existence_of_settings_file(cfg: &Cfg<'_>) -> Result<()> {
PartialToolchainDesc::from_str("stable")?.resolve(&cfg.get_default_host_triple()?)?;
if default_toolchain != inferred.to_string() {
warn!("rustup will install the default toolchain as specified in the settings file,");
warn!("instead of the one inferred from the default host triple.");
warn!("instead of the one inferred from the default host tuple.");
}
Ok(())
}
Expand Down Expand Up @@ -790,15 +790,15 @@ fn current_install_opts(opts: &InstallOpts<'_>, process: &Process) -> String {
format!(
r"Current installation options:

- ` `default host triple: `{}`
- ` `default host tuple: `{}`
- ` `default toolchain: `{}`
- ` `profile: `{}`
- modify PATH variable: `{}`
",
opts.default_host_triple
opts.default_host_tuple
.as_ref()
.map(TargetTriple::new)
.unwrap_or_else(|| TargetTriple::from_host_or_build(process)),
.map(TargetTuple::new)
.unwrap_or_else(|| TargetTuple::from_host_or_build(process)),
opts.default_toolchain
.as_ref()
.map(ToString::to_string)
Expand All @@ -817,18 +817,18 @@ fn warn_if_default_linker_missing(process: &Process) {
return;
};

// If we have the host triple, attempt to determine the CC/linker path that
// If we have the host tuple, attempt to determine the CC/linker path that
// `cc-rs` would use, as this is *usually* why we need a linker to invoke.
//
// Doing it this way allows us to correctly diagnose quirky systems like
// solaris and illumos that use `gcc` rather than `cc` for historical reasons.
let cc_tool = TargetTriple::from_host(process).and_then(|triple| {
let cc_tool = TargetTuple::from_host(process).and_then(|tuple| {
// Fill in some dummy settings for `Build`/`Tool` to be able to properly
// give us the metadata we want
cc::Build::new()
.opt_level(0)
.target(&triple)
.host(&triple)
.target(&tuple)
.host(&tuple)
.try_get_compiler()
.ok()
});
Expand Down Expand Up @@ -1299,8 +1299,8 @@ pub(crate) async fn prepare_update(dl_cfg: &DownloadCfg<'_>) -> Result<Option<Pa
utils::remove_file("setup", &setup_path)?;
}

// Get build triple
let triple = TargetTriple::from_build();
// Get build tuple
let tuple = TargetTuple::from_build();

// For windows x86 builds seem slow when used with windows defender.
// The website defaulted to i686-windows-gnu builds for a long time.
Expand All @@ -1309,7 +1309,7 @@ pub(crate) async fn prepare_update(dl_cfg: &DownloadCfg<'_>) -> Result<Option<Pa
// If someone really wants to use another version, they still can enforce
// that using the environment variable RUSTUP_OVERRIDE_HOST_TUPLE.
#[cfg(windows)]
let triple = TargetTriple::from_host(dl_cfg.process).unwrap_or(triple);
let tuple = TargetTuple::from_host(dl_cfg.process).unwrap_or(tuple);

// Get update root.
let update_root = update_root(dl_cfg.process);
Expand All @@ -1333,7 +1333,7 @@ pub(crate) async fn prepare_update(dl_cfg: &DownloadCfg<'_>) -> Result<Option<Pa
}

// Get download URL
let url = format!("{update_root}/archive/{available_version}/{triple}/rustup-init{EXE_SUFFIX}");
let url = format!("{update_root}/archive/{available_version}/{tuple}/rustup-init{EXE_SUFFIX}");

// Get download path
let download_url = utils::parse_url(&url)?;
Expand Down Expand Up @@ -1466,7 +1466,7 @@ mod tests {
Cfg::from_env(tp.process.current_dir().unwrap(), false, &tp.process).unwrap();

let opts = InstallOpts {
default_host_triple: None,
default_host_tuple: None,
default_toolchain: None, // No toolchain specified
profile: Profile::Default, // default profile
no_modify_path: false,
Expand All @@ -1488,7 +1488,7 @@ mod tests {
assert_eq!(
for_host!(
r"info: profile set to default
info: default host triple is {0}
info: default host tuple is {0}
"
),
&String::from_utf8(tp.stderr()).unwrap()
Expand Down
14 changes: 7 additions & 7 deletions src/cli/self_update/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::common;
use super::{InstallOpts, install_bins, report_error};
use crate::cli::markdown::md;
use crate::config::Cfg;
use crate::dist::TargetTriple;
use crate::dist::TargetTuple;
use crate::dist::download::DownloadCfg;
use crate::download::download_file;
use crate::process::{ColorableTerminal, Process};
Expand Down Expand Up @@ -187,20 +187,20 @@ pub(crate) fn do_msvc_check(opts: &InstallOpts<'_>, process: &Process) -> Option
}

use cc::windows_registry;
let host_triple = if let Some(trip) = opts.default_host_triple.as_ref() {
trip.to_owned()
let host_tuple = if let Some(tuple) = opts.default_host_tuple.as_ref() {
tuple.to_owned()
} else {
TargetTriple::from_host_or_build(process).to_string()
TargetTuple::from_host_or_build(process).to_string()
};
let installing_msvc = host_triple.contains("msvc");
let have_msvc = windows_registry::find_tool(&host_triple, "cl.exe").is_some();
let installing_msvc = host_tuple.contains("msvc");
let have_msvc = windows_registry::find_tool(&host_tuple, "cl.exe").is_some();
if installing_msvc && !have_msvc {
// Visual Studio build tools are required.
// If the user does not have Visual Studio installed and their host
// machine is i686 or x86_64 then it's OK to try an auto install.
// Otherwise a manual install will be required.
let has_any_vs = windows_registry::find_vs_version().is_ok();
let is_x86 = host_triple.contains("i686") || host_triple.contains("x86_64");
let is_x86 = host_tuple.contains("i686") || host_tuple.contains("x86_64");
if is_x86 && !has_any_vs {
Some(VsInstallPlan::Automatic)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/setup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub async fn main(
update_console_filter(process, &console_filter, quiet, verbose);

let opts = InstallOpts {
default_host_triple: default_host,
default_host_tuple: default_host,
default_toolchain,
profile,
no_modify_path,
Expand Down
16 changes: 8 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tracing::{debug, info, trace, warn};
use crate::{
cli::{common, self_update::SelfUpdateMode},
dist::{
self, AutoInstallMode, DistOptions, PartialToolchainDesc, Profile, TargetTriple,
self, AutoInstallMode, DistOptions, PartialToolchainDesc, Profile, TargetTuple,
ToolchainDesc,
},
errors::RustupError,
Expand Down Expand Up @@ -636,7 +636,7 @@ impl<'a> Cfg<'a> {
// Do not permit architecture/os selection in channels as
// these are host specific and toolchain files are portable.
if let ResolvableToolchainName::Official(name) = &toolchain_name
&& name.has_triple()
&& name.has_tuple()
{
// Permit fully qualified names IFF the toolchain is installed. TODO(robertc): consider
// disabling this and backing out https://github.com/rust-lang/rustup/pull/2141 (but provide
Expand Down Expand Up @@ -779,7 +779,7 @@ impl<'a> Cfg<'a> {
) -> Result<(UpdateStatus, Toolchain<'_>)> {
common::check_non_host_toolchain(
toolchain.to_string(),
&TargetTriple::from_host_or_build(self.process),
&TargetTuple::from_host_or_build(self.process),
&toolchain.target,
force_non_host,
)?;
Expand Down Expand Up @@ -901,15 +901,15 @@ impl<'a> Cfg<'a> {
// against the 'stable' toolchain. This provides early errors
// if the supplied triple is insufficient / bad.
PartialToolchainDesc::from_str("stable")?
.resolve(&TargetTriple::new(host_triple.clone()))?;
.resolve(&TargetTuple::new(host_triple.clone()))?;
self.settings_file.with_mut(|s| {
s.default_host_triple = Some(host_triple);
Ok(())
})
}

#[tracing::instrument(level = "trace", skip_all)]
pub(crate) fn get_default_host_triple(&self) -> Result<TargetTriple> {
pub(crate) fn get_default_host_triple(&self) -> Result<TargetTuple> {
self.settings_file
.with(|s| Ok(get_default_host_triple(s, self.process)))
}
Expand Down Expand Up @@ -980,11 +980,11 @@ impl Debug for Cfg<'_> {
}
}

fn get_default_host_triple(s: &Settings, process: &Process) -> TargetTriple {
fn get_default_host_triple(s: &Settings, process: &Process) -> TargetTuple {
s.default_host_triple
.as_ref()
.map(TargetTriple::new)
.unwrap_or_else(|| TargetTriple::from_host_or_build(process))
.map(TargetTuple::new)
.unwrap_or_else(|| TargetTuple::from_host_or_build(process))
}

fn no_toolchain_error(process: &Process) -> anyhow::Error {
Expand Down
Loading
Loading