diff options
author | David Malcolm <dmalcolm@redhat.com> | 2015-02-03 17:19:58 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2015-02-03 17:19:58 +0000 |
commit | 2cb844ce9cf37fdd75438e27b515371ad1f71405 (patch) | |
tree | 8dfc1a700bed24b907d6f4da60e4d204beb6bd55 /gcc/jit/jit-playback.c | |
parent | ebc8f0bb3a8ac745dd710c7ce5cc918d998560c6 (diff) | |
download | gcc-2cb844ce9cf37fdd75438e27b515371ad1f71405.zip gcc-2cb844ce9cf37fdd75438e27b515371ad1f71405.tar.gz gcc-2cb844ce9cf37fdd75438e27b515371ad1f71405.tar.bz2 |
PR jit/64810: driver, arm, jit: configure-time default options
gcc/ChangeLog:
PR jit/64810
* Makefile.in (GCC_OBJS): Add gcc-main.o.
* gcc-main.c: New file, containing "main" taken from gcc.c.
* gcc.c (do_self_spec): Free decoded_options.
(class driver): Move declaration to gcc.h.
(main): Move declaration and implementation to new file
gcc-main.c.
(driver_get_configure_time_options): New function.
* gcc.h (class driver): Move this declaration here, from
gcc.c.
(driver_get_configure_time_options): New declaration.
gcc/jit/ChangeLog:
PR jit/64810
* Make-lang.in (jit_OBJS): Add jit/jit-spec.o and gcc.o.
(LIBGCCJIT_FILENAME): Add EXTRA_GCC_OBJS.
* jit-playback.c: Include gcc.h.
(gcc::jit::playback::context::compile): Move mutex acquisition
to before the call to make_fake_args.
(append_arg_from_driver): New function.
(gcc::jit::playback::context::make_fake_args): On the first call,
call into driver_get_configure_time_options to get configure-time
default options and cache them. Add them to the args for
toplev::main.
* jit-spec.c: New source file.
* docs/internals/test-hello-world.exe.log.txt: Update to reflect
above changes.
From-SVN: r220373
Diffstat (limited to 'gcc/jit/jit-playback.c')
-rw-r--r-- | gcc/jit/jit-playback.c | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c index d2549a0..c75c076 100644 --- a/gcc/jit/jit-playback.c +++ b/gcc/jit/jit-playback.c @@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see #include "context.h" #include "fold-const.h" #include "debug.h" +#include "gcc.h" #include "jit-common.h" #include "jit-logging.h" @@ -1714,13 +1715,16 @@ compile () auto_vec <recording::requested_dump> requested_dumps; m_recording_ctxt->get_all_requested_dumps (&requested_dumps); + /* Acquire the JIT mutex and set "this" as the active playback ctxt. */ + acquire_mutex (); + auto_argvec fake_args; make_fake_args (&fake_args, ctxt_progname, &requested_dumps); if (errors_occurred ()) - return; - - /* Acquire the JIT mutex and set "this" as the active playback ctxt. */ - acquire_mutex (); + { + release_mutex (); + return; + } /* This runs the compiler. */ toplev toplev (false, /* use_TV_TOTAL */ @@ -2034,6 +2038,19 @@ playback::context::release_mutex () pthread_mutex_unlock (&jit_mutex); } +/* Callback used by gcc::jit::playback::context::make_fake_args when + invoking driver_get_configure_time_options. + Populate a vec <char * > with the configure-time options. */ + +static void +append_arg_from_driver (const char *option, void *user_data) +{ + gcc_assert (option); + gcc_assert (user_data); + vec <char *> *argvec = static_cast <vec <char *> *> (user_data); + argvec->safe_push (concat ("-", option, NULL)); +} + /* Build a fake argv for toplev::main from the options set by the user on the context . */ @@ -2118,6 +2135,57 @@ make_fake_args (vec <char *> *argvec, } } + /* PR jit/64810: Add any target-specific default options + from OPTION_DEFAULT_SPECS, normally provided by the driver + in the non-jit case. + + The target-specific code can define OPTION_DEFAULT_SPECS: + default command options in the form of spec macros for the + driver to expand (). + + For cc1 etc, the driver processes OPTION_DEFAULT_SPECS and, + if not overriden, injects the defaults as extra arguments to + cc1 etc. + For the jit case, we need to add these arguments here. The + input format (using the specs language) means that we have to run + part of the driver code here (driver_get_configure_time_options). + + To avoid running the spec-expansion code every time, we just do + it the first time (via a function-static flag), saving the result + into a function-static vec. + This flag and vec are global state (i.e. per-process). + They are guarded by the jit mutex. */ + { + static bool have_configure_time_options = false; + static vec <char *> configure_time_options; + + if (have_configure_time_options) + log ("reusing cached configure-time options"); + else + { + have_configure_time_options = true; + log ("getting configure-time options from driver"); + driver_get_configure_time_options (append_arg_from_driver, + &configure_time_options); + } + + int i; + char *opt; + + if (get_logger ()) + FOR_EACH_VEC_ELT (configure_time_options, i, opt) + log ("configure_time_options[%i]: %s", i, opt); + + /* configure_time_options should now contain the expanded options + from OPTION_DEFAULT_SPECS (if any). */ + FOR_EACH_VEC_ELT (configure_time_options, i, opt) + { + gcc_assert (opt); + gcc_assert (opt[0] == '-'); + ADD_ARG (opt); + } + } + #undef ADD_ARG #undef ADD_ARG_TAKE_OWNERSHIP } |