[win][arm64ec] Fix msvc-wholearchive for Arm64EC

This commit is contained in:
Daniel Paoliello 2025-08-04 17:05:20 -07:00
parent e1b9081e69
commit 36383dd2b8
4 changed files with 37 additions and 11 deletions

View file

@ -1,15 +1,23 @@
use crate::{is_win7, is_windows, is_windows_msvc, uname};
use crate::{is_arm64ec, is_win7, is_windows, is_windows_msvc, uname};
fn get_windows_msvc_libs() -> Vec<&'static str> {
let mut libs =
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
if is_win7() {
libs.push("advapi32.lib");
}
libs
}
/// `EXTRACFLAGS`
pub fn extra_c_flags() -> Vec<&'static str> {
if is_windows() {
if is_windows_msvc() {
let mut libs =
vec!["ws2_32.lib", "userenv.lib", "bcrypt.lib", "ntdll.lib", "synchronization.lib"];
if is_win7() {
libs.push("advapi32.lib");
let mut args = get_windows_msvc_libs();
if is_arm64ec() {
args.push("/arm64EC");
}
libs
args
} else {
vec!["-lws2_32", "-luserenv", "-lbcrypt", "-lntdll", "-lsynchronization"]
}
@ -26,6 +34,18 @@ pub fn extra_c_flags() -> Vec<&'static str> {
}
}
pub fn extra_linker_flags() -> Vec<&'static str> {
if is_windows_msvc() {
let mut args = get_windows_msvc_libs();
if is_arm64ec() {
args.push("/MACHINE:ARM64EC");
}
args
} else {
vec![]
}
}
/// `EXTRACXXFLAGS`
pub fn extra_cxx_flags() -> Vec<&'static str> {
if is_windows() {

View file

@ -56,7 +56,7 @@ pub use crate::external_deps::c_build::{
};
// Re-exports of external dependencies.
pub use crate::external_deps::c_cxx_compiler::{
Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, gcc,
Cc, Gcc, cc, cxx, extra_c_flags, extra_cxx_flags, extra_linker_flags, gcc,
};
pub use crate::external_deps::cargo::cargo;
pub use crate::external_deps::clang::{Clang, clang};
@ -84,6 +84,6 @@ pub use crate::string::{
};
// Helpers for checking target information.
pub use crate::targets::{
apple_os, is_aix, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
apple_os, is_aix, is_arm64ec, is_darwin, is_win7, is_windows, is_windows_gnu, is_windows_msvc,
llvm_components_contain, target, uname,
};

View file

@ -46,6 +46,12 @@ pub fn is_aix() -> bool {
target().contains("aix")
}
/// Check if target is arm64ec.
#[must_use]
pub fn is_arm64ec() -> bool {
target().starts_with("arm64ec")
}
/// Get the target OS on Apple operating systems.
#[must_use]
pub fn apple_os() -> &'static str {

View file

@ -7,7 +7,7 @@
use std::path::PathBuf;
use run_make_support::{cc, cmd, env_var, extra_c_flags, rustc};
use run_make_support::{cc, cmd, env_var, extra_linker_flags, rustc};
fn main() {
// Build the staticlib
@ -31,7 +31,7 @@ fn main() {
// Otherwise the actual test failure may be caused by something else.
cmd(&linker)
.args(["c.obj", "./static.lib", "-dll", "-def:dll.def", "-out:dll.dll"])
.args(extra_c_flags())
.args(extra_linker_flags())
.run();
// FIXME(@ChrisDenton): this doesn't currently work with llvm's lld-link for other reasons.
@ -46,7 +46,7 @@ fn main() {
"-def:dll.def",
"-out:dll_whole_archive.dll",
])
.args(extra_c_flags())
.args(extra_linker_flags())
.run();
}
}