[commit: ghc] master: Show -with-rtsopts options in runtime's --info (#15261) (dcf27e6)

git at git.haskell.org git at git.haskell.org
Tue Aug 21 22:57:54 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/dcf27e6f78529e7e471a4be64ca47398eb1b6b52/ghc

>---------------------------------------------------------------

commit dcf27e6f78529e7e471a4be64ca47398eb1b6b52
Author: roland <rsx at bluewin.ch>
Date:   Tue Aug 21 16:05:45 2018 -0400

    Show -with-rtsopts options in runtime's --info (#15261)
    
    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


>---------------------------------------------------------------

dcf27e6f78529e7e471a4be64ca47398eb1b6b52
 docs/users_guide/phases.rst               |  3 +++
 docs/users_guide/runtime_control.rst      |  4 ++++
 rts/RtsFlags.c                            |  2 +-
 rts/RtsUtils.c                            |  6 ++++--
 rts/RtsUtils.h                            |  2 +-
 testsuite/tests/rts/T15261/Makefile       | 11 +++++++++++
 testsuite/tests/rts/T15261/T15261a.hs     |  2 ++
 testsuite/tests/rts/T15261/T15261a.stdout |  1 +
 testsuite/tests/rts/T15261/T15261b.hs     |  2 ++
 testsuite/tests/rts/T15261/T15261b.stdout |  1 +
 testsuite/tests/rts/T15261/all.T          |  2 ++
 11 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst
index f8fe8d1..531f8c0 100644
--- a/docs/users_guide/phases.rst
+++ b/docs/users_guide/phases.rst
@@ -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.
 
diff --git a/docs/users_guide/runtime_control.rst b/docs/users_guide/runtime_control.rst
index 797c7e2..0c38ac5 100644
--- a/docs/users_guide/runtime_control.rst
+++ b/docs/users_guide/runtime_control.rst
@@ -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.
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 7c292d2..6a72e67 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -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)
diff --git a/rts/RtsUtils.c b/rts/RtsUtils.c
index 5357dc6..618815d 100644
--- a/rts/RtsUtils.c
+++ b/rts/RtsUtils.c
@@ -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");
 }
 
diff --git a/rts/RtsUtils.h b/rts/RtsUtils.h
index 16596c1..49712c0 100644
--- a/rts/RtsUtils.h
+++ b/rts/RtsUtils.h
@@ -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
index 0000000..f50b22c
--- /dev/null
+++ b/testsuite/tests/rts/T15261/Makefile
@@ -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
index 0000000..4c512dc
--- /dev/null
+++ b/testsuite/tests/rts/T15261/T15261a.hs
@@ -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
index 0000000..5919bb4
--- /dev/null
+++ b/testsuite/tests/rts/T15261/T15261a.stdout
@@ -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
index 0000000..1304a85
--- /dev/null
+++ b/testsuite/tests/rts/T15261/T15261b.hs
@@ -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
index 0000000..80184e8
--- /dev/null
+++ b/testsuite/tests/rts/T15261/T15261b.stdout
@@ -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
index 0000000..5bc6977
--- /dev/null
+++ b/testsuite/tests/rts/T15261/all.T
@@ -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'])



More information about the ghc-commits mailing list