From 950b09642f532d445f6796cf2366b51593240e3a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 27 Jun 2025 20:24:01 -0500 Subject: [PATCH 1/2] Disable f16 on Aarch64 without neon for llvm < 20.1.1 This check was added unconditionally in c51b229140 ("Disable f16 on Aarch64 without `neon`") and reverted in 4a8d35709e ("Revert "Disable `f16` on Aarch64 without `neon`"") since it did not fail in Rust's build. However, it is still possible to hit this crash if using LLVM 19 built with assertions, so disable the type conditionally based on version here. Note that for these builds, a similar patch is needed in the build script for `compiler-builtins` since it does not yet use `cfg(target_has_reliable_f16)` (hopefully to be resolved in the near future). Report: https://www.github.com/rust-lang/rust/pull/139276#issuecomment-3014781652 Original LLVM issue: https://www.github.com/llvm/llvm-project/issues/129394 --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 6fd07d562afd8..edf0cbe0f8532 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -370,10 +370,18 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { let target_env = sess.target.options.env.as_ref(); let target_abi = sess.target.options.abi.as_ref(); let target_pointer_width = sess.target.pointer_width; + let version = get_version(); cfg.has_reliable_f16 = match (target_arch, target_os) { // Selection failure ("s390x", _) => false, + // LLVM crash without neon (now fixed) + ("aarch64", _) + if !sess.target_features.iter().any(|f| f.as_str() == "neon") + && version < (20, 1, 1) => + { + false + } // Unsupported ("arm64ec", _) => false, // MinGW ABI bugs From f717f44c5b560b6995842b75e6d74ca064216c84 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 29 Jun 2025 13:56:36 -0500 Subject: [PATCH 2/2] fixup! 950b09642f532d445f6796cf2366b51593240e3a Co-authored-by: Josh Stone --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index edf0cbe0f8532..0fb987bdf82ed 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -377,7 +377,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { ("s390x", _) => false, // LLVM crash without neon (now fixed) ("aarch64", _) - if !sess.target_features.iter().any(|f| f.as_str() == "neon") + if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && version < (20, 1, 1) => { false