From 572ca1eb748f14b29b240a5028d72908fc4517f9 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Fri, 19 Sep 2025 04:58:26 +0000 Subject: [PATCH 1/3] rustc_codegen_llvm: Split "Fixed in LLVM 20" cases ... in `update_target_reliable_float_cfg`, based on the actual changes. The AArch64 issue is fixed on LLVM 20.1.1 while the MIPS issue is fixed on LLVM 20.1.0 (the first LLVM 20 release). This commit distinguishes two separate cases. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 2e1d0cfada5b5..adb1ac09a633a 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -364,11 +364,12 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { let target_abi = &sess.target.options.abi; let target_pointer_width = sess.target.pointer_width; let version = get_version(); + let lt_20_1_0 = version < (20, 1, 0); let lt_20_1_1 = version < (20, 1, 1); let lt_21_0_0 = version < (21, 0, 0); cfg.has_reliable_f16 = match (target_arch, target_os) { - // LLVM crash without neon (fixed in llvm20) + // LLVM crash without neon (fixed in LLVM 20.1.1) (Arch::AArch64, _) if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 => { @@ -395,8 +396,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { cfg.has_reliable_f128 = match (target_arch, target_os) { // Unsupported (Arch::Arm64EC, _) => false, - // Selection bug (fixed in llvm20) - (Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_1 => false, + // Selection bug (fixed in LLVM 20.1.0) + (Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_0 => false, // Selection bug . This issue is closed // but basic math still does not work. (Arch::Nvptx64, _) => false, From 28203e182f0d74577fee90d4fccd52fa98f72f07 Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Fri, 19 Sep 2025 04:14:10 +0000 Subject: [PATCH 2/3] rustc_codegen_llvm: Simplify `update_target_reliable_float_cfg` This commit simplifies floating type handling through `update_target_reliable_float_cfg` based on several facts: 1. Major changes in behavior normally occurs only on the major LLVM upgrade. 2. The first release of LLVM 20.x.x is 20.1.0. Due to the first fact, we can normally ignore minor and patch releases of LLVM and we can remove obscure variables like `lt_xx_x_x` (still, there is a case where checking for patch version is required). The second fact is missed when the minimum LLVM version is raised to LLVM 20 and one "fixed in LLVM 20" case can be safely removed. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index adb1ac09a633a..a3b1de9c3878a 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -364,26 +364,25 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { let target_abi = &sess.target.options.abi; let target_pointer_width = sess.target.pointer_width; let version = get_version(); - let lt_20_1_0 = version < (20, 1, 0); - let lt_20_1_1 = version < (20, 1, 1); - let lt_21_0_0 = version < (21, 0, 0); + let (major, _, _) = version; cfg.has_reliable_f16 = match (target_arch, target_os) { // LLVM crash without neon (fixed in LLVM 20.1.1) (Arch::AArch64, _) - if !cfg.target_features.iter().any(|f| f.as_str() == "neon") && lt_20_1_1 => + if !cfg.target_features.iter().any(|f| f.as_str() == "neon") + && version < (20, 1, 1) => { false } // Unsupported (Arch::Arm64EC, _) => false, // Selection failure (fixed in llvm21) - (Arch::S390x, _) if lt_21_0_0 => false, + (Arch::S390x, _) if major < 21 => false, // MinGW ABI bugs (Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false, // Infinite recursion (Arch::CSky, _) => false, - (Arch::Hexagon, _) if lt_21_0_0 => false, // (fixed in llvm21) + (Arch::Hexagon, _) if major < 21 => false, // (fixed in llvm21) (Arch::PowerPC | Arch::PowerPC64, _) => false, (Arch::Sparc | Arch::Sparc64, _) => false, (Arch::Wasm32 | Arch::Wasm64, _) => false, @@ -397,7 +396,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { // Unsupported (Arch::Arm64EC, _) => false, // Selection bug (fixed in LLVM 20.1.0) - (Arch::Mips64 | Arch::Mips64r6, _) if lt_20_1_0 => false, + (Arch::Mips64 | Arch::Mips64r6, _) if version < (20, 1, 0) => false, // Selection bug . This issue is closed // but basic math still does not work. (Arch::Nvptx64, _) => false, @@ -410,7 +409,7 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { (Arch::Sparc, _) => false, // Stack alignment bug . NB: tests may // not fail if our compiler-builtins is linked. (fixed in llvm21) - (Arch::X86, _) if lt_21_0_0 => false, + (Arch::X86, _) if major < 21 => false, // MinGW ABI bugs (Arch::X86_64, Os::Windows) if *target_env == Env::Gnu && *target_abi != Abi::Llvm => false, // There are no known problems on other platforms, so the only requirement is that symbols From 42d9f099e0f703bf681ab5e5fa502193bab7ad9e Mon Sep 17 00:00:00 2001 From: Tsukasa OI Date: Fri, 19 Sep 2025 04:14:10 +0000 Subject: [PATCH 3/3] rustc_codegen_llvm: Reorder by arch in `update_target_reliable_float_cfg` This commit reorders certain match clauses in `update_target_reliable_float_cfg` by the architecture when there's no problems reordering it. --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index a3b1de9c3878a..a5a8f8e6a25e8 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -393,6 +393,8 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { }; cfg.has_reliable_f128 = match (target_arch, target_os) { + // Unsupported https://github.com/llvm/llvm-project/issues/121122 + (Arch::AmdGpu, _) => false, // Unsupported (Arch::Arm64EC, _) => false, // Selection bug (fixed in LLVM 20.1.0) @@ -400,8 +402,6 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) { // Selection bug . This issue is closed // but basic math still does not work. (Arch::Nvptx64, _) => false, - // Unsupported https://github.com/llvm/llvm-project/issues/121122 - (Arch::AmdGpu, _) => false, // ABI bugs et al. (full // list at ) (Arch::PowerPC | Arch::PowerPC64, _) => false,