1 |
From: Benda Xu <heroxbd@g.o> |
2 |
|
3 |
If ghc spawns too many C compilers, it will exhaust file descripters. |
4 |
|
5 |
In the reference, it was thought to be a macOS bug for aggressive fd |
6 |
limits. But the ghc bug also applies to GNU/Linux, when ghc is |
7 |
asked to spawn, for example 256, jobs. |
8 |
|
9 |
This patch circumvents this ghc design flaw. |
10 |
|
11 |
Reference: https://github.com/commercialhaskell/stack/issues/1177 |
12 |
Reference: https://github.com/commercialhaskell/stack/issues/1979 |
13 |
Signed-off-by: Benda Xu <heroxbd@g.o> |
14 |
--- |
15 |
eclass/ghc-package.eclass | 4 +++- |
16 |
1 file changed, 3 insertions(+), 1 deletion(-) |
17 |
|
18 |
diff --git a/eclass/ghc-package.eclass b/eclass/ghc-package.eclass |
19 |
index 5361f09af1e9..d729f4a407b4 100644 |
20 |
--- a/eclass/ghc-package.eclass |
21 |
+++ b/eclass/ghc-package.eclass |
22 |
@@ -203,7 +203,9 @@ ghc-make-args() { |
23 |
# https://ghc.haskell.org/trac/ghc/ticket/9221#comment:57 |
24 |
# SMP is a requirement for parallel GC's gen0 |
25 |
# 'qb' balancing. |
26 |
- echo "-j$(makeopts_jobs) +RTS -A256M -qb0 -RTS" |
27 |
+ local n=$(makeopts_jobs) |
28 |
+ [[ ${n} -gt 64 ]] && n=64 |
29 |
+ echo "-j${n} +RTS -A256M -qb0 -RTS" |
30 |
ghc_make_args=() |
31 |
fi |
32 |
echo "${ghc_make_args[@]}" |
33 |
-- |
34 |
2.25.0 |