Skip to content

Commit 95500f4

Browse files
committed
Make executable extension platform, rather than environment dependent
1 parent 074fb2c commit 95500f4

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/tools/opt-dist/src/environment/linux.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ impl Environment for LinuxEnvironment {
5757
true
5858
}
5959

60-
fn executable_extension(&self) -> &'static str {
61-
""
62-
}
63-
6460
fn skipped_tests(&self) -> &'static [&'static str] {
6561
&[
6662
// Fails because of linker errors, as of June 2023.

src/tools/opt-dist/src/environment/mod.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ pub trait Environment {
3131
self.build_artifacts()
3232
.join("stage0")
3333
.join("bin")
34-
.join(format!("cargo{}", self.executable_extension()))
34+
.join(format!("cargo{}", executable_extension()))
3535
}
3636

3737
fn rustc_stage_0(&self) -> Utf8PathBuf {
3838
self.build_artifacts()
3939
.join("stage0")
4040
.join("bin")
41-
.join(format!("rustc{}", self.executable_extension()))
41+
.join(format!("rustc{}", executable_extension()))
4242
}
4343

4444
fn rustc_stage_2(&self) -> Utf8PathBuf {
4545
self.build_artifacts()
4646
.join("stage2")
4747
.join("bin")
48-
.join(format!("rustc{}", self.executable_extension()))
48+
.join(format!("rustc{}", executable_extension()))
4949
}
5050

5151
/// Path to the built rustc-perf benchmark suite.
@@ -60,9 +60,6 @@ pub trait Environment {
6060

6161
fn supports_shared_llvm(&self) -> bool;
6262

63-
/// What is the extension of binary executables in this environment?
64-
fn executable_extension(&self) -> &'static str;
65-
6663
/// List of test paths that should be skipped when testing the optimized artifacts.
6764
fn skipped_tests(&self) -> &'static [&'static str];
6865
}
@@ -73,3 +70,14 @@ pub fn create_environment(target_triple: String) -> Box<dyn Environment> {
7370
#[cfg(target_family = "windows")]
7471
return Box::new(windows::WindowsEnvironment::new(target_triple));
7572
}
73+
74+
/// What is the extension of binary executables on this platform?
75+
#[cfg(target_family = "unix")]
76+
pub fn executable_extension() -> &'static str {
77+
""
78+
}
79+
80+
#[cfg(target_family = "windows")]
81+
pub fn executable_extension() -> &'static str {
82+
".exe"
83+
}

src/tools/opt-dist/src/environment/windows.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ impl Environment for WindowsEnvironment {
8484
false
8585
}
8686

87-
fn executable_extension(&self) -> &'static str {
88-
".exe"
89-
}
90-
9187
fn skipped_tests(&self) -> &'static [&'static str] {
9288
&[
9389
// Fails as of June 2023.

src/tools/opt-dist/src/tests.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::environment::Environment;
1+
use crate::environment::{executable_extension, Environment};
22
use crate::exec::cmd;
33
use crate::utils::io::{copy_directory, find_file_in_dir, unpack_archive};
44
use anyhow::Context;
@@ -45,9 +45,9 @@ pub fn run_tests(env: &dyn Environment) -> anyhow::Result<()> {
4545
&rustc_dir.join("lib").join("rustlib").join("src"),
4646
)?;
4747

48-
let rustc_path = rustc_dir.join("bin").join(format!("rustc{}", env.executable_extension()));
48+
let rustc_path = rustc_dir.join("bin").join(format!("rustc{}", executable_extension()));
4949
assert!(rustc_path.is_file());
50-
let cargo_path = cargo_dir.join("bin").join(format!("cargo{}", env.executable_extension()));
50+
let cargo_path = cargo_dir.join("bin").join(format!("cargo{}", executable_extension()));
5151
assert!(cargo_path.is_file());
5252

5353
// Specify path to a LLVM config so that LLVM is not rebuilt.
@@ -56,7 +56,7 @@ pub fn run_tests(env: &dyn Environment) -> anyhow::Result<()> {
5656
.build_artifacts()
5757
.join("llvm")
5858
.join("bin")
59-
.join(format!("llvm-config{}", env.executable_extension()));
59+
.join(format!("llvm-config{}", executable_extension()));
6060
assert!(llvm_config.is_file());
6161

6262
let config_content = format!(

src/tools/opt-dist/src/training.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::environment::Environment;
1+
use crate::environment::{executable_extension, Environment};
22
use crate::exec::{cmd, CmdBuilder};
33
use crate::utils::io::{count_files, delete_directory};
44
use crate::utils::with_log_group;
@@ -86,7 +86,7 @@ fn merge_llvm_profiles(
8686
.build_artifacts()
8787
.join("llvm")
8888
.join("build")
89-
.join(format!("bin/llvm-profdata{}", env.executable_extension())),
89+
.join(format!("bin/llvm-profdata{}", executable_extension())),
9090
};
9191

9292
cmd(&[llvm_profdata.as_str(), "merge", "-o", merged_path.as_str(), profile_dir.as_str()])

0 commit comments

Comments
 (0)