Skip to content

Commit 36383dd

Browse files
committed
[win][arm64ec] Fix msvc-wholearchive for Arm64EC
1 parent e1b9081 commit 36383dd

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
use crate::{is_win7, is_windows, is_windows_msvc, uname};
1+
use crate::{is_arm64ec, is_win7, is_windows, is_windows_msvc, uname};
2+
3+
fn get_windows_msvc_libs() -> Vec<&'static str> {
4+
let mut libs =
5+
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
6+
if is_win7() {
7+
libs.push("advapi32.lib");
8+
}
9+
libs
10+
}
211

312
/// `EXTRACFLAGS`
413
pub fn extra_c_flags() -> Vec<&'static str> {
514
if is_windows() {
615
if is_windows_msvc() {
7-
let mut libs =
8-
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
9-
if is_win7() {
10-
libs.push("advapi32.lib");
16+
let mut args = get_windows_msvc_libs();
17+
if is_arm64ec() {
18+
args.push("/arm64EC");
1119
}
12-
libs
20+
args
1321
} else {
1422
vec!["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"]
1523
}
@@ -26,6 +34,18 @@ pub fn extra_c_flags() -> Vec<&'static str> {
2634
}
2735
}
2836

37+
pub fn extra_linker_flags() -> Vec<&'static str> {
38+
if is_windows_msvc() {
39+
let mut args = get_windows_msvc_libs();
40+
if is_arm64ec() {
41+
args.push("/MACHINE:ARM64EC");
42+
}
43+
args
44+
} else {
45+
vec![]
46+
}
47+
}
48+
2949
/// `EXTRACXXFLAGS`
3050
pub fn extra_cxx_flags() -> Vec<&'static str> {
3151
if is_windows() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub use crate::external_deps::c_build::{
5656
};
5757
// Re-exports of external dependencies.
5858
pub use crate::external_deps::c_cxx_compiler::{
59-
Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc,
59+
Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, extra_linker_flags, gcc,
6060
};
6161
pub use crate::external_deps::cargo::cargo;
6262
pub use crate::external_deps::clang::{Clang, clang};
@@ -84,6 +84,6 @@ pub use crate::string::{
8484
};
8585
// Helpers for checking target information.
8686
pub use crate::targets::{
87-
apple_os, is_aix, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
87+
apple_os, is_aix, is_arm64ec, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
8888
llvm_components_contain, target, uname,
8989
};

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ pub fn is_aix() -> bool {
4646
target().contains("aix")
4747
}
4848

49+
/// Check if target is arm64ec.
50+
#[must_use]
51+
pub fn is_arm64ec() -> bool {
52+
target().starts_with("arm64ec")
53+
}
54+
4955
/// Get the target OS on Apple operating systems.
5056
#[must_use]
5157
pub fn apple_os() -> &'static str {

tests/run-make/msvc-wholearchive/rmake.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use std::path::PathBuf;
99

10-
use run_make_support::{cc, cmd, env_var, extra_c_flags, rustc};
10+
use run_make_support::{cc, cmd, env_var, extra_linker_flags, rustc};
1111

1212
fn main() {
1313
// Build the staticlib
@@ -31,7 +31,7 @@ fn main() {
3131
// Otherwise the actual test failure may be caused by something else.
3232
cmd(&linker)
3333
.args(["c.obj", "./static.lib", "-dll", "-def:dll.def", "-out:dll.dll"])
34-
.args(extra_c_flags())
34+
.args(extra_linker_flags())
3535
.run();
3636

3737
// FIXME(@ChrisDenton): this doesn't currently work with llvm's lld-link for other reasons.
@@ -46,7 +46,7 @@ fn main() {
4646
"-def:dll.def",
4747
"-out:dll_whole_archive.dll",
4848
])
49-
.args(extra_c_flags())
49+
.args(extra_linker_flags())
5050
.run();
5151
}
5252
}

0 commit comments

Comments
 (0)