Show -with-rtsopts options in runtime's --info (#15261)
authorroland <rsx@bluewin.ch>
Tue, 21 Aug 2018 20:05:45 +0000 (16:05 -0400)
committerBen Gamari <ben@smart-cactus.org>
Tue, 21 Aug 2018 22:56:12 +0000 (18:56 -0400)
Add an additional line to the output of +RTS --info.  It shows the value
of the flag -with-rtsopts provided at compile/link time.

Test Plan: make test TESTS="T15261a T15261b"

Reviewers: hvr, erikd, dfeuer, thomie, austin, bgamari, simonmar, osa1,
monoidal

Reviewed By: osa1, monoidal

Subscribers: osa1, rwbarton, carter

GHC Trac Issues: #15261

Differential Revision: https://phabricator.haskell.org/D5053

docs/users_guide/phases.rst
docs/users_guide/runtime_control.rst
rts/RtsFlags.c
rts/RtsUtils.c
rts/RtsUtils.h
testsuite/tests/rts/T15261/Makefile [new file with mode: 0644]
testsuite/tests/rts/T15261/T15261a.hs [new file with mode: 0644]
testsuite/tests/rts/T15261/T15261a.stdout [new file with mode: 0644]
testsuite/tests/rts/T15261/T15261b.hs [new file with mode: 0644]
testsuite/tests/rts/T15261/T15261b.stdout [new file with mode: 0644]
testsuite/tests/rts/T15261/all.T [new file with mode: 0644]

index f8fe8d1..531f8c0 100644 (file)
@@ -1004,6 +1004,9 @@ for example).
     change RTS options at run-time, in which case ``-with-rtsopts``
     would be the *only* way to set them.)
 
+    Use the runtime flag :rts-flag:`--info` on the executable program
+    to see the options set with ``-with-rtsopts``.
+
     Note that ``-with-rtsopts`` has no effect when used with
     ``-no-hs-main``; see :ref:`using-own-main` for details.
 
index 797c7e2..0c38ac5 100644 (file)
@@ -1219,6 +1219,7 @@ Getting information about the RTS
         ,("Word size", "64")
         ,("Compiler unregisterised", "NO")
         ,("Tables next to code", "YES")
+        ,("Flag -with-rtsopts", "")
         ]
 
     The information is formatted such that it can be read as a of type
@@ -1269,3 +1270,6 @@ Getting information about the RTS
         performance optimisation that is not available on all platforms.
         This field tells you whether the program has been compiled with this
         optimisation. (Usually yes, except on unusual platforms.)
+
+    ``Flag -with-rtsopts``
+        The value of the GHC flag :ghc-flag:`-with-rtsopts=⟨opts⟩` at compile/link time.
index 7c292d2..6a72e67 100644 (file)
@@ -901,7 +901,7 @@ error = true;
                   else if (strequal("info",
                                &rts_argv[arg][2])) {
                       OPTION_SAFE;
-                      printRtsInfo();
+                      printRtsInfo(rtsConfig);
                       stg_exit(0);
                   }
 #if defined(THREADED_RTS)
index 5357dc6..618815d 100644 (file)
@@ -275,7 +275,7 @@ int genericRaise(int sig) {
 #endif
 }
 
-static void mkRtsInfoPair(char *key, char *val) {
+static void mkRtsInfoPair(const char *key, const char *val) {
     /* XXX should check for "s, \s etc in key and val */
     printf(" ,(\"%s\", \"%s\")\n", key, val);
 }
@@ -285,7 +285,7 @@ static void mkRtsInfoPair(char *key, char *val) {
 #define TOSTRING2(x) #x
 #define TOSTRING(x)  TOSTRING2(x)
 
-void printRtsInfo(void) {
+void printRtsInfo(const RtsConfig rts_config) {
     /* The first entry is just a hack to make it easy to get the
      * commas right */
     printf(" [(\"GHC RTS\", \"YES\")\n");
@@ -306,6 +306,8 @@ void printRtsInfo(void) {
     mkRtsInfoPair("Word size",               TOSTRING(WORD_SIZE_IN_BITS));
     mkRtsInfoPair("Compiler unregisterised", GhcUnregisterised);
     mkRtsInfoPair("Tables next to code",     GhcEnableTablesNextToCode);
+    mkRtsInfoPair("Flag -with-rtsopts",      /* See Trac #15261 */
+        rts_config.rts_opts != NULL ? rts_config.rts_opts : "");
     printf(" ]\n");
 }
 
index 16596c1..49712c0 100644 (file)
@@ -40,7 +40,7 @@ char *showStgWord64(StgWord64, char *, bool);
 void heapCheckFail( void );
 #endif
 
-void printRtsInfo(void);
+void printRtsInfo(const RtsConfig);
 
 void checkFPUStack(void);
 
diff --git a/testsuite/tests/rts/T15261/Makefile b/testsuite/tests/rts/T15261/Makefile
new file mode 100644 (file)
index 0000000..f50b22c
--- /dev/null
@@ -0,0 +1,11 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+T15261a:
+       '$(TEST_HC)' $(TEST_HC_OPTS) -v0 -with-rtsopts="-t -s" --make T15261a.hs
+       ./T15261a +RTS --info | grep "rtsopts"
+
+T15261b:
+       '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make T15261b.hs
+       ./T15261b +RTS --info | grep "rtsopts"
diff --git a/testsuite/tests/rts/T15261/T15261a.hs b/testsuite/tests/rts/T15261/T15261a.hs
new file mode 100644 (file)
index 0000000..4c512dc
--- /dev/null
@@ -0,0 +1,2 @@
+main :: IO ()
+main = putStrLn "T15261a"
diff --git a/testsuite/tests/rts/T15261/T15261a.stdout b/testsuite/tests/rts/T15261/T15261a.stdout
new file mode 100644 (file)
index 0000000..5919bb4
--- /dev/null
@@ -0,0 +1 @@
+ ,("Flag -with-rtsopts", "-t -s")
diff --git a/testsuite/tests/rts/T15261/T15261b.hs b/testsuite/tests/rts/T15261/T15261b.hs
new file mode 100644 (file)
index 0000000..1304a85
--- /dev/null
@@ -0,0 +1,2 @@
+main :: IO ()
+main = putStrLn "T15261b"
diff --git a/testsuite/tests/rts/T15261/T15261b.stdout b/testsuite/tests/rts/T15261/T15261b.stdout
new file mode 100644 (file)
index 0000000..80184e8
--- /dev/null
@@ -0,0 +1 @@
+ ,("Flag -with-rtsopts", "")
diff --git a/testsuite/tests/rts/T15261/all.T b/testsuite/tests/rts/T15261/all.T
new file mode 100644 (file)
index 0000000..5bc6977
--- /dev/null
@@ -0,0 +1,2 @@
+test('T15261a', normal, run_command, ['$MAKE -s --no-print-directory T15261a'])
+test('T15261b', normal, run_command, ['$MAKE -s --no-print-directory T15261b'])