on iko/ghcjs-patch-master help sign in
Fix cross-compilation for armv6l (#480)

This PR adds a patch for GHC 8.6.5 to properly remove the atomic primops fallbacks on ARM architectures. Those primops called some GCC legacy synchronization functions that were not loaded during TH, ending in failure within `remote-iserv`. It turns out that the condition `!defined(arm_HOST_ARCH)` was never `true`, as `arm_HOST_ARCH` was actually defined (on ARM architectures) in a dependency of the `Rts.h` file. This patch works for my use case (GHC 8.6.5 for armv6l). I haven't done any test on the other GHC versions. This PR also includes a patch to actually use the native `pkgconfig` during cross-compilation. Fixes #441 Authored-by: Michivi <webmaster@michvi.com>

commit8099da8fe035efe49e81a6eb974eea9e5656b9c6 authorLe Tuan <webmaster@michivi.com> dateWed 11 Mar 2020, 11:04 (7 years ago) parentcac0bae
3 files changed+15−2
builder/comp-builder.nix+2−2 overlays/bootstrap.nix+1 overlays/patches/ghc/ghc-8.6.5-atomic-arm-arch.patch+12
builder/comp-builder.nix+2−2
@@ -1,4 +1,4 @@
1−{ stdenv, buildPackages, ghc, lib, pkgconfig, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }:
1+{ stdenv, buildPackages, ghc, lib, gobject-introspection ? null, haskellLib, makeConfigFiles, ghcForComponent, hsPkgs, runCommand, libffi, gmp }:
22
33{ componentId
44, component
@@ -121,7 +121,7 @@ let
121121 (lib.concatMap (c: if c.isHaskell or false
122122 then builtins.attrValues (c.components.exes or {})
123123 else [c]) component.build-tools) ++
124− lib.optional (component.pkgconfig != []) pkgconfig;
124+ lib.optional (component.pkgconfig != []) buildPackages.pkgconfig;
125125
126126 # Unfortunately, we need to wrap ghc commands for cabal builds to
127127 # work in the nix-shell. See ../doc/removing-with-package-wrapper.md.
overlays/bootstrap.nix+1
@@ -106,6 +106,7 @@ in {
106106 ++ self.lib.optional (version == "8.6.3") ./patches/ghc/ghc-8.6.3-reinstallable-lib-ghc.patch
107107 ++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-reinstallable-lib-ghc.patch
108108 ++ self.lib.optional (version == "8.6.5") ./patches/ghc/ghc-8.6.5-reinstallable-lib-ghc.patch
109+ ++ self.lib.optional (version == "8.6.5") ./patches/ghc/ghc-8.6.5-atomic-arm-arch.patch
109110 ++ self.lib.optional (version == "8.8.1") ./patches/ghc/ghc-8.8.1-reinstallable-lib-ghc.patch
110111 ++ self.lib.optional (version == "8.8.2") ./patches/ghc/ghc-8.8.2-reinstallable-lib-ghc.patch
111112 ++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-better-plusSimplCountErrors.patch
overlays/patches/ghc/ghc-8.6.5-atomic-arm-arch.patchnew file+12
@@ -0,0 +1,12 @@
1+diff --git a/libraries/ghc-prim/cbits/atomic.c b/libraries/ghc-prim/cbits/atomic.c
2+index ea96120..f3f4a9e 100644
3+--- a/libraries/ghc-prim/cbits/atomic.c
4++++ b/libraries/ghc-prim/cbits/atomic.c
5+@@ -1,6 +1,6 @@
6+-#if !defined(arm_HOST_ARCH)
7+ #include "Rts.h"
8+
9++#if !defined(arm_HOST_ARCH)
10+ // Fallbacks for atomic primops on byte arrays. The builtins used
11+ // below are supported on both GCC and LLVM.
12+ //