Skip to content

Commit 9d55e30

Browse files
angermanshumvgolovehamishmack
authored
Add better support for armv7a cross compilation (#1874)
* Support for armv7a-bionic (android) This adds support to haskell.nix for building for armv7a-android. It includes - various minor fixes - a lot of bionic (libc) patches for ghc - no gold on 32bit android - android overlay: mostly static - disable KTLS on openssl for android * allow setupBuildFlags on components and packages * android + ios: missing patches (#1884) * android: missing patches * ios: missing patches * Fix hadrian naming convenction cabal ends up with aarch64-android whereas hadrian ends up with aarch64-linux_android * Fix format * newlines * WIP tools * Add iserv logic * WIP * Fix 9.6.3 aarch64 outline atomics * Better patch * Better linux cross * Fix ghc:-dynamic-system-linker for android * Fixup arm * Patch only for aarch64 * add aggregated ghc-9.6 patch * More android patches * Adds genapply patch for 9.6 GenApply suffers from having GHC pollute its defines. * Add [PATCH] AArch64: Fix broken conditional jumps for offsets >= 1MB This is added for aarch64 for now only as that's the only affeted platform. * Update default.nix * fix native musl * add debug secno patch * fix musl being considered stage2 * Allow undefined weak symbols. * Map missing symbols to 0xDEADBEEF. * Set -dynamic-system-linker if musl and not x86_64 * proper parens * Add i686 cross * more patches * 🤦 * patch interpreter also for windows. * No dynamic loading on x86. * 🤦 * Sigh * Disable linux cross patch for now. * Fix 32bit patch * No symbol loading on darwin. The weak logic doesn't seem to work well there. * all ghc c files apple-a7 * Drop duplicate patch * Fixup compilers * Update nixpkgs pins * ifdLevel 0 * Simplify bootPkgs * Update materialized files * Bump nixpkgs-unstable and ghc911 * Simplify bootPkgs * Simplify bootPkgs * Update ghc911 * Reduce the number of compilers tested * Bump llvm for ghc >=9.10 * Update patch upper bounds * Include clang for useLLVM GHC * ifdLevel 1 * Add materialized files * Disable haskell-gi-overloading (it's too slow to build) * Update patch upper bound * ifdLevel 2 * Fixes for GHC HEAD * ifdLevel 3 * Fixes for GHC HEAD * Fix supported-languages for GHC HEAD * More fixes for GHC HEAD * Possible fix for plugin failure on aarch64-darwin * ifdLevel 0 * ifdLevel 3 * Add emar and emranlib to ghc js builds * Fix `repo-tar` downloads * Fix `repo-tar` downloads * More fixes for ghc HEAD * Fix for GHC 9.6 JS backend * Fix for GHC HEAD JS * fix syntax errors * ifdLevel 0 * Disable darwin on hydra for now. * ifdLevel 1 * ifdLevel 2 * ifdLevel 3 * Fix eval * Fix patches * Fix patches * ifdLevel 0 * ifdLevel 1 * ifdLevel 2 * ifdLevel 3 * Add upper bound for patch * Add ArchX86 and ArchRISCV64 * Fix logic for iserv-syms.patch * Fix logic for iserv-syms.patch * Remove old patch. Latest upstream GHC >9.6 have a better one. * ifdLevel 0 * ifdLevel 1 * Fix hadrian strip patch * Fix hadrian strip patch * Fix haddock (now that isNativeMusl works correctly) * Fix haddock (now that isNativeMusl works correctly) * Avoid building source-pins on hackage (just make sure the components needed are present). * ifdLevel 2 * Fix for native musl builds * ifdLevel 3 * Add musl32 and android tests * Add AArch32 to call-cabal-project-to-nix.nix * Update iserv-proxy patches * Fix duplication of patch in overlays/bootstrap.nix * Add missing materialized file * Remove patch already in 9.2.8 * Build android compilers with nixpkgs 24.05 * Fix gi-gtk test * Fix eval * Try aarch64-android-prebuilt * ifdLevel 1 * Disable ncurses on android for now * Fix patch * Use aarch64-android (not prebuilt) * Fixes for armv7a * Fixes for armv7a * Fix ghc-9.6-32bit-cmm.patch bounds * Fix genapply patch bound * Try Android SDK version 26 * Try Android SDK version 26 * Try Android SDK version 26 * Use small address space * Use small address space * androidNdkVersion = "24" * Fix android sdk/ndk pins so they work for ci.nix * Add missing casts * Add preBuild to set CFLAGS * Better fix? * Better fix? * Support Cabal calling configure with "--host=arm-android" * Fix ghc 9.8 * Fix for ghc >9.10 * Fix patch error * Possible fix for aarch64 android * Fix patches for GHC 8.10 * Try aarch64-android-prebuilt * Include clang * Don't include clang for prebuilt android * Set `LLVMAS` * Setting LLVMAS to `llvm-as` did not help * Set `LLVMAS` the same as `CC` * Relax llvm max version * Try with llvm version bound relaxed, but without LLVMAS env var * Define ELF64_ST_VISIBILITY and ELF32_ST_VISIBILITY for android * ifdLevel 2 * ifdLevel 3 * ifdLevel 2 * ifdLevel 3 * Fix for android ioctl issue * Skip running tests for aarch64-android * Same problem for armv7a * Fixes from aarch64 android * Fixes from armv7a android * Test android on nixpkgs 24.11 * musl fix * Fix musl64 unlit not found issue * nix flake update iserv-proxy * nix flake update nixpkgs-2411 * nix flake update iserv-proxy * Disable x86_64-darwin.R2411 tests (strangely broken) * Add patch to load archive script See https://gitlab.haskell.org/ghc/ghc/-/issues/16130 * Fix for libsodium on android * Move libsodium fix to test/modules.nix * Fix darwin builds for nixpkgs 24.11 * nix flake update iserv-proxy * Move iserv-proxy-interpreter overrides into overlays/haskell.nix * Move iserv-proxy-interpreter overrides into overlays/haskell.nix * nix flake update iserv-proxy * Disable musl32 tests (unhandled ELF relocation(Rel) type 10) * Add to fix resolveArchive for libiserv * nix flake update iserv-proxy * nix flake update iserv-proxy * nix flake update iserv-proxy * Overlay to avoid issue that will be fixed by NixOS/nixpkgs#385722 * nix flake update iserv-proxy * Add COMPAT_R_ARM_PREL31 patch to fix TH for armv6a android * nix flake update iserv-proxy * Disable plugin test for armv7 * Enable tests that should pass * Disable shell-for for armv7 * nix flake update iserv-proxy * nix flake update iserv-proxy * Exclude libc.a from loadArchive for android * nix flake update iserv-proxy * Disable tests of llvm backend for musl32 (seems broken) * Use static linking for android tests * Make `.profiled` and `.dwarf` overridable * Fix cabal-simple-prof test * Add ghc96X * Update JS-implement-TH-support.patch * Skip windows patch now in 9.6 branch * Update patch * Fix for ghcjs * Use hls master branch for testing hls * Add materialized files * Add materialized files * Add materialized files * Add materialized files * Fix iserv-proxy issues for GHC >9.11 * Revert "Fix iserv-proxy issues for GHC >9.11" This reverts commit 7e04c0d. * nix flake update iserv-proxy * Disable ghcjs for ghc96720250227 on macOS * Disable mingwW64 for ghc96720250227 (use ucrt64) * Disable broken test * nix flake update iserv-proxy * Skip broken test * Skip broken test --------- Co-authored-by: sh <[email protected]> Co-authored-by: Hamish Mackenzie <[email protected]>
1 parent a439918 commit 9d55e30

File tree

151 files changed

+10873
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+10873
-190
lines changed

build.nix

+8-3
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,15 @@ in rec {
5757
inherit evalPackages;
5858
src = pkgs.haskell-nix.sources."hls-2.2";
5959
};
60-
} // pkgs.lib.optionalAttrs (ghcFromTo "9.0" "9.8.3" || ghcFromTo "9.10" "9.11") {
61-
"hls-29" = tool compiler-nix-name "haskell-language-server" {
60+
} // pkgs.lib.optionalAttrs (ghcFromTo "9.0" "9.11") {
61+
"hls" = tool compiler-nix-name "haskell-language-server" {
6262
inherit evalPackages;
63-
src = pkgs.haskell-nix.sources."hls-2.9";
63+
src = pkgs.haskell-nix.sources.hls;
64+
cabalProjectLocal = ''
65+
if impl(ghc >=9.6.7) && impl(ghc <9.7) || impl(ghc >=9.8.3)
66+
constraints: ghc-lib-parser >=9.8.4
67+
allow-older: ghc-lib-parser:filepath
68+
'';
6469
};
6570
})
6671
);

builder/comp-builder.nix

+11-3
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,15 @@ let
209209
(enableFeature enableShared "shared")
210210
(enableFeature enableExecutableDynamic "executable-dynamic")
211211
(enableFeature doCoverage "coverage")
212-
(enableFeature (enableLibraryForGhci && !stdenv.hostPlatform.isGhcjs) "library-for-ghci")
212+
# For Android (or really anything that uses lld), -r will silently drop
213+
# "lazy" symbols. Those are leaf symbols with no referenes. This however
214+
# does not work when loading the objects into the linker, because then we
215+
# occationally miss symbols when subsequent libraries depending on the one
216+
# that dropped the symbol are loaded. bfd and lld support --whole-archive
217+
# lld -r --whole-archive ... will _not_ drop lazy symbols. However the
218+
# --whole-archive flag needs to come _before_ the objects, it's applied in
219+
# sequence. The proper fix is thusly to add --while-archive to Cabal.
220+
(enableFeature (enableLibraryForGhci && !stdenv.hostPlatform.isGhcjs && !stdenv.hostPlatform.isAndroid) "library-for-ghci")
213221
] ++ lib.optionals (stdenv.hostPlatform.isMusl && (haskellLib.isExecutableType componentId)) [
214222
# These flags will make sure the resulting executable is statically linked.
215223
# If it uses other libraries it may be necessary for to add more
@@ -377,8 +385,8 @@ let
377385
inherit (package.identifier) version;
378386
nativeBuildInputs = [shellWrappers.drv] ++ attrs.nativeBuildInputs;
379387
});
380-
profiled = self (drvArgs // { enableLibraryProfiling = true; });
381-
dwarf = self (drvArgs // { enableDWARF = true; });
388+
profiled = lib.makeOverridable self (drvArgs // { enableLibraryProfiling = true; });
389+
dwarf = lib.makeOverridable self (drvArgs // { enableDWARF = true; });
382390
} // lib.optionalAttrs (haskellLib.isLibrary componentId || haskellLib.isTest componentId) ({
383391
inherit haddock;
384392
inherit (haddock) haddockDir; # This is null if `doHaddock = false`

builder/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ let
6868
let
6969
haskellPackages = {
7070
# For musl we can use haddock from the buildGHC
71-
ghc = if stdenv.hostPlatform.isLinux && stdenv.targetPlatform.isMusl && !haskellLib.isNativeMusl
71+
ghc = if stdenv.targetPlatform.isMusl
7272
then ghc.buildGHC
7373
else ghc;
7474
inherit packages hoogle;

builder/ghc-for-component-wrapper.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let
2323
libDir = "$wrappedGhc/${configFiles.libDir}";
2424
docDir = "$wrappedGhc/share/doc/ghc/html";
2525
# For musl we can use haddock from the buildGHC
26-
haddock = if stdenv.hostPlatform.isLinux && stdenv.targetPlatform.isMusl && !haskellLib.isNativeMusl
26+
haddock = if stdenv.targetPlatform.isMusl
2727
then ghc.buildGHC
2828
else ghc;
2929

@@ -125,7 +125,7 @@ let
125125
done
126126
127127
''
128-
+ lib.optionalString (stdenv.targetPlatform.isMusl && !haskellLib.isNativeMusl && builtins.compareVersions ghc.version "9.9" >0) ''
128+
+ lib.optionalString (haskellLib.isNativeMusl && builtins.compareVersions ghc.version "9.9" >0) ''
129129
ln -s $wrappedGhc/bin/${targetPrefix}unlit $wrappedGhc/bin/unlit
130130
ln -s $wrappedGhc/bin/${ghcCommand}-iserv $wrappedGhc/bin/ghc-iserv
131131
ln -s $wrappedGhc/bin/${ghcCommand}-iserv-prof $wrappedGhc/bin/ghc-iserv-prof

ci.nix

+17-11
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,14 @@
5858
# from here (so that is no longer cached) also remove ./materialized/ghcXXX.
5959
# Update supported-ghc-versions.md to reflect any changes made here.
6060
nixpkgs.lib.optionalAttrs (nixpkgsName == "R2411") {
61-
ghc96 = false;
62-
ghc98 = false;
63-
ghc910 = false;
64-
ghc912 = true;
65-
} // nixpkgs.lib.optionalAttrs (nixpkgsName == "unstable") {
6661
ghc96 = true;
6762
ghc98 = true;
63+
ghc910 = true;
64+
ghc9121 = true;
65+
} // nixpkgs.lib.optionalAttrs (nixpkgsName == "unstable") {
66+
ghc96 = false;
67+
ghc96X = true;
68+
ghc98 = true;
6869
ghc98llvm = false;
6970
ghc910 = true;
7071
ghc910llvm = true;
@@ -80,13 +81,13 @@
8081
&& (__match ".*llvm" compiler-nix-name == null)
8182
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"])
8283
|| (system == "aarch64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"])
83-
|| (system == "x86_64-darwin" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc966" "ghc982" "ghc983" "ghc984"])
84-
|| (system == "aarch64-darwin" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc966" "ghc982" "ghc983" "ghc984"])
84+
|| (system == "x86_64-darwin" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc966" "ghc96720250227" "ghc982" "ghc983" "ghc984"])
85+
|| (system == "aarch64-darwin" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948" "ghc966" "ghc96720250227" "ghc982" "ghc983" "ghc984"])
8586
)) {
8687
inherit (lib.systems.examples) ghcjs;
87-
} // lib.optionalAttrs (
88-
(__match ".*llvm" compiler-nix-name == null)
89-
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc966"]) # Not sure why GHC 9.6.6 TH code now wants `log1pf`
88+
} // lib.optionalAttrs (nixpkgsName == "unstable"
89+
&& (__match ".*llvm" compiler-nix-name == null)
90+
&& ((system == "x86_64-linux" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc966" "ghc96720250227"]) # Not sure why GHC 9.6.6 TH code now wants `log1pf`
9091
|| (system == "x86_64-darwin" && builtins.elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
9192
inherit (lib.systems.examples) mingwW64;
9293
} // lib.optionalAttrs (nixpkgsName == "unstable"
@@ -98,7 +99,12 @@
9899
# Musl cross only works on linux
99100
# aarch64 cross only works on linux
100101
inherit (lib.systems.examples) musl64 aarch64-multiplatform;
101-
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && builtins.elem compiler-nix-name ["ghc927" "ghc928"]) {
102+
} // lib.optionalAttrs (__match ".*llvm" compiler-nix-name == null && system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
103+
# Out llvm versions of GHC seem to break for musl32
104+
inherit (lib.systems.examples) musl32;
105+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "R2411" && !builtins.elem compiler-nix-name ["ghc902" "ghc928" "ghc948"]) {
106+
inherit (lib.systems.examples) aarch64-android-prebuilt armv7a-android-prebuilt;
107+
} // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {
102108
# TODO fix this for the compilers we build with hadrian (ghc >=9.4)
103109
inherit (lib.systems.examples) aarch64-multiplatform-musl;
104110
} // lib.optionalAttrs (system == "aarch64-linux" && nixpkgsName == "unstable" && !builtins.elem compiler-nix-name ["ghc8107" "ghc902"]) {

compiler/ghc/default.nix

+35-18
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ let self =
4545

4646
, enableDWARF ? false
4747

48-
, enableTerminfo ?
48+
, enableTerminfo ? !stdenv.targetPlatform.isAndroid &&
4949
# Terminfo does not work on older ghc cross arm and windows compilers
50-
(!haskell-nix.haskellLib.isCrossTarget || !(stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isWindows) || builtins.compareVersions ghc-version "8.10" >= 0)
50+
(!haskell-nix.haskellLib.isCrossTarget || !(stdenv.targetPlatform.isAarch32 || stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isWindows) || builtins.compareVersions ghc-version "8.10" >= 0)
5151

5252
, # Wheter to build in NUMA support
5353
enableNUMA ? true
@@ -62,7 +62,7 @@ let self =
6262

6363
, # Whether to disable the large address space allocator
6464
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
65-
disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
65+
disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isAndroid
6666

6767
, useLdGold ?
6868
# might be better check to see if cc is clang/llvm?
@@ -169,8 +169,9 @@ let
169169
WITH_TERMINFO=NO
170170
''
171171
# musl doesn't have a system-linker. Only on x86, and on x86 we need it, as
172-
# our elf linker for x86_64 is broken.
173-
+ lib.optionalString (targetPlatform.isAndroid || (targetPlatform.isMusl && !targetPlatform.isx86)) ''
172+
# our elf linker for x86_64 is broken. The i686 one seems also to not exist.
173+
# So it's really _just_ x86_64.
174+
+ lib.optionalString (targetPlatform.isAndroid || (targetPlatform.isMusl && !targetPlatform.isx86_64)) ''
174175
compiler_CONFIGURE_OPTS += --flags=-dynamic-system-linker
175176
''
176177
# While split sections are now enabled by default in ghc 8.8 for windows,
@@ -183,12 +184,14 @@ let
183184
SplitSections = NO
184185
'' + lib.optionalString (!enableLibraryProfiling) ''
185186
BUILD_PROF_LIBS = NO
187+
'' + lib.optionalString (disableLargeAddressSpace) ''
188+
libraries/base_CONFIGURE_OPTS += --configure-option=--with-libcharset=no
186189
'';
187190

188191
# `--with` flags for libraries needed for RTS linker
189192
configureFlags = [
190193
"--datadir=$doc/share/doc/ghc"
191-
] ++ lib.optionals (!targetPlatform.isGhcjs) ["--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
194+
] ++ lib.optionals (!targetPlatform.isGhcjs && !targetPlatform.isAndroid) ["--with-curses-includes=${targetPackages.ncurses.dev}/include" "--with-curses-libraries=${targetPackages.ncurses.out}/lib"
192195
] ++ lib.optionals (targetLibffi != null && !targetPlatform.isGhcjs) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
193196
] ++ lib.optionals (!enableIntegerSimple && !targetPlatform.isGhcjs) [
194197
"--with-gmp-includes=${targetGmp.dev}/include" "--with-gmp-libraries=${targetGmp.out}/lib"
@@ -216,23 +219,24 @@ let
216219
# https://gitlab.haskell.org/ghc/ghc/-/issues/23188
217220
# https://github.com/haskell/cabal/issues/8882
218221
"fp_cv_prog_ar_supports_dash_l=no"
219-
] ++ lib.optional (targetPlatform.isGhcjs) "--target=javascript-unknown-ghcjs"; # TODO use configurePlatforms once tripple is updated in nixpkgs
222+
] ++ lib.optionals (targetPlatform.isDarwin) [
223+
"--without-libcharset"
224+
] ++ lib.optional (targetPlatform.isGhcjs) "--target=javascript-unknown-ghcjs" # TODO use configurePlatforms once tripple is updated in nixpkgs
225+
;
220226

221227
# Splicer will pull out correct variations
222-
libDeps = platform: lib.optional (enableTerminfo && !targetPlatform.isGhcjs) [ targetPackages.ncurses targetPackages.ncurses.dev ]
228+
libDeps = platform: lib.optional (enableTerminfo && !targetPlatform.isGhcjs && !targetPlatform.isAndroid) [ targetPackages.ncurses targetPackages.ncurses.dev ]
223229
++ lib.optional (!targetPlatform.isGhcjs) targetLibffi
224230
++ lib.optional (!enableIntegerSimple && !targetPlatform.isGhcjs) gmp
225231
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
226232
++ lib.optional (enableNUMA && platform.isLinux && !platform.isAarch32 && !platform.isAndroid) numactl
227-
# Even with terminfo disabled some older ghc cross arm and windows compilers do not build unless `ncurses` is found and they seem to want the buildPlatform version
228-
++ lib.optional (!enableTerminfo && haskell-nix.haskellLib.isCrossTarget && (stdenv.targetPlatform.isAarch64 || stdenv.targetPlatform.isWindows) && builtins.compareVersions ghc-version "8.10" < 0) ncurses.dev
229233
++ lib.optional enableDWARF (lib.getLib elfutils);
230234

231235
toolsForTarget =
232236
if targetPlatform.isGhcjs
233237
then [ buildPackages.emscripten ]
234238
else if hostPlatform == buildPlatform
235-
then [ targetPackages.stdenv.cc ] ++ lib.optionals useLLVM [llvmPackages.llvm llvmPackages.clang]
239+
then [ targetPackages.stdenv.cc ] ++ lib.optionals useLLVM ([llvmPackages.llvm] ++ lib.optional (!targetPlatform.useAndroidPrebuilt) llvmPackages.clang)
236240
else assert targetPlatform == hostPlatform; # build != host == target
237241
[ stdenv.cc ] ++ lib.optional useLLVM buildLlvmPackages.llvm;
238242

@@ -244,7 +248,7 @@ let
244248
# for musl only; but I'd like to stay far away from the unnecessary
245249
# bindist logic as we can. It's slow, and buggy, and doesn't provide any
246250
# value for us.
247-
installStage1 = useHadrian && (haskell-nix.haskellLib.isCrossTarget || stdenv.targetPlatform.isMusl);
251+
installStage1 = useHadrian && (with haskell-nix.haskellLib; isCrossTarget || isNativeMusl);
248252

249253
hadrian =
250254
let
@@ -345,7 +349,14 @@ let
345349
" '*.ghc.cabal.configure.opts += --flags=-dynamic-system-linker'"
346350
# The following is required if we build on aarch64-darwin for aarch64-iOS. Otherwise older
347351
# iPhones/iPads/... won't understand the compiled code, as the compiler will emit LDSETALH
348-
# + lib.optionalString (targetPlatform.???) "'*.rts.ghc.c.opts += -optc-mcpu=apple-a7 -optc-march=armv8-a+norcpc'"
352+
# FIXME: we should have iOS as an argument to this derivation, and then make this, as well as
353+
# disableLargeAddress space conditional on iOS = true.
354+
+ lib.optionalString (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64)
355+
" '*.*.ghc.c.opts += -optc-mcpu=apple-a7 -optc-march=armv8-a+norcpc'"
356+
+ lib.optionalString (targetPlatform.isAndroid && targetPlatform.isAarch32)
357+
" 'stage1.*.ghc.c.opts += -optc-march=armv7-a -optc-mfloat-abi=softfp -optc-mfpu=vfpv3-d16'"
358+
+ lib.optionalString (targetPlatform.isAndroid && targetPlatform.isAarch64)
359+
" 'stage1.*.ghc.c.opts += -optc-march=armv8-a'"
349360
# For GHC versions in the 9.x range that don't support the +native_bignum flavour transformer yet
350361
+ lib.optionalString ((enableNativeBignum && !hadrianHasNativeBignumFlavour))
351362
" --bignum=native"
@@ -462,7 +473,10 @@ stdenv.mkDerivation (rec {
462473
export NIX_LDFLAGS+=" -rpath $out/lib/${targetPrefix}ghc-${ghc-version}"
463474
'' + lib.optionalString stdenv.isDarwin ''
464475
export NIX_LDFLAGS+=" -no_dtrace_dof"
465-
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
476+
'' +
477+
# we really want "+armv7-a,+soft-float,+neon" as features, but llvm will
478+
# fail with those :facepalm:
479+
lib.optionalString targetPlatform.useAndroidPrebuilt ''
466480
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
467481
'' + lib.optionalString targetPlatform.isMusl ''
468482
echo "patching llvm-targets for musl targets..."
@@ -537,7 +551,7 @@ stdenv.mkDerivation (rec {
537551
++ lib.optional stdenv.targetPlatform.isMusl "pie"
538552
++ lib.optional enableDWARF "fortify";
539553

540-
postInstall = lib.optionalString (enableNUMA && targetPlatform.isLinux) ''
554+
postInstall = lib.optionalString (enableNUMA && targetPlatform.isLinux && !targetPlatform.isAarch32 && !targetPlatform.isAndroid) ''
541555
# Patch rts.conf to ensure libnuma can be found
542556
543557
for file in $(find "$out/lib" -name "rts*.conf"); do
@@ -731,7 +745,7 @@ stdenv.mkDerivation (rec {
731745
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib'
732746
find . -name 'system*.conf*'
733747
cat mk/system-cxx-std-lib-1.0.conf
734-
'' + lib.optionalString (installStage1 && stdenv.targetPlatform.isMusl) ''
748+
'' + lib.optionalString (installStage1 && haskell-nix.haskellLib.isNativeMusl) ''
735749
substituteInPlace hadrian/cfg/system.config \
736750
--replace 'cross-compiling = YES' \
737751
'cross-compiling = NO'
@@ -781,7 +795,7 @@ stdenv.mkDerivation (rec {
781795
dontStrip = true;
782796
dontPatchELF = true;
783797
noAuditTmpdir = true;
784-
} // lib.optionalAttrs (stdenv.buildPlatform.isDarwin || stdenv.targetPlatform.isWindows) {
798+
} // {
785799
# ghc install on macOS wants to run `xattr -r -c`
786800
# The macOS version fails because it wants python 2.
787801
# The nix version of xattr does not support those args.
@@ -821,12 +835,13 @@ stdenv.mkDerivation (rec {
821835
--replace 'dynamic-library-dirs:' 'dynamic-library-dirs: ${libcxx}/lib'
822836
find . -name 'system*.conf*'
823837
cat mk/system-cxx-std-lib-1.0.conf
824-
'' + lib.optionalString (installStage1 && !haskell-nix.haskellLib.isCrossTarget && stdenv.targetPlatform.isMusl) ''
838+
'' + lib.optionalString (installStage1 && haskell-nix.haskellLib.isNativeMusl) ''
825839
substituteInPlace hadrian/cfg/system.config \
826840
--replace 'cross-compiling = YES' \
827841
'cross-compiling = NO'
828842
'';
829843
buildPhase = ''
844+
runHook preBuild
830845
${hadrian}/bin/hadrian ${hadrianArgs}
831846
'' + lib.optionalString (installStage1 && !stdenv.targetPlatform.isGhcjs && builtins.compareVersions ghc-version "9.8" < 0) ''
832847
${hadrian}/bin/hadrian ${hadrianArgs} stage1:lib:libiserv
@@ -841,6 +856,8 @@ stdenv.mkDerivation (rec {
841856
mv $exe ${targetPrefix}$exe
842857
done
843858
popd
859+
'' + ''
860+
runHook postBuild
844861
'';
845862

846863
# Hadrian's installation only works for native compilers, and is broken for cross compilers.

flake.lock

+26-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)