From 2155c0350081ae159e37aa25cfd829da950bb282 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 10 Feb 2023 10:03:42 +0000 Subject: [PATCH] Inline Compiler::bootstrap_with_triple --- build_system/mod.rs | 22 +++++++++++++++++----- build_system/utils.rs | 13 ------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/build_system/mod.rs b/build_system/mod.rs index 0a83ea93778..80a777fc00e 100644 --- a/build_system/mod.rs +++ b/build_system/mod.rs @@ -1,5 +1,5 @@ use std::env; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::process; use self::utils::{is_ci, is_ci_opt, Compiler}; @@ -101,12 +101,24 @@ pub(crate) fn main() { } } - let bootstrap_host_compiler = Compiler::bootstrap_with_triple( - std::env::var("HOST_TRIPLE") + let bootstrap_host_compiler = { + let cargo = rustc_info::get_cargo_path(); + let rustc = rustc_info::get_rustc_path(); + let rustdoc = rustc_info::get_rustdoc_path(); + let triple = std::env::var("HOST_TRIPLE") .ok() .or_else(|| config::get_value("host")) - .unwrap_or_else(|| rustc_info::get_host_triple(Path::new("rustc"))), - ); + .unwrap_or_else(|| rustc_info::get_host_triple(&rustc)); + Compiler { + cargo, + rustc, + rustdoc, + rustflags: String::new(), + rustdocflags: String::new(), + triple, + runner: vec![], + } + }; let target_triple = std::env::var("TARGET_TRIPLE") .ok() .or_else(|| config::get_value("target")) diff --git a/build_system/utils.rs b/build_system/utils.rs index 8928ed7cd56..6c0ecd8b02a 100644 --- a/build_system/utils.rs +++ b/build_system/utils.rs @@ -5,7 +5,6 @@ use std::path::{Path, PathBuf}; use std::process::{self, Command, Stdio}; use super::path::{Dirs, RelPath}; -use super::rustc_info::{get_cargo_path, get_rustc_path, get_rustdoc_path}; #[derive(Clone, Debug)] pub(crate) struct Compiler { @@ -19,18 +18,6 @@ pub(crate) struct Compiler { } impl Compiler { - pub(crate) fn bootstrap_with_triple(triple: String) -> Compiler { - Compiler { - cargo: get_cargo_path(), - rustc: get_rustc_path(), - rustdoc: get_rustdoc_path(), - rustflags: String::new(), - rustdocflags: String::new(), - triple, - runner: vec![], - } - } - pub(crate) fn set_cross_linker_and_runner(&mut self) { match self.triple.as_str() { "aarch64-unknown-linux-gnu" => {