diff --git a/builder/comp-builder.nix b/builder/comp-builder.nix index e6e5523403..c802574081 100644 --- a/builder/comp-builder.nix +++ b/builder/comp-builder.nix @@ -16,7 +16,7 @@ let self = , preUnpack ? component.preUnpack, postUnpack ? component.postUnpack , configureFlags ? component.configureFlags , preConfigure ? component.preConfigure, postConfigure ? component.postConfigure -, setupBuildFlags ? component.setupBuildFlags +, setupBuildFlags ? [] , preBuild ? component.preBuild , postBuild ? component.postBuild , preCheck ? component.preCheck , postCheck ? component.postCheck , setupInstallFlags ? component.setupInstallFlags @@ -437,17 +437,17 @@ let # See also https://gitlab.haskell.org/ghc/ghc/-/issues/12935 (if contentAddressed then '' runHook preBuild - $SETUP_HS build ${haskellLib.componentTarget componentId} -j1 ${lib.concatStringsSep " " setupBuildFlags} + $SETUP_HS build ${haskellLib.componentTarget componentId} -j1 ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupBuildFlags)} runHook postBuild '' else if stdenv.hostPlatform.isGhcjs then '' runHook preBuild # https://gitlab.haskell.org/ghc/ghc/issues/9221 - $SETUP_HS build ${haskellLib.componentTarget componentId} ${lib.concatStringsSep " " setupBuildFlags} + $SETUP_HS build ${haskellLib.componentTarget componentId} ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupBuildFlags)} runHook postBuild '' else '' runHook preBuild # https://gitlab.haskell.org/ghc/ghc/issues/9221 - $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " setupBuildFlags} + $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupBuildFlags)} runHook postBuild ''); diff --git a/modules/plan.nix b/modules/plan.nix index 4b1c2b6de8..036eba3090 100644 --- a/modules/plan.nix +++ b/modules/plan.nix @@ -253,7 +253,7 @@ let ''; }; planned = mkOption { - description = "Set to true by `plan-to-nix` for any component that was included in the `plan.json` file."; + description = "Set to true by `plan-to-nix` for any component that was included in the `plan.json` file."; # This is here so that (rather than in componentOptions) so it can be set project wide for stack projects type = bool; default = def.planned or false; diff --git a/overlays/android.nix b/overlays/android.nix index 036c7dcaff..5cd37b34d0 100644 --- a/overlays/android.nix +++ b/overlays/android.nix @@ -11,8 +11,9 @@ final: prev: prev.lib.optionalAttrs prev.stdenv.hostPlatform.isAndroid ({ ''; # my current thinking is that this is due to the android toolchain using r23, api30. }); - libffi = prev.libffi.overrideAttrs (_: { + libffi = prev.libffi.overrideAttrs ( old: { dontDisableStatic = true; + configureFlags = old.configureFlags ++ [ "--disable-shared" ]; hardeningDisable = [ "fortify" "stackprotector" "format" ]; # see libiconv. We want to target a lower minsdk @@ -20,9 +21,19 @@ final: prev: prev.lib.optionalAttrs prev.stdenv.hostPlatform.isAndroid ({ echo "#undef HAVE_MEMFD_CREATE" >> aarch64-unknown-linux-android/fficonfig.h ''; }); - gmp6 = (prev.gmp6.override { withStatic = true; }).overrideAttrs(_: { + gmp6 = (prev.gmp6.override { withStatic = true; }).overrideAttrs(old: { hardeningDisable = [ "fortify" "stackprotector" "format" ]; + configureFlags = old.configureFlags ++ [ "--disable-shared" ]; }); + + zlib = prev.zlib.override { shared = false; static = true; }; + + numactl = prev.numactl.overrideAttrs (attrs: { + patches = (attrs.patches or []) ++ [ ./patches/numactl-2.0.14-no-librt.patch ]; + }); + }) // prev.lib.optionalAttrs prev.stdenv.targetPlatform.isAndroid ({ - bionic = prev.bionic.override { enableStatic = true; }; + # we still need the shared libraries to link against on the platform. GHC + # has been neutered to not even try loading shared libs and will use dynamic ones. + bionic = prev.bionic.override { enableStatic = true; enableShared = true; }; }) diff --git a/overlays/bootstrap.nix b/overlays/bootstrap.nix index b2a0217ce6..12fd646a0c 100644 --- a/overlays/bootstrap.nix +++ b/overlays/bootstrap.nix @@ -228,6 +228,7 @@ in { ++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.targetPlatform.isAndroid) ./patches/ghc/ghc-8.10.7-linker-weak-and-common.patch ++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.targetPlatform.isAndroid) ./patches/ghc/libc-memory-symbols.patch ++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.targetPlatform.isAndroid) ./patches/ghc/android-base-needs-iconv.patch + ++ final.lib.optional (versionAtLeast "8.10" && versionLessThan "9.0" && final.targetPlatform.isAndroid) ./patches/ghc/ghc-8.10.7-weak-symbols-2.patch ; in ({ ghc844 = final.callPackage ../compiler/ghc (traceWarnOld "8.4" { diff --git a/overlays/patches/ghc/ghc-8.10.7-linker-weak-and-common.patch b/overlays/patches/ghc/ghc-8.10.7-linker-weak-and-common.patch index b416c6e2c4..09ce07e496 100644 --- a/overlays/patches/ghc/ghc-8.10.7-linker-weak-and-common.patch +++ b/overlays/patches/ghc/ghc-8.10.7-linker-weak-and-common.patch @@ -85,9 +85,9 @@ index fdfe87a..c3f9110 100644 + oc->common_mem = NULL; + oc->common_size = common_size; if(common_size > 0) { -- common_mem = mmapAnonForLinker(common_size); +- common_mem = mmapAnonForLinker(common_size, true, "anon:common_mem"); - if (common_mem == NULL) { -+ oc->common_mem = mmapAnonForLinker(common_size); ++ oc->common_mem = mmapAnonForLinker(common_size, true, "anon:common_mem"); + if (oc->common_mem == NULL) { barf("ocGetNames_ELF: Failed to allocate memory for SHN_COMMONs"); } @@ -186,4 +186,4 @@ index fdfe87a..c3f9110 100644 + } } } - } \ 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; diff --git a/overlays/patches/numactl-2.0.14-no-librt.patch b/overlays/patches/numactl-2.0.14-no-librt.patch new file mode 100644 index 0000000000..3e63c32e3b --- /dev/null +++ b/overlays/patches/numactl-2.0.14-no-librt.patch @@ -0,0 +1,13 @@ +diff --git a/Makefile.am b/Makefile.am +index 44d0d76..1181ca5 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -34,7 +34,7 @@ migratepages_SOURCES = migratepages.c util.c + migratepages_LDADD = libnuma.la + + migspeed_SOURCES = migspeed.c util.c +-migspeed_LDADD = libnuma.la -lrt ++migspeed_LDADD = libnuma.la + + memhog_SOURCES = memhog.c util.c + memhog_LDADD = libnuma.la