Commit a7ab1616 authored by Simon Marlow's avatar Simon Marlow

Replace hooks by callbacks in RtsConfig (#8785)

Summary:
Hooks rely on static linking semantics, and are broken by -Bsymbolic
which we need when using dynamic linking.

Test Plan: Built it

Reviewers: austin, hvr, tibbe

Differential Revision: https://phabricator.haskell.org/D8
parent 72092904
...@@ -1604,14 +1604,9 @@ linkDynLib dflags0 o_files dep_packages ...@@ -1604,14 +1604,9 @@ linkDynLib dflags0 o_files dep_packages
------------------------------------------------------------------- -------------------------------------------------------------------
let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; } let output_fn = case o_file of { Just s -> s; Nothing -> "a.out"; }
let buildingRts = thisPackage dflags == rtsPackageKey let bsymbolicFlag = -- we need symbolic linking to resolve
let bsymbolicFlag = if buildingRts -- non-PIC intra-package-relocations
then -- -Bsymbolic breaks the way we implement ["-Wl,-Bsymbolic"]
-- hooks in the RTS
[]
else -- we need symbolic linking to resolve
-- non-PIC intra-package-relocations
["-Wl,-Bsymbolic"]
runLink dflags ( runLink dflags (
map Option verbFlags map Option verbFlags
......
...@@ -51,6 +51,10 @@ ghc_stage1_C_FILES_NODEPS = ghc/hschooks.c ...@@ -51,6 +51,10 @@ ghc_stage1_C_FILES_NODEPS = ghc/hschooks.c
ghc_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES ghc_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
ghc_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES ghc_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
ghc_stage1_MORE_HC_OPTS += -no-hs-main
ghc_stage2_MORE_HC_OPTS += -no-hs-main
ghc_stage3_MORE_HC_OPTS += -no-hs-main
ifeq "$(GhcDebugged)" "YES" ifeq "$(GhcDebugged)" "YES"
ghc_stage1_MORE_HC_OPTS += -debug ghc_stage1_MORE_HC_OPTS += -debug
ghc_stage2_MORE_HC_OPTS += -debug ghc_stage2_MORE_HC_OPTS += -debug
......
...@@ -54,3 +54,15 @@ StackOverflowHook (StgWord stack_size) /* in bytes */ ...@@ -54,3 +54,15 @@ StackOverflowHook (StgWord stack_size) /* in bytes */
fprintf(stderr, "GHC stack-space overflow: current limit is %zu bytes.\nUse the `-K<size>' option to increase it.\n", (size_t)stack_size); fprintf(stderr, "GHC stack-space overflow: current limit is %zu bytes.\nUse the `-K<size>' option to increase it.\n", (size_t)stack_size);
} }
int main (int argc, char *argv[])
{
RtsConfig conf = defaultRtsConfig;
#if __GLASGOW_HASKELL__ >= 711
conf.defaultsHook = defaultsHook;
conf.rts_opts_enabled = RtsOptsAll;
conf.stackOverflowHook = StackOverflowHook;
#endif
extern StgClosure ZCMain_main_closure;
hs_main(argc, argv, &ZCMain_main_closure, conf);
}
...@@ -220,7 +220,6 @@ INLINE_HEADER Time fsecondsToTime (double t) ...@@ -220,7 +220,6 @@ INLINE_HEADER Time fsecondsToTime (double t)
/* Other RTS external APIs */ /* Other RTS external APIs */
#include "rts/Parallel.h" #include "rts/Parallel.h"
#include "rts/Hooks.h"
#include "rts/Signals.h" #include "rts/Signals.h"
#include "rts/BlockSignals.h" #include "rts/BlockSignals.h"
#include "rts/Hpc.h" #include "rts/Hpc.h"
......
...@@ -60,9 +60,42 @@ typedef enum { ...@@ -60,9 +60,42 @@ typedef enum {
// reason for using a struct is extensibility: we can add more // reason for using a struct is extensibility: we can add more
// fields to this later without breaking existing client code. // fields to this later without breaking existing client code.
typedef struct { typedef struct {
// Whether to interpret +RTS options on the command line
RtsOptsEnabledEnum rts_opts_enabled; RtsOptsEnabledEnum rts_opts_enabled;
// additional RTS options
const char *rts_opts; const char *rts_opts;
// True if GHC was not passed -no-hs-main
HsBool rts_hs_main; HsBool rts_hs_main;
// Called before processing command-line flags, so that default
// settings for RtsFlags can be provided.
void (* defaultsHook) (void);
// Called just before exiting
void (* onExitHook) (void);
// Called on a stack overflow, before exiting
void (* stackOverflowHook) (W_ stack_size);
// Called on heap overflow, before exiting
void (* outOfHeapHook) (W_ request_size, W_ heap_size);
// Called when malloc() fails, before exiting
void (* mallocFailHook) (W_ request_size /* in bytes */, char *msg);
// Called for every GC
void (* gcDoneHook) (unsigned int gen,
W_ allocated_bytes, /* since last GC */
W_ live_bytes,
W_ copied_bytes,
W_ max_copied_per_thread_bytes,
W_ total_bytes,
W_ slop_bytes,
W_ sync_elapsed_ns, W_ elapsed_ns, W_ cpu_ns);
} RtsConfig; } RtsConfig;
// Clients should start with defaultRtsConfig and then customise it. // Clients should start with defaultRtsConfig and then customise it.
......
...@@ -1095,10 +1095,6 @@ typedef struct _RtsSymbolVal { ...@@ -1095,10 +1095,6 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(stg_block_readmvar) \ SymI_HasProto(stg_block_readmvar) \
SymI_HasProto(stg_block_putmvar) \ SymI_HasProto(stg_block_putmvar) \
MAIN_CAP_SYM \ MAIN_CAP_SYM \
SymI_HasProto(MallocFailHook) \
SymI_HasProto(OnExitHook) \
SymI_HasProto(OutOfHeapHook) \
SymI_HasProto(StackOverflowHook) \
SymI_HasProto(addDLL) \ SymI_HasProto(addDLL) \
SymI_HasProto(__int_encodeDouble) \ SymI_HasProto(__int_encodeDouble) \
SymI_HasProto(__word_encodeDouble) \ SymI_HasProto(__word_encodeDouble) \
...@@ -1123,7 +1119,6 @@ typedef struct _RtsSymbolVal { ...@@ -1123,7 +1119,6 @@ typedef struct _RtsSymbolVal {
SymI_HasProto(stg_decodeDoublezu2Intzh) \ SymI_HasProto(stg_decodeDoublezu2Intzh) \
SymI_HasProto(stg_decodeDoublezuInt64zh) \ SymI_HasProto(stg_decodeDoublezuInt64zh) \
SymI_HasProto(stg_decodeFloatzuIntzh) \ SymI_HasProto(stg_decodeFloatzuIntzh) \
SymI_HasProto(defaultsHook) \
SymI_HasProto(stg_delayzh) \ SymI_HasProto(stg_delayzh) \
SymI_HasProto(stg_deRefWeakzh) \ SymI_HasProto(stg_deRefWeakzh) \
SymI_HasProto(stg_deRefStablePtrzh) \ SymI_HasProto(stg_deRefStablePtrzh) \
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "Profiling.h" #include "Profiling.h"
#include "RtsFlags.h" #include "RtsFlags.h"
#include "sm/OSMem.h" #include "sm/OSMem.h"
#include "hooks/Hooks.h"
#ifdef HAVE_CTYPE_H #ifdef HAVE_CTYPE_H
#include <ctype.h> #include <ctype.h>
...@@ -52,6 +53,22 @@ int win32_prog_argc = 0; ...@@ -52,6 +53,22 @@ int win32_prog_argc = 0;
wchar_t **win32_prog_argv = NULL; wchar_t **win32_prog_argv = NULL;
#endif #endif
// The global rtsConfig, set from the RtsConfig supplied by the call
// to hs_init_ghc().
RtsConfig rtsConfig;
const RtsConfig defaultRtsConfig = {
.rts_opts_enabled = RtsOptsSafeOnly,
.rts_opts = NULL,
.rts_hs_main = rtsFalse,
.defaultsHook = FlagDefaultsHook,
.onExitHook = OnExitHook,
.stackOverflowHook = StackOverflowHook,
.outOfHeapHook = OutOfHeapHook,
.mallocFailHook = MallocFailHook,
.gcDoneHook = NULL
};
/* /*
* constants, used later * constants, used later
*/ */
...@@ -62,31 +79,31 @@ wchar_t **win32_prog_argv = NULL; ...@@ -62,31 +79,31 @@ wchar_t **win32_prog_argv = NULL;
Static function decls Static function decls
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum enabled); static void procRtsOpts (int rts_argc0, RtsOptsEnabledEnum enabled);
static void normaliseRtsOpts (void); static void normaliseRtsOpts (void);
static void initStatsFile (FILE *f); static void initStatsFile (FILE *f);
static int openStatsFile (char *filename, const char *FILENAME_FMT, static int openStatsFile (
FILE **file_ret); char *filename, const char *FILENAME_FMT, FILE **file_ret);
static StgWord64 decodeSize (const char *flag, nat offset, static StgWord64 decodeSize (
StgWord64 min, StgWord64 max); const char *flag, nat offset, StgWord64 min, StgWord64 max);
static void bad_option (const char *s); static void bad_option (const char *s);
#ifdef TRACING #ifdef TRACING
static void read_trace_flags(char *arg); static void read_trace_flags(char *arg);
#endif #endif
static void errorUsage (void) GNU_ATTRIBUTE(__noreturn__); static void errorUsage (void) GNU_ATTRIBUTE(__noreturn__);
static char * copyArg (char *arg); static char * copyArg (char *arg);
static char ** copyArgv (int argc, char *argv[]); static char ** copyArgv (int argc, char *argv[]);
static void freeArgv (int argc, char *argv[]); static void freeArgv (int argc, char *argv[]);
static void errorRtsOptsDisabled(HsBool is_hs_main, const char *s); static void errorRtsOptsDisabled (const char *s);
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Command-line option parsing routines. * Command-line option parsing routines.
...@@ -416,8 +433,7 @@ usage_text[] = { ...@@ -416,8 +433,7 @@ usage_text[] = {
0 0
}; };
STATIC_INLINE rtsBool STATIC_INLINE rtsBool strequal(const char *a, const char * b)
strequal(const char *a, const char * b)
{ {
return(strcmp(a, b) == 0); return(strcmp(a, b) == 0);
} }
...@@ -457,10 +473,10 @@ static void splitRtsFlags(const char *s) ...@@ -457,10 +473,10 @@ static void splitRtsFlags(const char *s)
} while (*c1 != '\0'); } while (*c1 != '\0');
} }
static void static void errorRtsOptsDisabled(const char *s)
errorRtsOptsDisabled(HsBool is_hs_main, const char *s) { {
char *advice; char *advice;
if (is_hs_main) { if (rtsConfig.rts_hs_main) {
advice = "Link with -rtsopts to enable them."; advice = "Link with -rtsopts to enable them.";
} else { } else {
advice = "Use hs_init_with_rtsopts() to enable them."; advice = "Use hs_init_with_rtsopts() to enable them.";
...@@ -483,17 +499,18 @@ errorRtsOptsDisabled(HsBool is_hs_main, const char *s) { ...@@ -483,17 +499,18 @@ errorRtsOptsDisabled(HsBool is_hs_main, const char *s) {
- prog_name (global) contains the basename of prog_argv[0] - prog_name (global) contains the basename of prog_argv[0]
- rtsConfig (global) contains the supplied RtsConfig
-------------------------------------------------------------------------- */ -------------------------------------------------------------------------- */
void setupRtsFlags (int *argc, char *argv[], void setupRtsFlags (int *argc, char *argv[], RtsConfig rts_config)
RtsOptsEnabledEnum rtsOptsEnabled,
const char *ghc_rts_opts,
HsBool is_hs_main)
{ {
nat mode; nat mode;
nat total_arg; nat total_arg;
nat arg, rts_argc0; nat arg, rts_argc0;
rtsConfig = rts_config;
setProgName (argv); setProgName (argv);
total_arg = *argc; total_arg = *argc;
arg = 1; arg = 1;
...@@ -510,10 +527,10 @@ void setupRtsFlags (int *argc, char *argv[], ...@@ -510,10 +527,10 @@ void setupRtsFlags (int *argc, char *argv[],
// (arguments from the GHCRTS environment variable and the command // (arguments from the GHCRTS environment variable and the command
// line override these). // line override these).
{ {
if (ghc_rts_opts != NULL) { if (rtsConfig.rts_opts != NULL) {
splitRtsFlags(ghc_rts_opts); splitRtsFlags(rtsConfig.rts_opts);
// opts from ghc_rts_opts are always enabled: // opts from rts_opts are always enabled:
procRtsOpts(is_hs_main, rts_argc0, RtsOptsAll); procRtsOpts(rts_argc0, RtsOptsAll);
rts_argc0 = rts_argc; rts_argc0 = rts_argc;
} }
} }
...@@ -524,12 +541,13 @@ void setupRtsFlags (int *argc, char *argv[], ...@@ -524,12 +541,13 @@ void setupRtsFlags (int *argc, char *argv[],
char *ghc_rts = getenv("GHCRTS"); char *ghc_rts = getenv("GHCRTS");
if (ghc_rts != NULL) { if (ghc_rts != NULL) {
if (rtsOptsEnabled == RtsOptsNone) { if (rtsConfig.rts_opts_enabled == RtsOptsNone) {
errorRtsOptsDisabled(is_hs_main, "Warning: Ignoring GHCRTS variable as RTS options are disabled.\n %s"); errorRtsOptsDisabled(
"Warning: Ignoring GHCRTS variable as RTS options are disabled.\n %s");
// We don't actually exit, just warn // We don't actually exit, just warn
} else { } else {
splitRtsFlags(ghc_rts); splitRtsFlags(ghc_rts);
procRtsOpts(is_hs_main, rts_argc0, rtsOptsEnabled); procRtsOpts(rts_argc0, rtsConfig.rts_opts_enabled);
rts_argc0 = rts_argc; rts_argc0 = rts_argc;
} }
} }
...@@ -568,7 +586,7 @@ void setupRtsFlags (int *argc, char *argv[], ...@@ -568,7 +586,7 @@ void setupRtsFlags (int *argc, char *argv[],
} }
argv[*argc] = (char *) 0; argv[*argc] = (char *) 0;
procRtsOpts(is_hs_main, rts_argc0, rtsOptsEnabled); procRtsOpts(rts_argc0, rtsConfig.rts_opts_enabled);
appendRtsArg((char *)0); appendRtsArg((char *)0);
rts_argc--; // appendRtsArg will have bumped it for the NULL (#7227) rts_argc--; // appendRtsArg will have bumped it for the NULL (#7227)
...@@ -590,32 +608,34 @@ void setupRtsFlags (int *argc, char *argv[], ...@@ -590,32 +608,34 @@ void setupRtsFlags (int *argc, char *argv[],
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#if defined(HAVE_UNISTD_H) && defined(HAVE_SYS_TYPES_H) && !defined(mingw32_HOST_OS) #if defined(HAVE_UNISTD_H) && defined(HAVE_SYS_TYPES_H) && !defined(mingw32_HOST_OS)
static void checkSuid(HsBool is_hs_main, RtsOptsEnabledEnum enabled) static void checkSuid(RtsOptsEnabledEnum enabled)
{ {
if (enabled == RtsOptsSafeOnly) { if (enabled == RtsOptsSafeOnly) {
/* This doesn't cover linux/posix capabilities like CAP_DAC_OVERRIDE, /* This doesn't cover linux/posix capabilities like CAP_DAC_OVERRIDE,
we'd have to link with -lcap for that. */ we'd have to link with -lcap for that. */
if ((getuid() != geteuid()) || (getgid() != getegid())) { if ((getuid() != geteuid()) || (getgid() != getegid())) {
errorRtsOptsDisabled(is_hs_main, "RTS options are disabled for setuid binaries. %s"); errorRtsOptsDisabled(
"RTS options are disabled for setuid binaries. %s");
stg_exit(EXIT_FAILURE); stg_exit(EXIT_FAILURE);
} }
} }
} }
#else #else
static void checkSuid(HsBool is_hs_main STG_UNUSED, RtsOptsEnabledEnum enabled STG_UNUSED) static void checkSuid (RtsOptsEnabledEnum enabled STG_UNUSED)
{ {
} }
#endif #endif
static void checkUnsafe(HsBool is_hs_main, RtsOptsEnabledEnum enabled) static void checkUnsafe(RtsOptsEnabledEnum enabled)
{ {
if (enabled == RtsOptsSafeOnly) { if (enabled == RtsOptsSafeOnly) {
errorRtsOptsDisabled(is_hs_main, "Most RTS options are disabled. %s"); errorRtsOptsDisabled("Most RTS options are disabled. %s");
stg_exit(EXIT_FAILURE); stg_exit(EXIT_FAILURE);
} }
} }
static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum rtsOptsEnabled) static void procRtsOpts (int rts_argc0,
RtsOptsEnabledEnum rtsOptsEnabled)
{ {
rtsBool error = rtsFalse; rtsBool error = rtsFalse;
int arg; int arg;
...@@ -623,11 +643,11 @@ static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum rt ...@@ -623,11 +643,11 @@ static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum rt
if (!(rts_argc0 < rts_argc)) return; if (!(rts_argc0 < rts_argc)) return;
if (rtsOptsEnabled == RtsOptsNone) { if (rtsOptsEnabled == RtsOptsNone) {
errorRtsOptsDisabled(is_hs_main, "RTS options are disabled. %s"); errorRtsOptsDisabled("RTS options are disabled. %s");
stg_exit(EXIT_FAILURE); stg_exit(EXIT_FAILURE);
} }
checkSuid(is_hs_main, rtsOptsEnabled); checkSuid(rtsOptsEnabled);
// Process RTS (rts_argv) part: mainly to determine statsfile // Process RTS (rts_argv) part: mainly to determine statsfile
for (arg = rts_argc0; arg < rts_argc; arg++) { for (arg = rts_argc0; arg < rts_argc; arg++) {
...@@ -639,7 +659,7 @@ static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum rt ...@@ -639,7 +659,7 @@ static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum rt
rtsBool option_checked = rtsFalse; rtsBool option_checked = rtsFalse;
#define OPTION_SAFE option_checked = rtsTrue; #define OPTION_SAFE option_checked = rtsTrue;
#define OPTION_UNSAFE checkUnsafe(is_hs_main, rtsOptsEnabled); option_checked = rtsTrue; #define OPTION_UNSAFE checkUnsafe(rtsOptsEnabled); option_checked = rtsTrue;
if (rts_argv[arg][0] != '-') { if (rts_argv[arg][0] != '-') {
fflush(stdout); fflush(stdout);
...@@ -661,7 +681,8 @@ static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum rt ...@@ -661,7 +681,8 @@ static void procRtsOpts (HsBool is_hs_main, int rts_argc0, RtsOptsEnabledEnum rt
# define TICKY_BUILD_ONLY(x) x # define TICKY_BUILD_ONLY(x) x
#else #else
# define TICKY_BUILD_ONLY(x) \ # define TICKY_BUILD_ONLY(x) \
errorBelch("the flag %s requires the program to be built with -ticky", rts_argv[arg]); \ errorBelch("the flag %s requires the program to be built with -ticky", \
rts_argv[arg]); \
error = rtsTrue; error = rtsTrue;
#endif #endif
...@@ -669,7 +690,8 @@ error = rtsTrue; ...@@ -669,7 +690,8 @@ error = rtsTrue;
# define PROFILING_BUILD_ONLY(x) x # define PROFILING_BUILD_ONLY(x) x
#else #else
# define PROFILING_BUILD_ONLY(x) \ # define PROFILING_BUILD_ONLY(x) \
errorBelch("the flag %s requires the program to be built with -prof", rts_argv[arg]); \ errorBelch("the flag %s requires the program to be built with -prof", \
rts_argv[arg]); \
error = rtsTrue; error = rtsTrue;
#endif #endif
...@@ -677,7 +699,8 @@ error = rtsTrue; ...@@ -677,7 +699,8 @@ error = rtsTrue;
# define TRACING_BUILD_ONLY(x) x # define TRACING_BUILD_ONLY(x) x
#else #else
# define TRACING_BUILD_ONLY(x) \ # define TRACING_BUILD_ONLY(x) \
errorBelch("the flag %s requires the program to be built with -eventlog or -debug", rts_argv[arg]); \ errorBelch("the flag %s requires the program to be built with -eventlog or -debug", \
rts_argv[arg]); \
error = rtsTrue; error = rtsTrue;
#endif #endif
...@@ -685,7 +708,8 @@ error = rtsTrue; ...@@ -685,7 +708,8 @@ error = rtsTrue;
# define THREADED_BUILD_ONLY(x) x # define THREADED_BUILD_ONLY(x) x
#else #else
# define THREADED_BUILD_ONLY(x) \ # define THREADED_BUILD_ONLY(x) \
errorBelch("the flag %s requires the program to be built with -threaded", rts_argv[arg]); \ errorBelch("the flag %s requires the program to be built with -threaded", \
rts_argv[arg]); \
error = rtsTrue; error = rtsTrue;
#endif #endif
...@@ -693,7 +717,8 @@ error = rtsTrue; ...@@ -693,7 +717,8 @@ error = rtsTrue;
# define DEBUG_BUILD_ONLY(x) x # define DEBUG_BUILD_ONLY(x) x
#else #else
# define DEBUG_BUILD_ONLY(x) \ # define DEBUG_BUILD_ONLY(x) \
errorBelch("the flag %s requires the program to be built with -debug", rts_argv[arg]); \ errorBelch("the flag %s requires the program to be built with -debug", \
rts_argv[arg]); \
error = rtsTrue; error = rtsTrue;
#endif #endif
...@@ -882,7 +907,8 @@ error = rtsTrue; ...@@ -882,7 +907,8 @@ error = rtsTrue;
case 'K': case 'K':
OPTION_UNSAFE; OPTION_UNSAFE;
RtsFlags.GcFlags.maxStkSize = RtsFlags.GcFlags.maxStkSize =
decodeSize(rts_argv[arg], 2, sizeof(W_), HS_WORD_MAX) / sizeof(W_); decodeSize(rts_argv[arg], 2, sizeof(W_), HS_WORD_MAX)
/ sizeof(W_);
break; break;
case 'k': case 'k':
...@@ -890,19 +916,23 @@ error = rtsTrue; ...@@ -890,19 +916,23 @@ error = rtsTrue;
switch(rts_argv[arg][2]) { switch(rts_argv[arg][2]) {
case 'c': case 'c':
RtsFlags.GcFlags.stkChunkSize = RtsFlags.GcFlags.stkChunkSize =
decodeSize(rts_argv[arg], 3, sizeof(W_), HS_WORD_MAX) / sizeof(W_); decodeSize(rts_argv[arg], 3, sizeof(W_), HS_WORD_MAX)
/ sizeof(W_);
break; break;
case 'b': case 'b':
RtsFlags.GcFlags.stkChunkBufferSize = RtsFlags.GcFlags.stkChunkBufferSize =
decodeSize(rts_argv[arg], 3, sizeof(W_), HS_WORD_MAX) / sizeof(W_); decodeSize(rts_argv[arg], 3, sizeof(W_), HS_WORD_MAX)
/ sizeof(W_);
break; break;
case 'i': case 'i':
RtsFlags.GcFlags.initialStkSize = RtsFlags.GcFlags.initialStkSize =
decodeSize(rts_argv[arg], 3, sizeof(W_), HS_WORD_MAX) / sizeof(W_); decodeSize(rts_argv[arg], 3, sizeof(W_), HS_WORD_MAX)
/ sizeof(W_);
break; break;
default: default:
RtsFlags.GcFlags.initialStkSize = RtsFlags.GcFlags.initialStkSize =
decodeSize(rts_argv[arg], 2, sizeof(W_), HS_WORD_MAX) / sizeof(W_); decodeSize(rts_argv[arg], 2, sizeof(W_), HS_WORD_MAX)
/ sizeof(W_);
break; break;
} }
break; break;
...@@ -910,8 +940,10 @@ error = rtsTrue; ...@@ -910,8 +940,10 @@ error = rtsTrue;
case 'M': case 'M':
OPTION_UNSAFE; OPTION_UNSAFE;
RtsFlags.GcFlags.maxHeapSize = RtsFlags.GcFlags.maxHeapSize =
decodeSize(rts_argv[arg], 2, BLOCK_SIZE, HS_WORD_MAX) / BLOCK_SIZE; decodeSize(rts_argv[arg], 2, BLOCK_SIZE, HS_WORD_MAX)
/* user give size in *bytes* but "maxHeapSize" is in *blocks* */ / BLOCK_SIZE;
/* user give size in *bytes* but "maxHeapSize" is in
* *blocks* */
break; break;
case 'm': case 'm':
...@@ -1024,7 +1056,8 @@ error = rtsTrue; ...@@ -1024,7 +1056,8 @@ error = rtsTrue;
case 'R': case 'R':
OPTION_SAFE; OPTION_SAFE;
PROFILING_BUILD_ONLY( PROFILING_BUILD_ONLY(
RtsFlags.ProfFlags.maxRetainerSetSize = atof(rts_argv[arg]+2); RtsFlags.ProfFlags.maxRetainerSetSize =
atof(rts_argv[arg]+2);
) break; ) break;
case 'L': case 'L':
OPTION_SAFE; OPTION_SAFE;
...@@ -1207,7 +1240,7 @@ error = rtsTrue; ...@@ -1207,7 +1240,7 @@ error = rtsTrue;
} }
if (rtsOptsEnabled == RtsOptsSafeOnly && if (rtsOptsEnabled == RtsOptsSafeOnly &&
nNodes > (int)getNumberOfProcessors()) { nNodes > (int)getNumberOfProcessors()) {
errorRtsOptsDisabled(is_hs_main, "Using large values for -N is not allowed by default. %s"); errorRtsOptsDisabled("Using large values for -N is not allowed by default. %s");
stg_exit(EXIT_FAILURE); stg_exit(EXIT_FAILURE);
} }