From: Benda Xu <[email protected]> If ghc spawns too many C compilers, it will exhaust file descripters.
In the reference, it was thought to be a macOS bug for aggressive fd limits. But the ghc bug also applies to GNU/Linux, when ghc is asked to spawn, for example 256, jobs. This patch circumvents this ghc design flaw. Reference: https://github.com/commercialhaskell/stack/issues/1177 Reference: https://github.com/commercialhaskell/stack/issues/1979 Signed-off-by: Benda Xu <[email protected]> --- eclass/ghc-package.eclass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eclass/ghc-package.eclass b/eclass/ghc-package.eclass index 5361f09af1e9..d729f4a407b4 100644 --- a/eclass/ghc-package.eclass +++ b/eclass/ghc-package.eclass @@ -203,7 +203,9 @@ ghc-make-args() { # https://ghc.haskell.org/trac/ghc/ticket/9221#comment:57 # SMP is a requirement for parallel GC's gen0 # 'qb' balancing. - echo "-j$(makeopts_jobs) +RTS -A256M -qb0 -RTS" + local n=$(makeopts_jobs) + [[ ${n} -gt 64 ]] && n=64 + echo "-j${n} +RTS -A256M -qb0 -RTS" ghc_make_args=() fi echo "${ghc_make_args[@]}" -- 2.25.0
