From eb3982c17ef6db63b43eda4b346f34d4a2bd2465 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 23 Jul 2015 21:19:07 +0000 Subject: [PATCH] jit: supply MULTILIB_DEFAULTS as arguments when invoking driver 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 | 18 +++++++++ gcc/jit/docs/_build/texinfo/libgccjit.texi | 28 +++++++------- .../internals/test-hello-world.exe.log.txt | 26 ++++++------- gcc/jit/jit-playback.c | 38 +++++++++++++++++-- gcc/jit/jit-playback.h | 3 ++ 5 files changed, 81 insertions(+), 32 deletions(-) diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index e0abaac8eb7..f38143d02e4 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,21 @@ +2015-07-23 David Malcolm + + * 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 * docs/internals/index.rst (Overview of code structure): Add note diff --git a/gcc/jit/docs/_build/texinfo/libgccjit.texi b/gcc/jit/docs/_build/texinfo/libgccjit.texi index c304c26be3e..88df0ad9440 100644 --- a/gcc/jit/docs/_build/texinfo/libgccjit.texi +++ b/gcc/jit/docs/_build/texinfo/libgccjit.texi @@ -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*) JIT: exiting: void gcc::jit::playback::context::extract_any_requested_dumps(vec*) @@ -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*) +JIT: exiting: void gcc::jit::playback::context::add_multilib_driver_arguments(vec*) +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() diff --git a/gcc/jit/docs/internals/test-hello-world.exe.log.txt b/gcc/jit/docs/internals/test-hello-world.exe.log.txt index 5cb3aef8e78..d82038be864 100644 --- a/gcc/jit/docs/internals/test-hello-world.exe.log.txt +++ b/gcc/jit/docs/internals/test-hello-world.exe.log.txt @@ -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*) JIT: exiting: void gcc::jit::playback::context::extract_any_requested_dumps(vec*) @@ -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*) +JIT: exiting: void gcc::jit::playback::context::add_multilib_driver_arguments(vec*) +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() diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index 8d0c210a556..c46986327dc 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -2382,14 +2382,16 @@ invoke_driver (const char *ctxt_progname, TV_ASSEMBLE. */ auto_timevar assemble_timevar (tv_id); const char *errmsg; - auto_vec 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 *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. */ diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index 13cc748135f..1d7de17ca1c 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -272,6 +272,9 @@ protected: bool shared, bool run_linker); + void + add_multilib_driver_arguments (vec *argvec); + result * dlopen_built_dso (); -- 2.30.2