From 4f7c60edb1be8201c9de8011b99fa904055bc243 Mon Sep 17 00:00:00 2001 From: whispers Date: Wed, 15 Jul 2026 10:25:53 -0400 Subject: [PATCH 1/2] llvm_22: pick patch for selectiondag freeze condition miscompile see https://github.com/NixOS/nixpkgs/commit/f8a025c9646e61bc992f4f3d76dd4193d749f417. this commit backports that same change to LLVM 22. the fix is not available upstream since LLVM 22 is EOL, but we can pick the patch from the Rust fork of LLVM, as that is currently on version 22.1. --- .../compilers/llvm/common/llvm/default.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/development/compilers/llvm/common/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix index 2b872a8a45c8..c84539690668 100644 --- a/pkgs/development/compilers/llvm/common/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -234,6 +234,18 @@ stdenv.mkDerivation ( # LLVM issue: https://github.com/llvm/llvm-project/issues/208611 # LLVM PR: https://github.com/llvm/llvm-project/pull/208683 (getVersionFile "llvm/sdag-freeze-condition-in-select-of-load-fold.patch") + ] + ++ lib.optionals (lib.versions.major release_version == "22") [ + # Same issue and fix as above, for LLVM 22. While LLVM 22 was EOL at + # the time of the LLVM PR, and was thus not backported upstream, the + # backport was made to Rust's LLVM fork on LLVM 22.1. Accordingly, we + # fetch the patch from there. + (fetchpatch { + name = "llvm-22-sdag-freeze-condition-in-select-of-load-fold.patch"; + url = "https://github.com/rust-lang/llvm-project/commit/abcef279cd33492fe8301c8873fc535fa4dbf0d5.patch"; + stripLen = 1; + hash = "sha256-HHVMVL7ZWiZkbfnD37zYxFWnfvI3LNS0Z2oFHhOaZsU="; + }) ]; nativeBuildInputs = [ From 28e45056984f078671a9732253b51b8b8ba657a0 Mon Sep 17 00:00:00 2001 From: whispers Date: Wed, 15 Jul 2026 10:31:26 -0400 Subject: [PATCH 2/2] llvm: add comment about backport selectiondag miscompile fix --- pkgs/development/compilers/llvm/common/llvm/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/development/compilers/llvm/common/llvm/default.nix b/pkgs/development/compilers/llvm/common/llvm/default.nix index c84539690668..74badbfbd169 100644 --- a/pkgs/development/compilers/llvm/common/llvm/default.nix +++ b/pkgs/development/compilers/llvm/common/llvm/default.nix @@ -230,6 +230,10 @@ stdenv.mkDerivation ( # segfaulting code. The patch was made to LLVM 23, but the tests have # many conflicts, so we vendor a version-specific modified version. # + # This should be backported to older LLVM versions as well, but this + # has not yet been done in order to ship the more important fixes + # quickly. + # # Rust issue: https://github.com/rust-lang/rust/issues/159035 # LLVM issue: https://github.com/llvm/llvm-project/issues/208611 # LLVM PR: https://github.com/llvm/llvm-project/pull/208683