Fix #8754 again.
[ghc.git] / ghc / hschooks.c
1 /*
2 These routines customise the error messages
3 for various bits of the RTS. They are linked
4 in instead of the defaults.
5 */
6
7 #include "../rts/PosixSource.h"
8 #include "Rts.h"
9
10 #include "HsFFI.h"
11
12 #include <string.h>
13
14 #ifdef HAVE_UNISTD_H
15 #include <unistd.h>
16 #endif
17
18 void
19 initGCStatistics(void)
20 {
21 /* Workaround for #8754: if the GC stats aren't enabled because the
22 compiler couldn't use -Bsymbolic to link the default hooks, then
23 initialize them sensibly. See Note [-Bsymbolic and hooks] in
24 Main.hs. */
25 if (RtsFlags.GcFlags.giveStats == NO_GC_STATS) {
26 RtsFlags.GcFlags.giveStats = COLLECT_GC_STATS;
27 }
28 }
29
30 void
31 defaultsHook (void)
32 {
33 #if __GLASGOW_HASKELL__ >= 707
34 // This helps particularly with large compiles, but didn't work
35 // very well with earlier GHCs because it caused large amounts of
36 // fragmentation. See rts/sm/BlockAlloc.c:allocLargeChunk().
37 RtsFlags.GcFlags.heapSizeSuggestionAuto = rtsTrue;
38 #else
39 RtsFlags.GcFlags.heapSizeSuggestion = 6*1024*1024 / BLOCK_SIZE;
40 #endif
41
42 RtsFlags.GcFlags.maxStkSize = 512*1024*1024 / sizeof(W_);
43
44 initGCStatistics();
45
46 // See #3408: the default idle GC time of 0.3s is too short on
47 // Windows where we receive console events once per second or so.
48 #if __GLASGOW_HASKELL__ >= 703
49 RtsFlags.GcFlags.idleGCDelayTime = SecondsToTime(5);
50 #else
51 RtsFlags.GcFlags.idleGCDelayTime = 5*1000;
52 #endif
53 }
54
55 void
56 StackOverflowHook (StgWord stack_size) /* in bytes */
57 {
58 fprintf(stderr, "GHC stack-space overflow: current limit is %zu bytes.\nUse the `-K<size>' option to increase it.\n", (size_t)stack_size);
59 }
60