@@ -6,6 +6,9 @@
66
77, libiconv ? null, ncurses
88
9+, # GHC can be built with system libffi or a bundled one.
10+ libffi ? null
11+
912, useLLVM ? !stdenv.targetPlatform.isx86 || (stdenv.targetPlatform.isMusl && stdenv.hostPlatform != stdenv.targetPlatform)
1013, # LLVM is conceptually a run-time-only depedendency, but for
1114 # non-x86, we need LLVM to bootstrap later stages, so it becomes a
@@ -65,6 +68,7 @@ let
6568
6669 # Splicer will pull out correct variations
6770 libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
71+ ++ [libffi]
6872 ++ stdenv.lib.optional (!enableIntegerSimple) gmp
6973 ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
7074
@@ -149,6 +153,7 @@ stdenv.mkDerivation (rec {
149153 configureFlags = [
150154 "--datadir=$doc/share/doc/ghc"
151155 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
156+ ] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${libffi}/include" "--with-ffi-libraries=${libffi}/lib"
152157 ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && !enableIntegerSimple) [
153158 "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
154159 ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [