Skip to content

Commit 87a4121

Browse files
committed
Only provide is_windows_msvc to gate on windows-msvc
And not both `is_windows_msvc` and `is_msvc`.
1 parent 200f132 commit 87a4121

File tree

8 files changed

+29
-34
lines changed

8 files changed

+29
-34
lines changed

src/tools/run-make-support/src/artifact_names.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
//! libraries which are target-dependent.
33
44
use crate::target;
5-
use crate::targets::is_msvc;
5+
use crate::targets::is_windows_msvc;
66

77
/// Construct the static library name based on the target.
88
#[track_caller]
99
#[must_use]
1010
pub fn static_lib_name(name: &str) -> String {
1111
assert!(!name.contains(char::is_whitespace), "static library name cannot contain whitespace");
1212

13-
if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
13+
if is_windows_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
1414
}
1515

1616
/// Construct the dynamic library name based on the target.
@@ -45,7 +45,7 @@ pub fn dynamic_lib_extension() -> &'static str {
4545
#[track_caller]
4646
#[must_use]
4747
pub fn msvc_import_dynamic_lib_name(name: &str) -> String {
48-
assert!(is_msvc(), "this function is exclusive to MSVC");
48+
assert!(is_windows_msvc(), "this function is exclusive to MSVC");
4949
assert!(!name.contains(char::is_whitespace), "import library name cannot contain whitespace");
5050

5151
format!("{name}.dll.lib")

src/tools/run-make-support/src/external_deps/c_build.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::artifact_names::{dynamic_lib_name, static_lib_name};
44
use crate::external_deps::c_cxx_compiler::{cc, cxx};
55
use crate::external_deps::llvm::llvm_ar;
66
use crate::path_helpers::path;
7-
use crate::targets::{is_darwin, is_msvc, is_windows};
7+
use crate::targets::{is_darwin, is_windows, is_windows_msvc};
88

99
// FIXME(Oneirical): These native build functions should take a Path-based generic.
1010

@@ -24,20 +24,20 @@ pub fn build_native_static_lib_optimized(lib_name: &str) -> PathBuf {
2424

2525
#[track_caller]
2626
fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf {
27-
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
27+
let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
2828
let src = format!("{lib_name}.c");
2929
let lib_path = static_lib_name(lib_name);
3030

3131
let mut cc = cc();
32-
if !is_msvc() {
32+
if !is_windows_msvc() {
3333
cc.arg("-v");
3434
}
3535
if optimzed {
3636
cc.optimize();
3737
}
3838
cc.arg("-c").out_exe(&obj_file).input(src).optimize().run();
3939

40-
let obj_file = if is_msvc() {
40+
let obj_file = if is_windows_msvc() {
4141
PathBuf::from(format!("{lib_name}.obj"))
4242
} else {
4343
PathBuf::from(format!("{lib_name}.o"))
@@ -50,16 +50,17 @@ fn build_native_static_lib_internal(lib_name: &str, optimzed: bool) -> PathBuf {
5050
/// [`std::env::consts::DLL_PREFIX`] and [`std::env::consts::DLL_EXTENSION`].
5151
#[track_caller]
5252
pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
53-
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
53+
let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
5454
let src = format!("{lib_name}.c");
5555
let lib_path = dynamic_lib_name(lib_name);
56-
if is_msvc() {
56+
if is_windows_msvc() {
5757
cc().arg("-c").out_exe(&obj_file).input(src).run();
5858
} else {
5959
cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run();
6060
};
61-
let obj_file = if is_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") };
62-
if is_msvc() {
61+
let obj_file =
62+
if is_windows_msvc() { format!("{lib_name}.obj") } else { format!("{lib_name}.o") };
63+
if is_windows_msvc() {
6364
let out_arg = format!("-out:{lib_path}");
6465
cc().input(&obj_file).args(&["-link", "-dll", &out_arg]).run();
6566
} else if is_darwin() {
@@ -79,15 +80,15 @@ pub fn build_native_dynamic_lib(lib_name: &str) -> PathBuf {
7980
/// Built from a C++ file.
8081
#[track_caller]
8182
pub fn build_native_static_lib_cxx(lib_name: &str) -> PathBuf {
82-
let obj_file = if is_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
83+
let obj_file = if is_windows_msvc() { format!("{lib_name}") } else { format!("{lib_name}.o") };
8384
let src = format!("{lib_name}.cpp");
8485
let lib_path = static_lib_name(lib_name);
85-
if is_msvc() {
86+
if is_windows_msvc() {
8687
cxx().arg("-EHs").arg("-c").out_exe(&obj_file).input(src).run();
8788
} else {
8889
cxx().arg("-c").out_exe(&obj_file).input(src).run();
8990
};
90-
let obj_file = if is_msvc() {
91+
let obj_file = if is_windows_msvc() {
9192
PathBuf::from(format!("{lib_name}.obj"))
9293
} else {
9394
PathBuf::from(format!("{lib_name}.o"))

src/tools/run-make-support/src/external_deps/c_cxx_compiler/cc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::Path;
22

33
use crate::command::Command;
4-
use crate::{env_var, is_msvc};
4+
use crate::{env_var, is_windows_msvc};
55

66
/// Construct a new platform-specific C compiler invocation.
77
///
@@ -82,7 +82,7 @@ impl Cc {
8282
pub fn out_exe(&mut self, name: &str) -> &mut Self {
8383
let mut path = std::path::PathBuf::from(name);
8484

85-
if is_msvc() {
85+
if is_windows_msvc() {
8686
path.set_extension("exe");
8787
let fe_path = path.clone();
8888
path.set_extension("");
@@ -108,7 +108,7 @@ impl Cc {
108108
/// Optimize the output.
109109
/// Equivalent to `-O3` for GNU-compatible linkers or `-O2` for MSVC linkers.
110110
pub fn optimize(&mut self) -> &mut Self {
111-
if is_msvc() {
111+
if is_windows_msvc() {
112112
self.cmd.arg("-O2");
113113
} else {
114114
self.cmd.arg("-O3");

src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use crate::{is_msvc, is_win7, is_windows, uname};
1+
use crate::{is_win7, is_windows, is_windows_msvc, uname};
22

33
/// `EXTRACFLAGS`
44
pub fn extra_c_flags() -> Vec<&'static str> {
55
if is_windows() {
6-
if is_msvc() {
6+
if is_windows_msvc() {
77
let mut libs =
88
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
99
if is_win7() {
@@ -29,7 +29,7 @@ pub fn extra_c_flags() -> Vec<&'static str> {
2929
/// `EXTRACXXFLAGS`
3030
pub fn extra_cxx_flags() -> Vec<&'static str> {
3131
if is_windows() {
32-
if is_msvc() { vec![] } else { vec!["-lstdc++"] }
32+
if is_windows_msvc() { vec![] } else { vec!["-lstdc++"] }
3333
} else {
3434
match &uname()[..] {
3535
"Darwin" => vec!["-lc++"],

src/tools/run-make-support/src/external_deps/rustc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::command::Command;
66
use crate::env::env_var;
77
use crate::path_helpers::cwd;
88
use crate::util::set_host_compiler_dylib_path;
9-
use crate::{is_aix, is_darwin, is_msvc, is_windows, target, uname};
9+
use crate::{is_aix, is_darwin, is_windows, is_windows_msvc, target, uname};
1010

1111
/// Construct a new `rustc` invocation. This will automatically set the library
1212
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
@@ -377,7 +377,7 @@ impl Rustc {
377377
// So we end up with the following hack: we link use static:-bundle to only
378378
// link the parts of libstdc++ that we actually use, which doesn't include
379379
// the dependency on the pthreads DLL.
380-
if !is_msvc() {
380+
if !is_windows_msvc() {
381381
self.cmd.arg("-lstatic:-bundle=stdc++");
382382
};
383383
} else if is_darwin() {

src/tools/run-make-support/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ pub use crate::string::{
8383
};
8484
// Helpers for checking target information.
8585
pub use crate::targets::{
86-
apple_os, is_aix, is_darwin, is_msvc, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
86+
apple_os, is_aix, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
8787
llvm_components_contain, target, uname,
8888
};

src/tools/run-make-support/src/linker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use regex::Regex;
22

3-
use crate::{Rustc, is_msvc};
3+
use crate::{Rustc, is_windows_msvc};
44

55
/// Asserts that `rustc` uses LLD for linking when executed.
66
pub fn assert_rustc_uses_lld(rustc: &mut Rustc) {
@@ -22,7 +22,7 @@ pub fn assert_rustc_doesnt_use_lld(rustc: &mut Rustc) {
2222

2323
fn get_stderr_with_linker_messages(rustc: &mut Rustc) -> String {
2424
// lld-link is used if msvc, otherwise a gnu-compatible lld is used.
25-
let linker_version_flag = if is_msvc() { "--version" } else { "-Wl,-v" };
25+
let linker_version_flag = if is_windows_msvc() { "--version" } else { "-Wl,-v" };
2626

2727
let output = rustc.arg("-Wlinker-messages").link_arg(linker_version_flag).run();
2828
output.stderr_utf8()

src/tools/run-make-support/src/targets.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ pub fn is_windows() -> bool {
1616
target().contains("windows")
1717
}
1818

19-
/// Check if target uses msvc.
19+
/// Check if target is windows-msvc.
2020
#[must_use]
21-
pub fn is_msvc() -> bool {
22-
target().contains("msvc")
21+
pub fn is_windows_msvc() -> bool {
22+
target().ends_with("windows-msvc")
2323
}
2424

2525
/// Check if target is windows-gnu.
@@ -28,12 +28,6 @@ pub fn is_windows_gnu() -> bool {
2828
target().ends_with("windows-gnu")
2929
}
3030

31-
/// Check if target is windows-msvc.
32-
#[must_use]
33-
pub fn is_windows_msvc() -> bool {
34-
target().ends_with("windows-msvc")
35-
}
36-
3731
/// Check if target is win7.
3832
#[must_use]
3933
pub fn is_win7() -> bool {

0 commit comments

Comments
 (0)