]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
toplev: gcc version information for jit
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 27 Jan 2015 20:19:36 +0000 (20:19 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 27 Jan 2015 20:19:36 +0000 (20:19 +0000)
gcc/ChangeLog:
* toplev.c (print_version): Add param "show_global_state", and
only print GGC and plugin information if it is true.
(init_asm_output): Pass in "true" for the new param when calling
print_version.
(process_options): Likewise.
(toplev::main): Likewise.
* toplev.h (print_version): Add new param to decl.

gcc/jit/ChangeLog:
* docs/internals/test-hello-world.exe.log.txt: Add example version
lines.
* jit-common.h (gcc::jit::dump::get_file): New accessor.
* jit-logging.c: Include toplev.h.
(gcc::jit::logger::logger): Log the GCC version.
* jit-recording.c: Include toplev.h.
(gcc:jit::recording::context::dump_reproducer_to_file): Log the
GCC version.

From-SVN: r220190

gcc/ChangeLog
gcc/jit/ChangeLog
gcc/jit/docs/_build/texinfo/libgccjit.texi
gcc/jit/docs/internals/test-hello-world.exe.log.txt
gcc/jit/jit-common.h
gcc/jit/jit-logging.c
gcc/jit/jit-recording.c
gcc/toplev.c
gcc/toplev.h

index 36d0045f1943f7e8f4f3207682ab7d1430fc6308..67d3fc77555a764e48a838e91f77bbd65ec788ba 100644 (file)
@@ -1,3 +1,13 @@
+2015-01-27  David Malcolm  <dmalcolm@redhat.com>
+
+       * toplev.c (print_version): Add param "show_global_state", and
+       only print GGC and plugin information if it is true.
+       (init_asm_output): Pass in "true" for the new param when calling
+       print_version.
+       (process_options): Likewise.
+       (toplev::main): Likewise.
+       * toplev.h (print_version): Add new param to decl.
+
 2015-01-27  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/60871
index 577712cc6bcda00d622af672a2bdae79c8c442a5..a260ab083a2814e8b7d8167a2c1368f0dea03633 100644 (file)
@@ -1,3 +1,15 @@
+2015-01-27  David Malcolm  <dmalcolm@redhat.com>
+
+       * docs/internals/test-hello-world.exe.log.txt: Add example version
+       lines.
+       * docs/_build/texinfo/libgccjit.texi: Regenerate.
+       * jit-common.h (gcc::jit::dump::get_file): New accessor.
+       * jit-logging.c: Include toplev.h.
+       (gcc::jit::logger::logger): Log the GCC version.
+       * jit-recording.c: Include toplev.h.
+       (gcc:jit::recording::context::dump_reproducer_to_file): Log the
+       GCC version.
+
 2015-01-26  David Malcolm  <dmalcolm@redhat.com>
 
        * docs/topics/compilation.rst (gcc_jit_result_get_code): Fix typo.
index 3c324996052daade5b2650aebe1de3de58f704ad..37c466480cd15ae25efa25c6602f0ebd081e6511 100644 (file)
@@ -19,7 +19,7 @@
 
 @copying
 @quotation
-libgccjit 5.0.0 (experimental 20150126), January 26, 2015
+libgccjit 5.0.0 (experimental 20150127), January 27, 2015
 
 David Malcolm
 
@@ -13753,6 +13753,8 @@ via @pxref{5b,,gcc_jit_context_set_logfile()}.  Here is an example of a log
 generated via this call:
 
 @example
+JIT: libgccjit (GCC) version 5.0.0 20150123 (experimental) (x86_64-unknown-linux-gnu)
+JIT:   compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
 JIT: entering: gcc_jit_context_set_str_option
 JIT: exiting: gcc_jit_context_set_str_option
 JIT: entering: gcc_jit_context_set_int_option
index 205b6b47558d7d909cc3079a5f87acebf3067ff8..876d830b84adc4010b22c4092cde01ccf5107beb 100644 (file)
@@ -1,3 +1,5 @@
+JIT: libgccjit (GCC) version 5.0.0 20150123 (experimental) (x86_64-unknown-linux-gnu)
+JIT:   compiled by GNU C version 4.8.3 20140911 (Red Hat 4.8.3-7), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1
 JIT: entering: gcc_jit_context_set_str_option
 JIT: exiting: gcc_jit_context_set_str_option
 JIT: entering: gcc_jit_context_set_int_option
index 09d63badd9c9765ff968c12e07b30adb50e1fe4c..8753651a2be54a1f46568fb314ce0f381b823d49 100644 (file)
@@ -178,6 +178,8 @@ public:
   recording::location *
   make_location () const;
 
+  FILE *get_file () const { return m_file; }
+
 private:
   recording::context &m_ctxt;
   const char *m_filename;
index 61b898b00bd1af379efe2beb6b9a4eca25e9241f..22ab6fd42386bf6003873427698d44a65d8d4052 100644 (file)
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "toplev.h" /* for print_version */
 
 #include "jit-logging.h"
 
@@ -41,6 +42,8 @@ logger::logger (FILE *f_out,
   m_indent_level (0),
   m_log_refcount_changes (false)
 {
+  /* Begin the log by writing the GCC version.  */
+  print_version (f_out, "JIT:", false);
 }
 
 /* The destructor for gcc::jit::logger, invoked via
index 1077f2732e9049c7ffebbbae594c728aa60388c0..9f6e5fdeef8f6ec838d10639631077a12aaa24a6 100644 (file)
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "pretty-print.h"
 #include "hash-map.h"
+#include "toplev.h"
 
 #include <pthread.h>
 
@@ -1414,7 +1415,9 @@ recording::context::dump_reproducer_to_file (const char *path)
              == contexts[0]);
 
   r.write ("/* This code was autogenerated by"
-          " gcc_jit_context_dump_reproducer_to_file.  */\n\n");
+          " gcc_jit_context_dump_reproducer_to_file.\n\n");
+  print_version (r.get_file (), "  ", false);
+  r.write ("*/\n");
   r.write ("#include <libgccjit.h>\n\n");
   r.write ("static void\nset_options (");
   r.write_params (contexts);
index 50846280053191028d3d39787133cfa8d9eca75b..bc2ca3b3a27e0172ee1f3fede9f21aa528762743 100644 (file)
@@ -728,10 +728,19 @@ compile_file (void)
 
 /* Print version information to FILE.
    Each line begins with INDENT (for the case where FILE is the
-   assembler output file).  */
+   assembler output file).
+
+   If SHOW_GLOBAL_STATE is true (for cc1 etc), we are within the compiler
+   proper and can print pertinent state (e.g. params and plugins).
+
+   If SHOW_GLOBAL_STATE is false (for use by libgccjit), we are outside the
+   compiler, and we don't hold the mutex on the compiler's global state:
+   we can't print params and plugins, since they might not be initialized,
+   or might be being manipulated by a compile running in another
+   thread.  */
 
 void
-print_version (FILE *file, const char *indent)
+print_version (FILE *file, const char *indent, bool show_global_state)
 {
   static const char fmt1[] =
 #ifdef __GNUC__
@@ -791,12 +800,16 @@ print_version (FILE *file, const char *indent)
             file == stderr ? _(fmt3) : fmt3,
             indent, *indent != 0 ? " " : "",
             "MPC", MPC_VERSION_STRING, mpc_get_version ());
-  fprintf (file,
-          file == stderr ? _(fmt4) : fmt4,
-          indent, *indent != 0 ? " " : "",
-          PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
 
-  print_plugins_versions (file, indent);
+  if (show_global_state)
+    {
+      fprintf (file,
+              file == stderr ? _(fmt4) : fmt4,
+              indent, *indent != 0 ? " " : "",
+              PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
+
+      print_plugins_versions (file, indent);
+    }
 }
 
 static int
@@ -1008,7 +1021,7 @@ init_asm_output (const char *name)
        {
          /* Print the list of switches in effect
             into the assembler file as comments.  */
-         print_version (asm_out_file, ASM_COMMENT_START);
+         print_version (asm_out_file, ASM_COMMENT_START, true);
          print_switch_values (print_to_asm_out_file);
          putc ('\n', asm_out_file);
        }
@@ -1426,7 +1439,7 @@ process_options (void)
      option flags in use.  */
   if (version_flag)
     {
-      print_version (stderr, "");
+      print_version (stderr, "", true);
       if (! quiet_flag)
        print_switch_values (print_to_stderr);
     }
@@ -2135,7 +2148,7 @@ toplev::main (int argc, char **argv)
   initialize_plugins ();
 
   if (version_flag)
-    print_version (stderr, "");
+    print_version (stderr, "", true);
 
   if (help_flag)
     print_plugins_help (stderr, "");
index 6b423be3c51b9fb7d862c95b4c0331450af60574..9527f76ac6e92ec55e17925b22dcf96b4c5c9643 100644 (file)
@@ -80,7 +80,7 @@ extern bool user_defined_section_attribute;
 /* See toplev.c.  */
 extern int flag_rerun_cse_after_global_opts;
 
-extern void print_version (FILE *, const char *);
+extern void print_version (FILE *, const char *, bool);
 
 /* The hashtable, so that the C front ends can pass it to cpplib.  */
 extern struct ht *ident_hash;