about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-05-08 13:55:45 +0200
committerGitHub <noreply@github.com>2025-05-08 13:55:45 +0200
commit54f1da448601c63c45bdd3ba6380fb07cdf40919 (patch)
tree61c6722173c3bd447e69ed83473fc3fd5165759a
parent12d6a47bda0110b82a191a293bb0a41e5c0ce878 (diff)
parent75ca6c621e08eb7252bb542b9264e7ab7a8fc4e1 (diff)
downloadrust-54f1da448601c63c45bdd3ba6380fb07cdf40919.tar.gz
rust-54f1da448601c63c45bdd3ba6380fb07cdf40919.zip
Rollup merge of #140758 - dpaoliello:armhazard, r=jieyouxu
[win][arm64] Disable MSVC Linker 'Arm Hazard' warning

While trying to get the aarch64-msvc build working correctly (#140136), I observed the following test failure:

From <https://github.com/rust-lang/rust/pull/140136#issuecomment-2848179657>

```
  = note: main.main.d17f5fbe6225cf88-cgu.0.rcgu.o : fatal error LNK1322: cannot avoid potential ARM hazard (Cortex-A53 MPCore processor bug #843419) in section 0x57; please consider using compiler option /Gy if it was not used
```

This is warning of a code sequence that triggers a bug in Cortex-A53 processors: <https://developer.arm.com/documentation/epm048406/latest>

However, since Windows 10 isn't supported on the Cortex-A53, this warning is not required, so it can be suppressed using the undocumented `/arm64hazardfree` flag.
-rw-r--r--compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs
index 98d78520c98..0d25b19f3fc 100644
--- a/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs
+++ b/compiler/rustc_target/src/spec/targets/aarch64_pc_windows_msvc.rs
@@ -1,10 +1,15 @@
-use crate::spec::{Target, TargetMetadata, base};
+use crate::spec::{LinkerFlavor, Lld, Target, TargetMetadata, base};
 
 pub(crate) fn target() -> Target {
     let mut base = base::windows_msvc::opts();
     base.max_atomic_width = Some(128);
     base.features = "+v8a,+neon,+fp-armv8".into();
 
+    // MSVC emits a warning about code that may trip "Cortex-A53 MPCore processor bug #843419" (see
+    // https://developer.arm.com/documentation/epm048406/latest) which is sometimes emitted by LLVM.
+    // Since Arm64 Windows 10+ isn't supported on that processor, it's safe to disable the warning.
+    base.add_pre_link_args(LinkerFlavor::Msvc(Lld::No), &["/arm64hazardfree"]);
+
     Target {
         llvm_target: "aarch64-pc-windows-msvc".into(),
         metadata: TargetMetadata {