diff --git a/compiler/ghc/default.nix b/compiler/ghc/default.nix index 5b66e57d90..7718fdc8be 100644 --- a/compiler/ghc/default.nix +++ b/compiler/ghc/default.nix @@ -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 @@ -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 diff --git a/overlays/bootstrap.nix b/overlays/bootstrap.nix index 2a6d75ac84..af30818852 100644 --- a/overlays/bootstrap.nix +++ b/overlays/bootstrap.nix @@ -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 diff --git a/overlays/patches/ghc/ghc-8.10.7-rts-aarch64-darwin.patch b/overlays/patches/ghc/ghc-8.10.7-rts-aarch64-darwin.patch new file mode 100644 index 0000000000..04d527a098 --- /dev/null +++ b/overlays/patches/ghc/ghc-8.10.7-rts-aarch64-darwin.patch @@ -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 \ No newline at end of file diff --git a/overlays/patches/ghc/ghc-8.10.7-weak-symbols-2.patch b/overlays/patches/ghc/ghc-8.10.7-weak-symbols-2.patch new file mode 100644 index 0000000000..32d493dfa9 --- /dev/null +++ b/overlays/patches/ghc/ghc-8.10.7-weak-symbols-2.patch @@ -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;