nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 version,
4 fetchpatch,
5}:
6
7# Backports for LLVM support.
8#
9# These primarily focus on backporting patches that are relevant to
10# supporting newer LLVM versions, rather than aiming to backport every
11# LLVM backend bug fix or improvement from newer GHC releases.
12#
13# Potentially of interest for cross‐compiling GHC 9.4.8 to LoongArch64:
14#
15# * <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9292>
16# * <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13620>
17
18[ ]
19
20++ lib.optionals (lib.versionOlder version "9.6") [
21 # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9857>
22 (fetchpatch {
23 name = "ghc-9.4-llvm-support-15.patch";
24 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/0cc16aaf89d7dc3963764b7193ceac73e4e3329b.patch";
25 hash = "sha256-G0gqrj5iPuQ5JuC2+d151yka72XZMbrqMWPZd4EuT04=";
26 })
27
28 # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13763>
29 ./ghc-9.4-llvm-fix-version-detection.patch
30]
31
32++ lib.optionals (lib.versionOlder version "9.8") [
33 (
34 # The upstream backport of !13763 in 9.6.7 removed an unused import
35 # that is required by the next series.
36 if lib.versionOlder version "9.6" then null else ./ghc-9.6-llvm-restore-import.patch
37 )
38]
39
40++ lib.optionals (lib.versionOlder version "9.10") [
41 # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/11124>
42 (
43 if lib.versionOlder version "9.8" then
44 ./ghc-9.4-llvm-add-metadata-exports.patch
45 else
46 fetchpatch {
47 name = "ghc-9.8-llvm-add-metadata-exports.patch";
48 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/fcfc1777c22ad47613256c3c5e7304cfd29bc761.patch";
49 hash = "sha256-9rpyeH8TUVeKoW4PA6qn7DG2+P9MhBCywmbi1O/NsTQ=";
50 }
51 )
52 (
53 if lib.versionOlder version "9.8" then
54 ./ghc-9.4-llvm-allow-llvmlits-in-metaexprs.patch
55 else
56 fetchpatch {
57 name = "ghc-9.8-llvm-allow-llvmlits-in-metaexprs.patch";
58 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/5880fff6d353a14785c457999fded5a7100c9514.patch";
59 hash = "sha256-NDMGNc0PYpWJUW+nI2YvMsBOWRIfNix4oWHQZAIxrVY=";
60 }
61 )
62 (
63 # `GHC.Driver.DynFlags` was not split out until 9.8, so this can be
64 # omitted with no functional effect on the rest of the series on
65 # earlier versions.
66 if lib.versionOlder version "9.8" then
67 null
68 else
69 fetchpatch {
70 name = "ghc-9.8-move-feature-predicates-to-dynflags.patch";
71 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/86ce92a2f81a04aa980da2891d0e300cb3cb7efd.patch";
72 hash = "sha256-SzJgzq4b5wAMPz+/QSa67iSOxB2enqejvV0lsF0+9L8=";
73 }
74 )
75 (fetchpatch {
76 name = "ghc-9.4-llvm-add-module-flag-metadata-infra.patch";
77 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/a6a3874276ced1b037365c059dcd0a758e813a5b.patch";
78 hash = "sha256-tAYDRNXmpp5cZtyONpO8vlsDmnNEBbh4J3oSCy/uWWc=";
79 })
80 (
81 if lib.versionOlder version "9.8" then
82 ./ghc-9.4-llvm-fix-stack-alignment.patch
83 else
84 fetchpatch {
85 name = "ghc-9.8-llvm-fix-stack-alignment.patch";
86 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/e9af2cf3f16ab60b5c79ed91df95359b11784df6.patch";
87 hash = "sha256-RmYwFN3c3AgJxF9KXWQLdwOgugzepCW1wcTdJX1h0C4=";
88 }
89 )
90
91 # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/8999>
92 (
93 if lib.versionOlder version "9.6" then
94 ./ghc-9.4-llvm-use-new-pass-manager.patch
95 else if lib.versionOlder version "9.8" then
96 ./ghc-9.6-llvm-use-new-pass-manager.patch
97 else
98 ./ghc-9.8-llvm-use-new-pass-manager.patch
99 )
100]
101
102++ lib.optionals (lib.versionOlder version "9.12") [
103 # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12726>
104 (fetchpatch {
105 name = "ghc-9.4-llvm-support-16-17-18.patch";
106 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/ae170155e82f1e5f78882f7a682d02a8e46a5823.patch";
107 hash = "sha256-U1znWqXZTORmAg480p5TjTL53T2Zn+1+9Fnk2V1Drfs=";
108 })
109
110 # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13311>
111 (fetchpatch {
112 name = "ghc-9.4-llvm-support-19.patch";
113 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/36bbb167f354a2fbc6c4842755f2b1e374e3580e.patch";
114 excludes = [ ".gitlab-ci.yml" ];
115 hash = "sha256-v8T/FtriDPbibcIDZmU2yotBoDVo+wU2+gw+CCdQlm0=";
116 })
117]
118
119++ lib.optionals (lib.versionOlder version "9.14") [
120 # <https://gitlab.haskell.org/ghc/ghc/-/merge_requests/14600>
121 (fetchpatch {
122 name = "ghc-9.4-llvm-support-20.patch";
123 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/ca03226db2db2696460bfcb8035dd3268d546706.patch";
124 hash = "sha256-7cO049DQtJHUAhwPujoFO+zQtXsMg6VFTHtMDwenrKs=";
125 })
126]