Skip to content

Patch for ghc 8.10.3 to make musl builds possible on aarch64 #1029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ in {
++ final.lib.optional (versionAtLeast "8.6.4" && versionLessThan "8.8") ./patches/ghc/ghc-no-system-linker.patch

++ fromUntil "8.10.2" "8.10.3" ./patches/ghc/MR3714-backported-to-8.10.2.patch

++ final.lib.optional (version == "8.10.3" && final.targetPlatform.isAarch64) ./patches/ghc/3434.patch
++ from "8.10.1" ./patches/ghc/ghc-acrt-iob-func.patch

++ fromUntil "8.10.1" "8.10.3" ./patches/ghc/ghc-8.10-ubxt.patch
Expand Down
68 changes: 68 additions & 0 deletions overlays/patches/ghc/3434.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal
index c633124..2bd51c0 100644
--- a/libraries/ghc-prim/ghc-prim.cabal
+++ b/libraries/ghc-prim/ghc-prim.cabal
@@ -70,7 +70,7 @@ Library
if os(linux)
-- we need libm, but for musl and other's we might need libc, as libm
-- is just an empty shell.
- extra-libraries: c, m
+ extra-libraries: gcc, c, m

c-sources:
cbits/atomic.c
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 9ca696c..b4a85e5 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -1000,6 +1000,18 @@
#define RTS_LIBGCC_SYMBOLS
#endif

+
+#if !defined(DYNAMIC) && defined(linux_HOST_OS)
+// we need these for static musl builds. However when
+// linking shared objects (DLLs) this will fail, hence
+// we do not include them when building with -DDYNAMIC
+#define RTS_LINKER_SYMBOLS \
+ SymI_NeedsProto(__fini_array_start) \
+ SymI_NeedsProto(__fini_array_end)
+#else
+#define RTS_LINKER_SYMBOLS
+#endif
+
/* entirely bogus claims about types of these symbols */
#define SymI_NeedsProto(vvv) extern void vvv(void);
#define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
@@ -1028,6 +1040,7 @@ RTS_DARWIN_ONLY_SYMBOLS
RTS_OPENBSD_ONLY_SYMBOLS
RTS_LIBGCC_SYMBOLS
RTS_LIBFFI_SYMBOLS
+RTS_LINKER_SYMBOLS
#undef SymI_NeedsProto
#undef SymI_NeedsDataProto
#undef SymI_HasProto
@@ -1068,6 +1081,8 @@ RTS_LIBFFI_SYMBOLS
#define SymI_HasProto_deprecated(vvv) \
{ #vvv, (void*)0xBAADF00D, true },

+void *RTS_DYNAMIC = NULL;
+
RtsSymbolVal rtsSyms[] = {
RTS_SYMBOLS
RTS_RET_SYMBOLS
@@ -1078,6 +1093,7 @@ RtsSymbolVal rtsSyms[] = {
RTS_OPENBSD_ONLY_SYMBOLS
RTS_LIBGCC_SYMBOLS
RTS_LIBFFI_SYMBOLS
+ RTS_LINKER_SYMBOLS
SymI_HasDataProto(nonmoving_write_barrier_enabled)
#if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH)
// dyld stub code contains references to this,
@@ -1085,5 +1101,6 @@ RtsSymbolVal rtsSyms[] = {
// lazy pointers as nonlazy.
{ "dyld_stub_binding_helper", (void*)0xDEADBEEF, false },
#endif
+ { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false },
{ 0, 0, false } /* sentinel */
};