Skip to content

Commit d99ccd9

Browse files
authored
Backport fix for m32_allocator_init to GHC 9.2 (#1956)
* Backport fix for m32_allocator_init to GHC 9.2 See https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10453 * Add missing #include * Expose bignum backendName on ghc 9.2
1 parent cff2bc0 commit d99ccd9

File tree

4 files changed

+1545
-1
lines changed

4 files changed

+1545
-1
lines changed

overlays/bootstrap.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ in {
154154
++ final.lib.optional (versionAtLeast "9.2.1" && versionLessThan "9.3" && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-9.2-3434.patch
155155

156156
++ fromUntil "8.10.1" "9.4" ./patches/ghc/ghc-acrt-iob-func.patch
157-
++ fromUntil "8.10.1" "9.4" ./patches/ghc/ghc-mprotect-nonzero-len.patch
157+
++ fromUntil "8.10.1" "9.2" ./patches/ghc/ghc-mprotect-nonzero-len.patch
158+
++ fromUntil "9.2" "9.4" ./patches/ghc/ghc-9.2-fix-m32_allocator_init-10453.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10453
159+
++ fromUntil "9.2" "9.4" ./patches/ghc/ghc-9.2-fix-m32_allocator_init-10453-2.patch
160+
++ fromUntil "9.2" "9.4" ./patches/ghc/ghc-9.2-bignum-expose-backendName.patch # https://gitlab.haskell.org/ghc/ghc/-/commit/bc498fdfa482dfe796e3a12ac8f9d71913930740
158161

159162
++ fromUntil "8.10.1" "8.10.3" ./patches/ghc/ghc-8.10-ubxt.patch
160163
++ fromUntil "8.10.3" "8.10.5" ./patches/ghc/ghc-8.10.3-ubxt.patch
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
diff --git a/libraries/ghc-bignum/changelog.md b/libraries/ghc-bignum/changelog.md
2+
index 68f98d3adc0c597f3565eb4b6d0f2dd9b02be7fa..015721d40bfb281cd3dfe550d2507aa59554fee8 100644
3+
--- a/libraries/ghc-bignum/changelog.md
4+
+++ b/libraries/ghc-bignum/changelog.md
5+
@@ -1,5 +1,9 @@
6+
# Changelog for `ghc-bignum` package
7+
8+
+## 1.3
9+
+
10+
+- Expose backendName
11+
+
12+
## 1.2
13+
14+
- Moved naturalToDouble# and naturalToFloat# to `base` package
15+
diff --git a/libraries/ghc-bignum/ghc-bignum.cabal b/libraries/ghc-bignum/ghc-bignum.cabal
16+
index 468c2a042a2cf1ccc0bbaca799034e001b17290c..59ba8472724a3f190d305fe1c85078a494f074c5 100644
17+
--- a/libraries/ghc-bignum/ghc-bignum.cabal
18+
+++ b/libraries/ghc-bignum/ghc-bignum.cabal
19+
@@ -1,6 +1,6 @@
20+
cabal-version: 2.0
21+
name: ghc-bignum
22+
-version: 1.2
23+
+version: 1.3
24+
synopsis: GHC BigNum library
25+
license: BSD3
26+
license-file: LICENSE
27+
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs
28+
index b23fd1cb21965faf9cf0d16e14fc681a7f5e7ee0..00930a62bfd17a724dc085607ab32f74337cfdc3 100644
29+
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs
30+
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/Check.hs
31+
@@ -12,6 +12,7 @@
32+
-- | Check Native implementation against another backend
33+
module GHC.Num.Backend.Check where
34+
35+
+import GHC.CString
36+
import GHC.Prim
37+
import GHC.Types
38+
import GHC.Num.WordArray
39+
@@ -27,6 +28,12 @@ import qualified GHC.Num.Backend.Selected as Other
40+
41+
default ()
42+
43+
+-- | ghc-bignum backend name
44+
+backendName :: [Char]
45+
+backendName = unpackAppendCString# "check-"# Other.backendName
46+
+ -- we don't have (++) at our disposal, so we directly use
47+
+ -- `unpackAppendCString#`
48+
+
49+
bignat_compare
50+
:: WordArray#
51+
-> WordArray#
52+
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs
53+
index 21d74ee3e49b236f81ddc07ef322f7d96083069f..30fcc576cbb8e46e5efe7c4dd1220ada0d725fee 100644
54+
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs
55+
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/FFI.hs
56+
@@ -25,6 +25,10 @@ import {-# SOURCE #-} GHC.Num.Integer
57+
58+
default ()
59+
60+
+-- | ghc-bignum backend name
61+
+backendName :: [Char]
62+
+backendName = "ffi"
63+
+
64+
-- | Compare two non-zero BigNat of the same length
65+
--
66+
-- Return:
67+
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
68+
index 3fd4394bcf367a6e0c616a73a0a62b6224fa602e..48f5f8a90e9df51da99007967dfb0d8ab3440469 100644
69+
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
70+
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/GMP.hs
71+
@@ -32,6 +32,10 @@ import {-# SOURCE #-} GHC.Num.Natural
72+
73+
default ()
74+
75+
+-- | ghc-bignum backend name
76+
+backendName :: [Char]
77+
+backendName = "gmp"
78+
+
79+
----------------------------------------------------------------------------
80+
-- type definitions
81+
82+
diff --git a/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs b/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
83+
index 723096544a0bc12064821625c425d434fd4464a0..da08c55dd19bea27ed3c1a5ea323ef09c4e27133 100644
84+
--- a/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
85+
+++ b/libraries/ghc-bignum/src/GHC/Num/Backend/Native.hs
86+
@@ -30,6 +30,11 @@ import GHC.Types
87+
88+
default ()
89+
90+
+-- | ghc-bignum backend name
91+
+backendName :: [Char]
92+
+backendName = "native"
93+
+
94+
+
95+
count_words_bits :: Word# -> (# Word#, Word# #)
96+
count_words_bits n = (# nw, nb #)
97+
where
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/rts/linker/MachO.c b/rts/linker/MachO.c
2+
index 805731ba56..e54e7e44ac 100644
3+
--- a/rts/linker/MachO.c
4+
+++ b/rts/linker/MachO.c
5+
@@ -11,6 +11,7 @@
6+
#include "linker/MachO.h"
7+
#include "linker/CacheFlush.h"
8+
#include "linker/SymbolExtras.h"
9+
+#include "linker/MMap.h"
10+
11+
#include <string.h>
12+
#include <regex.h>

0 commit comments

Comments
 (0)