Skip to content
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

Update android.nix #1343

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions builder/comp-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
'');

Expand Down
2 changes: 1 addition & 1 deletion modules/plan.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 14 additions & 3 deletions overlays/android.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@ 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
postConfigure = ''
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; };
})
1 change: 1 addition & 0 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
6 changes: 3 additions & 3 deletions overlays/patches/ghc/ghc-8.10.7-linker-weak-and-common.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -186,4 +186,4 @@ index fdfe87a..c3f9110 100644
+ }
}
}
}
}
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;
13 changes: 13 additions & 0 deletions overlays/patches/numactl-2.0.14-no-librt.patch
Original file line number Diff line number Diff line change
@@ -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