Skip to content
Closed
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
24 changes: 18 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@ use std::env;
use platforms::Platform;

fn from_build() -> Result<String, String> {
let triple =
env::var("RUSTUP_OVERRIDE_BUILD_TRIPLE").unwrap_or_else(|_| env::var("TARGET").unwrap());
if Platform::ALL.iter().any(|p| p.target_triple == triple) {
Ok(triple)
let tuple = {
if let Ok(tuple) = env::var("RUSTUP_OVERRIDE_BUILD_TUPLE") {
tuple
} else if let Ok(tuple) = env::var("RUSTUP_OVERRIDE_BUILD_TRIPLE") {
tuple
} else if let Ok(tuple) = env::var("TARGET") {
tuple
} else {
panic!(
"Unable to get target tuple from environment; Be sure that TARGET env var is set, or its overrides"
)
}
};
if Platform::ALL.iter().any(|p| p.target_triple == tuple) {
Ok(tuple)
} else {
Err(triple)
Err(tuple)
}
}

fn main() {
println!("cargo::rerun-if-env-changed=RUSTUP_OVERRIDE_BUILD_TUPLE");
println!("cargo::rerun-if-env-changed=RUSTUP_OVERRIDE_BUILD_TRIPLE");
println!("cargo::rerun-if-env-changed=TARGET");
match from_build() {
Ok(triple) => eprintln!("Computed build based on target tuple: {triple:#?}"),
Ok(tuple) => eprintln!("Computed build based on target tuple: {tuple:#?}"),
Err(s) => {
eprintln!("Unable to parse target '{s}' as a known target tuple");
eprintln!(
Expand Down
2 changes: 1 addition & 1 deletion doc/user-guide/src/concepts/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To make it easier to choose which components are installed, `rustup` has the
concept of "profiles" which provide named groupings of different components.
See the [Profiles] chapter for more detail.

Most components have a target-triple suffix, such as
Most components have a target-tuple suffix, such as
`rustc-x86_64-apple-darwin`, to signify the platform the component is for.

The set of available components may vary with different releases and
Expand Down
2 changes: 1 addition & 1 deletion doc/user-guide/src/concepts/toolchains.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Standard release channel toolchain names have the following form:
<versioned> = <major.minor>|<major.minor.patch>
<prerelease> = beta[.<number>]
<date> = YYYY-MM-DD
<host> = <target-triple>
<host> = <target-tuple>
```

'channel' is a named release channel, a major and minor version number such as
Expand Down
4 changes: 2 additions & 2 deletions doc/user-guide/src/installation/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ which is a `brew`-managed `rust` toolchain installation.
## Manual installation

You can manually download `rustup-init` for a given target from
`https://static.rust-lang.org/rustup/dist/{target-triple}/rustup-init[.exe]`[^msys2] [^msvc].
`https://static.rust-lang.org/rustup/dist/{target-tuple}/rustup-init[.exe]`[^msys2] [^msvc].

<details>
<summary>Direct links</summary>
Expand Down Expand Up @@ -185,7 +185,7 @@ You can manually download `rustup-init` for a given target from
</details>

To get a previous version, use
`https://static.rust-lang.org/rustup/archive/{rustup-version}/{target-triple}/rustup-init[.exe]`.
`https://static.rust-lang.org/rustup/archive/{rustup-version}/{target-tuple}/rustup-init[.exe]`.

SHA-256 checksums are also available by appending `.sha256` to the link.

Expand Down
4 changes: 2 additions & 2 deletions doc/user-guide/src/installation/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ By default `rustup` on Windows configures Rust to target the MSVC ABI, that is
a target tuple of either `i686-pc-windows-msvc`, `x86_64-pc-windows-msvc`, or `aarch64-pc-windows-msvc`
depending on the CPU architecture of the host Windows OS. The toolchains that
`rustup` chooses to install, unless told otherwise through the [toolchain
specification], will be compiled to run on that target tuple host and will
target that triple by default.
specification], will be compiled to run on that host target, and will
target that tuple by default.

You can change this behavior with `rustup set default-host` or during
installation.
Expand Down
2 changes: 1 addition & 1 deletion rustup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Options:
-y
Disable confirmation prompt
--default-host <DEFAULT_HOST>
Choose a default host triple
Choose a default host tuple
--default-toolchain <DEFAULT_TOOLCHAIN>
Choose a default toolchain to install. Use 'none' to not install any toolchains at all
--profile <PROFILE>
Expand Down
14 changes: 7 additions & 7 deletions src/cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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 @@ -497,16 +497,16 @@ 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_tuple: &TargetTuple,
force_non_host: bool,
) -> Result<()> {
if force_non_host || host_arch.can_run(target_triple)? {
if force_non_host || host_arch.can_run(target_tuple)? {
return Ok(());
}
Err(RustupError::ToolchainIncompatible {
toolchain,
target_triple: target_triple.clone(),
target_tuple: target_tuple.clone(),
}
.into())
}
Expand All @@ -518,10 +518,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
2 changes: 1 addition & 1 deletion src/cli/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub(crate) fn toolchain_help() -> String {
{PLACEHOLDER}<versioned> = <major.minor>|<major.minor.patch>{PLACEHOLDER:#}
{PLACEHOLDER}<prerelease> = beta[.<number>]{PLACEHOLDER:#}
{PLACEHOLDER}<date> = YYYY-MM-DD{PLACEHOLDER:#}
{PLACEHOLDER}<host> = <target-triple>{PLACEHOLDER:#}
{PLACEHOLDER}<host> = <target-tuple>{PLACEHOLDER:#}

'channel' is a named release channel, a major and minor version
number such as `1.42`, or a fully specified version number, such
Expand Down
2 changes: 1 addition & 1 deletion src/cli/proxy_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub async fn main(arg0: &str, current_dir: PathBuf, process: &Process) -> Result
let (toolchain, source) = cfg
.local_toolchain(match toolchain {
Some(name) => Some((
name.resolve(&cfg.get_default_host_triple()?)?,
name.resolve(&cfg.get_default_host_tuple()?)?,
ActiveSource::CommandLine,
)),
None => None,
Expand Down
46 changes: 23 additions & 23 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,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},
},
Expand Down Expand Up @@ -562,8 +562,8 @@ enum SelfSubcmd {
#[derive(Debug, Subcommand)]
#[command(arg_required_else_help = true, subcommand_required = true)]
enum SetSubcmd {
/// The triple used to identify toolchains when not specified
DefaultHost { host_triple: String },
/// The tuple used to identify toolchains when not specified
DefaultHost { host_tuple: String },

/// The default components installed with a toolchain
Profile {
Expand Down Expand Up @@ -742,9 +742,9 @@ pub async fn main(
SelfSubcmd::UpgradeData => cfg.upgrade_data().map(|_| ExitCode(0)),
},
RustupSubcmd::Set { subcmd } => match subcmd {
SetSubcmd::DefaultHost { host_triple } => cfg
.set_default_host_triple(host_triple)
.map(|_| ExitCode(0)),
SetSubcmd::DefaultHost { host_tuple } => {
cfg.set_default_host_tuple(host_tuple).map(|_| ExitCode(0))
}
SetSubcmd::Profile { profile_name } => {
cfg.set_profile(profile_name).map(|_| ExitCode(0))
}
Expand Down Expand Up @@ -778,7 +778,7 @@ async fn default_(
cfg.set_default(Some(&toolchain_name.into()))?;
}
MaybeResolvableToolchainName::Some(ResolvableToolchainName::Official(toolchain)) => {
let desc = toolchain.resolve(&cfg.get_default_host_triple()?)?;
let desc = toolchain.resolve(&cfg.get_default_host_tuple()?)?;
let status = cfg
.ensure_installed(&desc, vec![], vec![], None, force_non_host, true)
.await?
Expand Down Expand Up @@ -954,17 +954,17 @@ 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(
name.to_string(),
&host_arch,
&target_triple,
&target_tuple,
force_non_host,
)?;
}
let desc = name.resolve(&cfg.get_default_host_triple()?)?;
let desc = name.resolve(&cfg.get_default_host_tuple()?)?;

let components = opts.component.iter().map(|s| &**s).collect::<Vec<_>>();
let targets = opts.target.iter().map(|s| &**s).collect::<Vec<_>>();
Expand Down Expand Up @@ -1027,7 +1027,7 @@ async fn run(
command: Vec<String>,
install: bool,
) -> Result<ExitStatus> {
let toolchain = toolchain.resolve(&cfg.get_default_host_triple()?)?;
let toolchain = toolchain.resolve(&cfg.get_default_host_tuple()?)?;
let toolchain = Toolchain::from_local(toolchain, install, cfg).await?;
let cmd = toolchain.command(&command[0])?;
command::run_command_for_dir(cmd, &command[0], &command[1..])
Expand All @@ -1041,7 +1041,7 @@ async fn which(
let (toolchain, _) = cfg
.local_toolchain(match toolchain {
Some(name) => Some((
name.resolve(&cfg.get_default_host_triple()?)?.into(),
name.resolve(&cfg.get_default_host_tuple()?)?.into(),
ActiveSource::CommandLine, // From --toolchain option
)),
None => None,
Expand Down Expand Up @@ -1075,14 +1075,14 @@ async fn which(
async fn show(cfg: &Cfg<'_>, verbose: bool) -> Result<ExitCode> {
common::warn_if_host_is_emulated(cfg.process);

// Print host triple
// Print host tuple
{
let t = cfg.process.stdout();
let mut t = t.lock();
writeln!(
t,
"{HEADER}Default host: {HEADER:#}{}",
cfg.get_default_host_triple()?
cfg.get_default_host_tuple()?
)?;
}

Expand Down Expand Up @@ -1326,7 +1326,7 @@ async fn target_add(
for target in targets {
let new_component = Component::new(
"rust-std".to_string(),
Some(TargetTriple::new(target)),
Some(TargetTuple::new(target)),
false,
);
distributable.add_component(new_component).await?;
Expand All @@ -1347,8 +1347,8 @@ async fn target_remove(
.await?;

for target in targets {
let target = TargetTriple::new(target);
let default_target = cfg.get_default_host_triple()?;
let target = TargetTuple::new(target);
let default_target = cfg.get_default_host_tuple()?;
if target == default_target {
warn!(
"removing the default host target; proc-macros and build scripts might no longer build"
Expand Down Expand Up @@ -1432,9 +1432,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 Expand Up @@ -1493,7 +1493,7 @@ async fn toolchain_remove(cfg: &mut Cfg<'_>, opts: UninstallOpts) -> Result<Exit
.map(|(it, _)| it);

for toolchain_name in &opts.toolchain {
let toolchain_name = toolchain_name.resolve(&cfg.get_default_host_triple()?)?;
let toolchain_name = toolchain_name.resolve(&cfg.get_default_host_tuple()?)?;

if active_toolchain
.as_ref()
Expand Down Expand Up @@ -1522,7 +1522,7 @@ async fn override_add(
toolchain: ResolvableToolchainName,
path: Option<&Path>,
) -> Result<ExitCode> {
let toolchain_name = toolchain.resolve(&cfg.get_default_host_triple()?)?;
let toolchain_name = toolchain.resolve(&cfg.get_default_host_tuple()?)?;
match Toolchain::new(cfg, (&toolchain_name).into()) {
Ok(_) => {}
Err(e @ RustupError::ToolchainNotInstalled { .. }) => match &toolchain_name {
Expand Down
Loading
Loading