Skip to content

Commit 9d55e30

Browse files
angermanshumvgolovehamishmack
authoredMar 17, 2025
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`

0 commit comments

Comments
 (0)
Please sign in to comment.