jit: supply MULTILIB_DEFAULTS as arguments when invoking driver
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 23 Jul 2015 21:19:07 +0000 (21:19 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Thu, 23 Jul 2015 21:19:07 +0000 (21:19 +0000)
gcc/jit/ChangeLog:
* jit-playback.c (invoke_driver): Convert local "argvec"
to an auto_argvec, so that it owns copies of the strings,
rather than borrows them, updating ADD_ARG to use xstrdup
and special-casing the NULL terminator to avoid
xstrdup (NULL).  Call add_multilib_driver_arguments at the front
of the arguments.
(MULTILIB_DEFAULTS): Provide a default definition.
(multilib_defaults_raw): New constant array.
(gcc::jit::playback::context::add_multilib_driver_arguments): New
method.
* jit-playback.h
(gcc::jit::playback::context::add_multilib_driver_arguments): New
method.
* docs/internals/test-hello-world.exe.log.txt: Update.
* docs/_build/texinfo/libgccjit.texi: Regenerate.

From-SVN: r226126

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

index e0abaac8eb7fae0fd0cfb48678db8e6e9dcc974e..f38143d02e471285e4a61c730a537fe269bfc8ab 100644 (file)
@@ -1,3 +1,21 @@
+2015-07-23  David Malcolm  <dmalcolm@redhat.com>
+
+       * jit-playback.c (invoke_driver): Convert local "argvec"
+       to an auto_argvec, so that it owns copies of the strings,
+       rather than borrows them, updating ADD_ARG to use xstrdup
+       and special-casing the NULL terminator to avoid
+       xstrdup (NULL).  Call add_multilib_driver_arguments at the front
+       of the arguments.
+       (MULTILIB_DEFAULTS): Provide a default definition.
+       (multilib_defaults_raw): New constant array.
+       (gcc::jit::playback::context::add_multilib_driver_arguments): New
+       method.
+       * jit-playback.h
+       (gcc::jit::playback::context::add_multilib_driver_arguments): New
+       method.
+       * docs/internals/test-hello-world.exe.log.txt: Update.
+       * docs/_build/texinfo/libgccjit.texi: Regenerate.
+
 2015-07-16  David Malcolm  <dmalcolm@redhat.com>
 
        * docs/internals/index.rst (Overview of code structure): Add note
index c304c26be3e7c02093810ae964c3fa20ed98dcf0..88df0ad9440d4e0a9ed72d0b3d9041a610458d22 100644 (file)
@@ -19,7 +19,7 @@
 
 @copying
 @quotation
-libgccjit 6.0.0 (experimental 20150716), July 16, 2015
+libgccjit 6.0.0 (experimental 20150723), July 23, 2015
 
 David Malcolm
 
@@ -14680,7 +14680,7 @@ 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: libgccjit (GCC) version 6.0.0 20150723 (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:  GCC_JIT_STR_OPTION_PROGNAME: "./test-hello-world.c.exe"
@@ -14746,6 +14746,7 @@ JIT:   GCC_JIT_BOOL_OPTION_DUMP_SUMMARY: false
 JIT:   GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING: false
 JIT:   GCC_JIT_BOOL_OPTION_SELFCHECK_GC: true
 JIT:   GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES: false
+JIT:   gcc_jit_context_set_bool_allow_unreachable_blocks: false
 JIT:   entering: void gcc::jit::recording::context::validate()
 JIT:   exiting: void gcc::jit::recording::context::validate()
 JIT:   entering: gcc::jit::playback::context::context(gcc::jit::recording::context*)
@@ -14797,12 +14798,6 @@ JIT:      exiting: void gcc::jit::playback::function::postprocess()
 JIT:      entering: void gcc::jit::playback::function::postprocess()
 JIT:      exiting: void gcc::jit::playback::function::postprocess()
 JIT:     exiting: void gcc::jit::playback::context::replay()
-JIT:     entering: void jit_langhook_write_globals()
-JIT:      entering: void gcc::jit::playback::context::write_global_decls_1()
-JIT:      exiting: void gcc::jit::playback::context::write_global_decls_1()
-JIT:      entering: void gcc::jit::playback::context::write_global_decls_2()
-JIT:      exiting: void gcc::jit::playback::context::write_global_decls_2()
-JIT:     exiting: void jit_langhook_write_globals()
 JIT:    exiting: toplev::main
 JIT:    entering: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*)
 JIT:    exiting: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*)
@@ -14811,13 +14806,16 @@ JIT:    exiting: toplev::finalize
 JIT:    entering: virtual void gcc::jit::playback::compile_to_memory::postprocess(const char*)
 JIT:     entering: void gcc::jit::playback::context::convert_to_dso(const char*)
 JIT:      entering: void gcc::jit::playback::context::invoke_driver(const char*, const char*, const char*, timevar_id_t, bool, bool)
-JIT:       argv[0]: x86_64-unknown-linux-gnu-gcc-5.0.0
-JIT:       argv[1]: -shared
-JIT:       argv[2]: /tmp/libgccjit-CKq1M9/fake.s
-JIT:       argv[3]: -o
-JIT:       argv[4]: /tmp/libgccjit-CKq1M9/fake.so
-JIT:       argv[5]: -fno-use-linker-plugin
-JIT:       argv[6]: (null)
+JIT:       entering: void gcc::jit::playback::context::add_multilib_driver_arguments(vec<char*>*)
+JIT:       exiting: void gcc::jit::playback::context::add_multilib_driver_arguments(vec<char*>*)
+JIT:       argv[0]: x86_64-unknown-linux-gnu-gcc-6.0.0
+JIT:       argv[1]: -m64
+JIT:       argv[2]: -shared
+JIT:       argv[3]: /tmp/libgccjit-CKq1M9/fake.s
+JIT:       argv[4]: -o
+JIT:       argv[5]: /tmp/libgccjit-CKq1M9/fake.so
+JIT:       argv[6]: -fno-use-linker-plugin
+JIT:       argv[7]: (null)
 JIT:      exiting: void gcc::jit::playback::context::invoke_driver(const char*, const char*, const char*, timevar_id_t, bool, bool)
 JIT:     exiting: void gcc::jit::playback::context::convert_to_dso(const char*)
 JIT:     entering: gcc::jit::result* gcc::jit::playback::context::dlopen_built_dso()
index 5cb3aef8e781f50857a904530cb38b6bdb79e416..d82038be864743ea28238d262c7baa39b95d4f20 100644 (file)
@@ -1,4 +1,4 @@
-JIT: libgccjit (GCC) version 5.0.0 20150123 (experimental) (x86_64-unknown-linux-gnu)
+JIT: libgccjit (GCC) version 6.0.0 20150723 (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:  GCC_JIT_STR_OPTION_PROGNAME: "./test-hello-world.c.exe"
@@ -64,6 +64,7 @@ JIT:   GCC_JIT_BOOL_OPTION_DUMP_SUMMARY: false
 JIT:   GCC_JIT_BOOL_OPTION_DUMP_EVERYTHING: false
 JIT:   GCC_JIT_BOOL_OPTION_SELFCHECK_GC: true
 JIT:   GCC_JIT_BOOL_OPTION_KEEP_INTERMEDIATES: false
+JIT:   gcc_jit_context_set_bool_allow_unreachable_blocks: false
 JIT:   entering: void gcc::jit::recording::context::validate()
 JIT:   exiting: void gcc::jit::recording::context::validate()
 JIT:   entering: gcc::jit::playback::context::context(gcc::jit::recording::context*)
@@ -115,12 +116,6 @@ JIT:      exiting: void gcc::jit::playback::function::postprocess()
 JIT:      entering: void gcc::jit::playback::function::postprocess()
 JIT:      exiting: void gcc::jit::playback::function::postprocess()
 JIT:     exiting: void gcc::jit::playback::context::replay()
-JIT:     entering: void jit_langhook_write_globals()
-JIT:      entering: void gcc::jit::playback::context::write_global_decls_1()
-JIT:      exiting: void gcc::jit::playback::context::write_global_decls_1()
-JIT:      entering: void gcc::jit::playback::context::write_global_decls_2()
-JIT:      exiting: void gcc::jit::playback::context::write_global_decls_2()
-JIT:     exiting: void jit_langhook_write_globals()
 JIT:    exiting: toplev::main
 JIT:    entering: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*)
 JIT:    exiting: void gcc::jit::playback::context::extract_any_requested_dumps(vec<gcc::jit::recording::requested_dump>*)
@@ -129,13 +124,16 @@ JIT:    exiting: toplev::finalize
 JIT:    entering: virtual void gcc::jit::playback::compile_to_memory::postprocess(const char*)
 JIT:     entering: void gcc::jit::playback::context::convert_to_dso(const char*)
 JIT:      entering: void gcc::jit::playback::context::invoke_driver(const char*, const char*, const char*, timevar_id_t, bool, bool)
-JIT:       argv[0]: x86_64-unknown-linux-gnu-gcc-5.0.0
-JIT:       argv[1]: -shared
-JIT:       argv[2]: /tmp/libgccjit-CKq1M9/fake.s
-JIT:       argv[3]: -o
-JIT:       argv[4]: /tmp/libgccjit-CKq1M9/fake.so
-JIT:       argv[5]: -fno-use-linker-plugin
-JIT:       argv[6]: (null)
+JIT:       entering: void gcc::jit::playback::context::add_multilib_driver_arguments(vec<char*>*)
+JIT:       exiting: void gcc::jit::playback::context::add_multilib_driver_arguments(vec<char*>*)
+JIT:       argv[0]: x86_64-unknown-linux-gnu-gcc-6.0.0
+JIT:       argv[1]: -m64
+JIT:       argv[2]: -shared
+JIT:       argv[3]: /tmp/libgccjit-CKq1M9/fake.s
+JIT:       argv[4]: -o
+JIT:       argv[5]: /tmp/libgccjit-CKq1M9/fake.so
+JIT:       argv[6]: -fno-use-linker-plugin
+JIT:       argv[7]: (null)
 JIT:      exiting: void gcc::jit::playback::context::invoke_driver(const char*, const char*, const char*, timevar_id_t, bool, bool)
 JIT:     exiting: void gcc::jit::playback::context::convert_to_dso(const char*)
 JIT:     entering: gcc::jit::result* gcc::jit::playback::context::dlopen_built_dso()
index 8d0c210a55636ce7a50d6980c1901fdf302cc608..c46986327dc5b2194948409f043855ede922eb4b 100644 (file)
@@ -2382,14 +2382,16 @@ invoke_driver (const char *ctxt_progname,
      TV_ASSEMBLE.  */
   auto_timevar assemble_timevar (tv_id);
   const char *errmsg;
-  auto_vec <const char *> argvec;
-#define ADD_ARG(arg) argvec.safe_push (arg)
+  auto_argvec argvec;
+#define ADD_ARG(arg) argvec.safe_push (xstrdup (arg))
   int exit_status = 0;
   int err = 0;
   const char *gcc_driver_name = GCC_DRIVER_NAME;
 
   ADD_ARG (gcc_driver_name);
 
+  add_multilib_driver_arguments (&argvec);
+
   if (shared)
     ADD_ARG ("-shared");
 
@@ -2410,7 +2412,7 @@ invoke_driver (const char *ctxt_progname,
   ADD_ARG ("-fno-use-linker-plugin");
 
   /* pex argv arrays are NULL-terminated.  */
-  ADD_ARG (NULL);
+  argvec.safe_push (NULL);
 
   /* pex_one's error-handling requires pname to be non-NULL.  */
   gcc_assert (ctxt_progname);
@@ -2451,6 +2453,36 @@ invoke_driver (const char *ctxt_progname,
 #undef ADD_ARG
 }
 
+/* Extract the target-specific MULTILIB_DEFAULTS to
+   multilib_defaults_raw for use by
+   playback::context::add_multilib_driver_arguments ().  */
+
+#ifndef MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS { "" }
+#endif
+
+static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS;
+
+/* Helper function for playback::context::invoke_driver ().
+
+   32-bit and 64-bit multilib peer builds of libgccjit.so may share
+   a driver binary.  We need to pass in options to the shared driver
+   to get the appropriate assembler/linker options for this multilib
+   peer.  */
+
+void
+playback::context::
+add_multilib_driver_arguments (vec <char *> *argvec)
+{
+  JIT_LOG_SCOPE (get_logger ());
+
+  /* Add copies of the arguments in multilib_defaults_raw to argvec,
+     prepending each with a "-".  */
+  for (size_t i = 0; i < ARRAY_SIZE (multilib_defaults_raw); i++)
+    if (multilib_defaults_raw[i][0])
+      argvec->safe_push (concat ("-", multilib_defaults_raw[i], NULL));
+}
+
 /* Dynamically-link the built DSO file into this process, using dlopen.
    Wrap it up within a jit::result *, and return that.
    Return NULL if any errors occur, reporting them on this context.  */
index 13cc748135f26a7f2fe8535e0de439becba4b5dc..1d7de17ca1c9cf19b39b59c54f4a229c41d53044 100644 (file)
@@ -272,6 +272,9 @@ protected:
                 bool shared,
                 bool run_linker);
 
+  void
+  add_multilib_driver_arguments (vec <char *> *argvec);
+
   result *
   dlopen_built_dso ();