From 990eb4c4f2abcf64bee7870a13abe40c3efc1d69 Mon Sep 17 00:00:00 2001 From: pjsier Date: Mon, 18 Oct 2021 19:22:19 -0500 Subject: [PATCH] use host defaults for can_run target triple --- src/dist/dist.rs | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/dist/dist.rs b/src/dist/dist.rs index 5d494bfbca..c7236605b4 100644 --- a/src/dist/dist.rs +++ b/src/dist/dist.rs @@ -322,11 +322,24 @@ impl TargetTriple { // Otherwise we need to parse things let partial_self = PartialTargetTriple::new(&self.0) .ok_or_else(|| anyhow!(format!("Unable to parse target triple: {}", self.0)))?; - let partial_other = PartialTargetTriple::new(&other.0) + let mut partial_other = PartialTargetTriple::new(&other.0) .ok_or_else(|| anyhow!(format!("Unable to parse target triple: {}", other.0)))?; - // First obvious check is OS, if that doesn't match then we know it - // can't run unless an OS isn't specified - let ret = if partial_self.os != partial_other.os && partial_other.os.is_some() { + + // Default to host for missing target triple values + if partial_other.arch.is_none() { + partial_other.arch = partial_self.clone().arch; + } + if partial_other.os.is_none() { + partial_other.os = partial_self.clone().os; + } + if partial_other.env.is_none() { + partial_other.env = partial_self.clone().env; + } + + // First obvious check is OS, if that doesn't match there's no chance + let ret = if partial_self == partial_other { + true + } else if partial_self.os != partial_other.os { false } else if partial_self.os.as_deref() == Some("pc-windows") { // Windows is a special case here, we know we can run 32bit on 64bit @@ -336,8 +349,8 @@ impl TargetTriple { || (partial_self.arch.as_deref() == Some("x86_64") && partial_other.arch.as_deref() == Some("i686")) } else { - // For other OSes, for now, we assume other toolchains won't run if an OS is specified - partial_other.os.is_none() + // For other OSes, for now, we assume other toolchains won't run + false }; Ok(ret) }