about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-08 12:52:54 +1000
committerGitHub <noreply@github.com>2025-08-08 12:52:54 +1000
commit2edfd3636117db8f57cc49c3a0b786c6245b0617 (patch)
tree8fdf954fb681741cbe2f1dafd1cda6b102ca191b /src
parentbdb082b7639de67e421a3d32c331949654460cec (diff)
parent36383dd2b8e1eeb18c018f1db324425f4355fe10 (diff)
downloadrust-2edfd3636117db8f57cc49c3a0b786c6245b0617.tar.gz
rust-2edfd3636117db8f57cc49c3a0b786c6245b0617.zip
Rollup merge of #144931 - dpaoliello:msvc-wholearchive, r=jieyouxu
[win][arm64ec] Fix msvc-wholearchive for Arm64EC

`msvc-wholearchive` was failing on Arm64EC Windows as it requires the `/MACHINE:ARM64EC` flag to be passed to the MSVC linker.

This required splitting the `extra_c_flags` function into a new `extra_linker_flags` function as `/MACHINE:ARM64EC` is not a valid argument to be passed to the MSVC Compiler (instead, `/arm64EC` should be used).
Diffstat (limited to 'src')
-rw-r--r--src/tools/run-make-support/src/external_deps/c_cxx_compiler/extras.rs32
-rw-r--r--src/tools/run-make-support/src/lib.rs4
-rw-r--r--src/tools/run-make-support/src/targets.rs6
3 files changed, 34 insertions, 8 deletions
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 ac7392641c0..5c980068e4b 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 b7d89b130c6..191e205f257 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 b20e12561fb..6288f5f7c59 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 {