on iko/ghcjs-patch-master help sign in
fix: use target libffi instead of build libffi (#538)
1031e80Le Tuan
compiler/ghc/default.nix+8−5
@@ -73,9 +73,12 @@ let
73 inherit (bootPkgs) ghc;
73 inherit (bootPkgs) ghc;
74
74
75 # TODO check if this posible fix for segfaults works or not.
75 # TODO check if this posible fix for segfaults works or not.
76+ targetLibffi =
76− libffiStaticEnabled = if libffi == null || !stdenv.targetPlatform.isMusl
77+ if stdenv.targetPlatform.isMusl
77− then libffi
78− else targetPackages.libffi.overrideAttrs (old: { dontDisableStatic = true; });
78+ then targetPackages.libffi.overrideAttrs (old: { dontDisableStatic = true; })
79+ else if targetPlatform != hostPlatform
80+ then targetPackages.libffi
81+ else libffi;
79
82
80 # TODO(@Ericson2314) Make unconditional
83 # TODO(@Ericson2314) Make unconditional
81 targetPrefix = stdenv.lib.optionalString
84 targetPrefix = stdenv.lib.optionalString
@@ -116,7 +119,7 @@ let
116
119
117 # Splicer will pull out correct variations
120 # Splicer will pull out correct variations
118 libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
121 libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
119− ++ [libffiStaticEnabled]
122+ ++ [targetLibffi]
120 ++ stdenv.lib.optional (!enableIntegerSimple) gmp
123 ++ stdenv.lib.optional (!enableIntegerSimple) gmp
121 ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
124 ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
122
125
@@ -208,7 +211,7 @@ in let configured-src = stdenv.mkDerivation (rec {
208 configureFlags = [
211 configureFlags = [
209 "--datadir=$doc/share/doc/ghc"
212 "--datadir=$doc/share/doc/ghc"
210 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
213 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
211− ] ++ stdenv.lib.optionals (libffiStaticEnabled != null) ["--with-system-libffi" "--with-ffi-includes=${libffiStaticEnabled.dev}/include" "--with-ffi-libraries=${libffiStaticEnabled.out}/lib"
214+ ] ++ stdenv.lib.optionals (targetLibffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetLibffi.dev}/include" "--with-ffi-libraries=${targetLibffi.out}/lib"
212 ] ++ stdenv.lib.optional (!enableIntegerSimple) [
215 ] ++ stdenv.lib.optional (!enableIntegerSimple) [
213 "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
216 "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
214 ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
217 ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [