on iko/ghcjs-patch-master help sign in
Patch for ghc 8.10.3 to make musl builds possible on aarch64 (#1029)

See https://github.com/input-output-hk/haskell.nix/issues/1027#issuecomment-772087166

commit40a26afa33b421d7ede240b5d6c2a9a22313cb2b authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateThu 4 Feb 2021, 01:55 (6 years ago) parent928bdb5
2 files changed+69−1
overlays/bootstrap.nix+1−1 overlays/patches/ghc/3434.patch+68
overlays/bootstrap.nix+1−1
@@ -135,7 +135,7 @@ in {
135135 ++ final.lib.optional (versionAtLeast "8.6.4" && versionLessThan "8.8") ./patches/ghc/ghc-no-system-linker.patch
136136
137137 ++ fromUntil "8.10.2" "8.10.3" ./patches/ghc/MR3714-backported-to-8.10.2.patch
138−
138+ ++ final.lib.optional (version == "8.10.3" && final.targetPlatform.isAarch64) ./patches/ghc/3434.patch
139139 ++ from "8.10.1" ./patches/ghc/ghc-acrt-iob-func.patch
140140
141141 ++ fromUntil "8.10.1" "8.10.3" ./patches/ghc/ghc-8.10-ubxt.patch
overlays/patches/ghc/3434.patchnew file+68
@@ -0,0 +1,68 @@
1+diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal
2+index c633124..2bd51c0 100644
3+--- a/libraries/ghc-prim/ghc-prim.cabal
4++++ b/libraries/ghc-prim/ghc-prim.cabal
5+@@ -70,7 +70,7 @@ Library
6+ if os(linux)
7+ -- we need libm, but for musl and other's we might need libc, as libm
8+ -- is just an empty shell.
9+- extra-libraries: c, m
10++ extra-libraries: gcc, c, m
11+
12+ c-sources:
13+ cbits/atomic.c
14+diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
15+index 9ca696c..b4a85e5 100644
16+--- a/rts/RtsSymbols.c
17++++ b/rts/RtsSymbols.c
18+@@ -1000,6 +1000,18 @@
19+ #define RTS_LIBGCC_SYMBOLS
20+ #endif
21+
22++
23++#if !defined(DYNAMIC) && defined(linux_HOST_OS)
24++// we need these for static musl builds. However when
25++// linking shared objects (DLLs) this will fail, hence
26++// we do not include them when building with -DDYNAMIC
27++#define RTS_LINKER_SYMBOLS \
28++ SymI_NeedsProto(__fini_array_start) \
29++ SymI_NeedsProto(__fini_array_end)
30++#else
31++#define RTS_LINKER_SYMBOLS
32++#endif
33++
34+ /* entirely bogus claims about types of these symbols */
35+ #define SymI_NeedsProto(vvv) extern void vvv(void);
36+ #define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
37+@@ -1028,6 +1040,7 @@ RTS_DARWIN_ONLY_SYMBOLS
38+ RTS_OPENBSD_ONLY_SYMBOLS
39+ RTS_LIBGCC_SYMBOLS
40+ RTS_LIBFFI_SYMBOLS
41++RTS_LINKER_SYMBOLS
42+ #undef SymI_NeedsProto
43+ #undef SymI_NeedsDataProto
44+ #undef SymI_HasProto
45+@@ -1068,6 +1081,8 @@ RTS_LIBFFI_SYMBOLS
46+ #define SymI_HasProto_deprecated(vvv) \
47+ { #vvv, (void*)0xBAADF00D, true },
48+
49++void *RTS_DYNAMIC = NULL;
50++
51+ RtsSymbolVal rtsSyms[] = {
52+ RTS_SYMBOLS
53+ RTS_RET_SYMBOLS
54+@@ -1078,6 +1093,7 @@ RtsSymbolVal rtsSyms[] = {
55+ RTS_OPENBSD_ONLY_SYMBOLS
56+ RTS_LIBGCC_SYMBOLS
57+ RTS_LIBFFI_SYMBOLS
58++ RTS_LINKER_SYMBOLS
59+ SymI_HasDataProto(nonmoving_write_barrier_enabled)
60+ #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH)
61+ // dyld stub code contains references to this,
62+@@ -1085,5 +1101,6 @@ RtsSymbolVal rtsSyms[] = {
63+ // lazy pointers as nonlazy.
64+ { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false },
65+ #endif
66++ { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false },
67+ { 0, 0, false } /* sentinel */
68+ };