about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/tools/opt-dist/src/environment/linux.rs14
-rw-r--r--src/tools/opt-dist/src/environment/mod.rs10
-rw-r--r--src/tools/opt-dist/src/environment/windows.rs9
-rw-r--r--src/tools/opt-dist/src/main.rs4
4 files changed, 27 insertions, 10 deletions
diff --git a/src/tools/opt-dist/src/environment/linux.rs b/src/tools/opt-dist/src/environment/linux.rs
index 58b7e6d2306..bd8dd037ae5 100644
--- a/src/tools/opt-dist/src/environment/linux.rs
+++ b/src/tools/opt-dist/src/environment/linux.rs
@@ -3,9 +3,21 @@ use crate::exec::cmd;
 use crate::utils::io::copy_directory;
 use camino::{Utf8Path, Utf8PathBuf};
 
-pub(super) struct LinuxEnvironment;
+pub(super) struct LinuxEnvironment {
+    target_triple: String,
+}
+
+impl LinuxEnvironment {
+    pub fn new(target_triple: String) -> Self {
+        Self { target_triple }
+    }
+}
 
 impl Environment for LinuxEnvironment {
+    fn host_triple(&self) -> &str {
+        &self.target_triple
+    }
+
     fn python_binary(&self) -> &'static str {
         "python3"
     }
diff --git a/src/tools/opt-dist/src/environment/mod.rs b/src/tools/opt-dist/src/environment/mod.rs
index a8650fad011..9f7f31d4791 100644
--- a/src/tools/opt-dist/src/environment/mod.rs
+++ b/src/tools/opt-dist/src/environment/mod.rs
@@ -6,9 +6,7 @@ mod linux;
 mod windows;
 
 pub trait Environment {
-    fn host_triple(&self) -> String {
-        std::env::var("PGO_HOST").expect("PGO_HOST environment variable missing")
-    }
+    fn host_triple(&self) -> &str;
 
     fn python_binary(&self) -> &'static str;
 
@@ -69,9 +67,9 @@ pub trait Environment {
     fn skipped_tests(&self) -> &'static [&'static str];
 }
 
-pub fn create_environment() -> Box<dyn Environment> {
+pub fn create_environment(target_triple: String) -> Box<dyn Environment> {
     #[cfg(target_family = "unix")]
-    return Box::new(linux::LinuxEnvironment);
+    return Box::new(linux::LinuxEnvironment::new(target_triple));
     #[cfg(target_family = "windows")]
-    return Box::new(windows::WindowsEnvironment::new());
+    return Box::new(windows::WindowsEnvironment::new(target_triple));
 }
diff --git a/src/tools/opt-dist/src/environment/windows.rs b/src/tools/opt-dist/src/environment/windows.rs
index 79399391798..90ddc01e893 100644
--- a/src/tools/opt-dist/src/environment/windows.rs
+++ b/src/tools/opt-dist/src/environment/windows.rs
@@ -9,15 +9,20 @@ use zip::ZipArchive;
 
 pub(super) struct WindowsEnvironment {
     checkout_dir: Utf8PathBuf,
+    target_triple: String,
 }
 
 impl WindowsEnvironment {
-    pub fn new() -> Self {
-        Self { checkout_dir: std::env::current_dir().unwrap().try_into().unwrap() }
+    pub fn new(target_triple: String) -> Self {
+        Self { checkout_dir: std::env::current_dir().unwrap().try_into().unwrap(), target_triple }
     }
 }
 
 impl Environment for WindowsEnvironment {
+    fn host_triple(&self) -> &str {
+        &self.target_triple
+    }
+
     fn python_binary(&self) -> &'static str {
         "python"
     }
diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs
index 8ab19674d05..484ca5b3b86 100644
--- a/src/tools/opt-dist/src/main.rs
+++ b/src/tools/opt-dist/src/main.rs
@@ -171,6 +171,8 @@ fn main() -> anyhow::Result<()> {
         .parse_default_env()
         .init();
 
+    let target_triple = std::env::var("PGO_HOST").expect("PGO_HOST environment variable missing");
+
     let mut build_args: Vec<String> = std::env::args().skip(1).collect();
     println!("Running optimized build pipeline with args `{}`", build_args.join(" "));
 
@@ -202,7 +204,7 @@ fn main() -> anyhow::Result<()> {
     }
 
     let mut timer = Timer::new();
-    let env = create_environment();
+    let env = create_environment(target_triple);
 
     let result = execute_pipeline(env.as_ref(), &mut timer, build_args);
     log::info!("Timer results\n{}", timer.format_stats());