Skip to content

android + ios: missing patches #1884

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 2 commits into from
Mar 18, 2023
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
4 changes: 4 additions & 0 deletions compiler/ghc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ let
SplitSections = NO
'' + lib.optionalString (!enableLibraryProfiling) ''
BUILD_PROF_LIBS = NO
'' + lib.optionalString (disableLargeAddressSpace) ''
libraries/base_CONFIGURE_OPTS += --configure-option=--with-libcharset=no
'';

# `--with` flags for libraries needed for RTS linker
Expand All @@ -198,6 +200,8 @@ let
"--enable-dwarf-unwind"
"--with-libdw-includes=${lib.getDev elfutils}/include"
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
] ++ lib.optionals (targetPlatform.isDarwin) [
"--without-libcharset"
];

# Splicer will pull out correct variations
Expand Down
2 changes: 2 additions & 0 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ in {
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAndroid && final.stdenv.targetPlatform.isAarch32) ./patches/ghc/libc-memory-symbols-armv7a.patch
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAndroid && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/libc-memory-symbols.patch
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAndroid) ./patches/ghc/android-base-needs-iconv.patch
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isAndroid) ./patches/ghc/ghc-8.10.7-weak-symbols-2.patch
++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.stdenv.targetPlatform.isDarwin && final.stdenv.targetPlatform.isAarch64) ./patches/ghc/ghc-8.10.7-rts-aarch64-darwin.patch
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.2" && final.stdenv.targetPlatform.isAndroid && final.stdenv.targetPlatform.isAarch32) ./patches/ghc/ghc-8.10-android.patch
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.2" && final.stdenv.targetPlatform.isAndroid && final.stdenv.targetPlatform.isAarch32) ./patches/ghc/ghc-8.10.7-android-bionic-symbols.patch
++ final.lib.optional (versionAtLeast "8.10.6" && versionLessThan "9.2" && final.stdenv.targetPlatform.isAndroid && final.stdenv.targetPlatform.isAarch32) ./patches/ghc/ghc-8.10.7-bionic-libc.patch
Expand Down
18 changes: 18 additions & 0 deletions overlays/patches/ghc/ghc-8.10.7-rts-aarch64-darwin.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 6d6ff4bb90..02d3c64ce9 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -415,6 +415,13 @@ rts_CC_OPTS += -fno-strict-aliasing

rts_CC_OPTS += -fno-common

+
+ifeq "$(TargetArch_CPP)" "aarch64"
+ifeq "$(TargetOS_CPP)" "darwin"
+rts_CC_OPTS += -mcpu=apple-a7 -march=armv8-a+norcpc
+endif
+endif
+
ifeq "$(BeConservative)" "YES"
rts_CC_OPTS += -DBE_CONSERVATIVE
endif
37 changes: 37 additions & 0 deletions overlays/patches/ghc/ghc-8.10.7-weak-symbols-2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/rts/Linker.c b/rts/Linker.c
index 727fe74..12a22d7 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1810,6 +1810,8 @@ static HsInt resolveObjs_ (void)
IF_DEBUG(linker, debugBelch("resolveObjs: start\n"));

for (ObjectCode *oc = objects; oc; oc = oc->next) {
+ if(oc->status == OBJECT_RESOLVED)
+ continue;
int r = ocTryLoad(oc);
if (!r)
{
diff --git a/rts/linker/Elf.c b/rts/linker/Elf.c
index c3f9110..1b497af 100644
--- a/rts/linker/Elf.c
+++ b/rts/linker/Elf.c
@@ -963,10 +963,15 @@ ocGetNames_ELF ( ObjectCode* oc )
stab[j].st_size, stab[j].st_value, nm);
}
*/
- symbol->addr = (SymbolAddr*)(
- (intptr_t) oc->sections[secno].start +
- (intptr_t) symbol->elf_sym->st_value);
- ASSERT(symbol->addr != 0x0);
+ if(shndx == SHN_UNDEF && ELF_ST_BIND(symbol->elf_sym->st_info) == STB_WEAK) {
+ symbol->addr = NULL;
+ } else {
+ symbol->addr = (SymbolAddr*)(
+ (intptr_t) oc->sections[secno].start +
+ (intptr_t) symbol->elf_sym->st_value);
+ ASSERT(symbol->addr != 0x0);
+ }
+
if (ELF_ST_BIND(symbol->elf_sym->st_info) == STB_LOCAL) {
isLocal = true;
isWeak = false;