diff --git a/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs b/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs index ac7392641c0d7..5c980068e4bdd 100644 --- a/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs +++ b/src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs @@ -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() { diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs index b7d89b130c6ba..191e205f2577f 100644 --- a/src/tools/run-make-support/src/lib.rs +++ b/src/tools/run-make-support/src/lib.rs @@ -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, }; diff --git a/src/tools/run-make-support/src/targets.rs b/src/tools/run-make-support/src/targets.rs index b20e12561fbfa..6288f5f7c59da 100644 --- a/src/tools/run-make-support/src/targets.rs +++ b/src/tools/run-make-support/src/targets.rs @@ -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 { diff --git a/tests/run-make/msvc-wholearchive/rmake.rs b/tests/run-make/msvc-wholearchive/rmake.rs index 98586fd8cc8bd..aec9391a420df 100644 --- a/tests/run-make/msvc-wholearchive/rmake.rs +++ b/tests/run-make/msvc-wholearchive/rmake.rs @@ -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(); } }