summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2010-03-13 15:45:55 +0000
committerIan Lynagh <igloo@earth.li>2010-03-13 15:45:55 +0000
commit929d166932ee207871e66cc305059f356241c06b (patch)
treea8eec6032460dafe24abfdaa233b56c6bbf26cd5 /rts
parent1e31c2960f7a9fc61119237d8a35b0516d6accca (diff)
downloadhaskell-929d166932ee207871e66cc305059f356241c06b.tar.gz
Add a link-time flag to en/disable the RTS options
If RTS options are disabled then: * The ghc_rts_opts C code variable is processed as normal * The GHCRTS environment variable is ignored and, if it is defined, a warning is emitted * The +RTS flag gives an error and terminates the program
Diffstat (limited to 'rts')
-rw-r--r--rts/RtsFlags.c17
-rw-r--r--rts/RtsOpts.h14
-rw-r--r--rts/hooks/RtsOptsEnabled.c13
3 files changed, 42 insertions, 2 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index b99995b16d..790bf426c2 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -10,6 +10,7 @@
#include "PosixSource.h"
#include "Rts.h"
+#include "RtsOpts.h"
#include "RtsUtils.h"
#include "Profiling.h"
@@ -413,7 +414,13 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[])
char *ghc_rts = getenv("GHCRTS");
if (ghc_rts != NULL) {
- splitRtsFlags(ghc_rts, rts_argc, rts_argv);
+ if (rtsOptsEnabled) {
+ splitRtsFlags(ghc_rts, rts_argc, rts_argv);
+ }
+ else {
+ errorBelch("Warning: Ignoring GHCRTS variable");
+ // We don't actually exit, just warn
+ }
}
}
@@ -432,7 +439,13 @@ setupRtsFlags(int *argc, char *argv[], int *rts_argc, char *rts_argv[])
break;
}
else if (strequal("+RTS", argv[arg])) {
- mode = RTS;
+ if (rtsOptsEnabled) {
+ mode = RTS;
+ }
+ else {
+ errorBelch("RTS options are disabled");
+ stg_exit(EXIT_FAILURE);
+ }
}
else if (strequal("-RTS", argv[arg])) {
mode = PGM;
diff --git a/rts/RtsOpts.h b/rts/RtsOpts.h
new file mode 100644
index 0000000000..381ee0e3c5
--- /dev/null
+++ b/rts/RtsOpts.h
@@ -0,0 +1,14 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team, 2010
+ *
+ * En/disable RTS options
+ *
+ * ---------------------------------------------------------------------------*/
+
+#ifndef RTSOPTS_H
+#define RTSOPTS_H
+
+extern const rtsBool rtsOptsEnabled;
+
+#endif /* RTSOPTS_H */
diff --git a/rts/hooks/RtsOptsEnabled.c b/rts/hooks/RtsOptsEnabled.c
new file mode 100644
index 0000000000..d7d6cb595f
--- /dev/null
+++ b/rts/hooks/RtsOptsEnabled.c
@@ -0,0 +1,13 @@
+/* -----------------------------------------------------------------------------
+ *
+ * (c) The GHC Team 2010
+ *
+ * En/disable RTS options
+ *
+ * ---------------------------------------------------------------------------*/
+
+#include "Rts.h"
+#include "RtsOpts.h"
+
+const rtsBool rtsOptsEnabled = rtsFalse;
+