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 | |
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')
-rw-r--r-- | gcc/jit/ChangeLog | 18 | ||||
-rw-r--r-- | gcc/jit/Make-lang.in | 8 | ||||
-rw-r--r-- | gcc/jit/docs/_build/texinfo/libgccjit.texi | 11 | ||||
-rw-r--r-- | gcc/jit/docs/internals/test-hello-world.exe.log.txt | 9 | ||||
-rw-r--r-- | gcc/jit/jit-playback.c | 76 | ||||
-rw-r--r-- | gcc/jit/jit-spec.c | 44 |
6 files changed, 155 insertions, 11 deletions
diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index ccbd250..e25b9de 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,21 @@ +2015-02-03 David Malcolm <dmalcolm@redhat.com> + + 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. + * docs/_build/texinfo/libgccjit.texi: Regenerate. + 2015-02-02 David Malcolm <dmalcolm@redhat.com> PR jit/64810 diff --git a/gcc/jit/Make-lang.in b/gcc/jit/Make-lang.in index e622690..44d0750 100644 --- a/gcc/jit/Make-lang.in +++ b/gcc/jit/Make-lang.in @@ -67,7 +67,9 @@ jit_OBJS = attribs.o \ jit/jit-playback.o \ jit/jit-result.o \ jit/jit-tempdir.o \ - jit/jit-builtins.o + jit/jit-builtins.o \ + jit/jit-spec.o \ + gcc.o # Use strict warnings for this front end. jit-warn = $(STRICT_WARN) @@ -77,10 +79,12 @@ jit-warn = $(STRICT_WARN) $(LIBGCCJIT_FILENAME): $(jit_OBJS) \ libbackend.a libcommon-target.a libcommon.a \ $(CPPLIB) $(LIBDECNUMBER) \ - $(LIBDEPS) $(srcdir)/jit/libgccjit.map + $(LIBDEPS) $(srcdir)/jit/libgccjit.map \ + $(EXTRA_GCC_OBJS) +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ -shared \ $(jit_OBJS) libbackend.a libcommon-target.a libcommon.a \ $(CPPLIB) $(LIBDECNUMBER) $(LIBS) $(BACKENDLIBS) \ + $(EXTRA_GCC_OBJS) \ -Wl,--version-script=$(srcdir)/jit/libgccjit.map \ -Wl,-soname,$(LIBGCCJIT_SONAME) diff --git a/gcc/jit/docs/_build/texinfo/libgccjit.texi b/gcc/jit/docs/_build/texinfo/libgccjit.texi index 37c4664..f0a34cb 100644 --- a/gcc/jit/docs/_build/texinfo/libgccjit.texi +++ b/gcc/jit/docs/_build/texinfo/libgccjit.texi @@ -19,7 +19,7 @@ @copying @quotation -libgccjit 5.0.0 (experimental 20150127), January 27, 2015 +libgccjit 5.0.0 (experimental 20150203), February 03, 2015 David Malcolm @@ -13815,10 +13815,13 @@ JIT: entering: bool gcc::jit::tempdir::create() JIT: m_path_template: /tmp/libgccjit-XXXXXX JIT: m_path_tempdir: /tmp/libgccjit-CKq1M9 JIT: exiting: bool gcc::jit::tempdir::create() -JIT: entering: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) -JIT: exiting: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) JIT: entering: void gcc::jit::playback::context::acquire_mutex() JIT: exiting: void gcc::jit::playback::context::acquire_mutex() +JIT: entering: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) +JIT: reusing cached configure-time options +JIT: configure_time_options[0]: -mtune=generic +JIT: configure_time_options[1]: -march=x86-64 +JIT: exiting: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) JIT: entering: toplev::main JIT: argv[0]: ./test-hello-world.c.exe JIT: argv[1]: /tmp/libgccjit-CKq1M9/fake.c @@ -13830,6 +13833,8 @@ JIT: argv[6]: --param JIT: argv[7]: ggc-min-expand=0 JIT: argv[8]: --param JIT: argv[9]: ggc-min-heapsize=0 +JIT: argv[10]: -mtune=generic +JIT: argv[11]: -march=x86-64 JIT: entering: bool jit_langhook_init() JIT: exiting: bool jit_langhook_init() JIT: entering: void gcc::jit::playback::context::replay() 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 876d830..a9abc10 100644 --- a/gcc/jit/docs/internals/test-hello-world.exe.log.txt +++ b/gcc/jit/docs/internals/test-hello-world.exe.log.txt @@ -60,10 +60,13 @@ JIT: entering: bool gcc::jit::tempdir::create() JIT: m_path_template: /tmp/libgccjit-XXXXXX JIT: m_path_tempdir: /tmp/libgccjit-CKq1M9 JIT: exiting: bool gcc::jit::tempdir::create() -JIT: entering: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) -JIT: exiting: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) JIT: entering: void gcc::jit::playback::context::acquire_mutex() JIT: exiting: void gcc::jit::playback::context::acquire_mutex() +JIT: entering: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) +JIT: reusing cached configure-time options +JIT: configure_time_options[0]: -mtune=generic +JIT: configure_time_options[1]: -march=x86-64 +JIT: exiting: void gcc::jit::playback::context::make_fake_args(vec<char*>*, const char*, vec<gcc::jit::recording::requested_dump>*) JIT: entering: toplev::main JIT: argv[0]: ./test-hello-world.c.exe JIT: argv[1]: /tmp/libgccjit-CKq1M9/fake.c @@ -75,6 +78,8 @@ JIT: argv[6]: --param JIT: argv[7]: ggc-min-expand=0 JIT: argv[8]: --param JIT: argv[9]: ggc-min-heapsize=0 +JIT: argv[10]: -mtune=generic +JIT: argv[11]: -march=x86-64 JIT: entering: bool jit_langhook_init() JIT: exiting: bool jit_langhook_init() JIT: entering: void gcc::jit::playback::context::replay() 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 } diff --git a/gcc/jit/jit-spec.c b/gcc/jit/jit-spec.c new file mode 100644 index 0000000..fa7e9d4 --- /dev/null +++ b/gcc/jit/jit-spec.c @@ -0,0 +1,44 @@ +/* Dummy flag and argument handling of the jit "front-end". + Copyright (C) 2015 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "gcc.h" +#include "opts.h" + +/* Filter command line before processing by the gcc driver proper. */ +void +lang_specific_driver (struct cl_decoded_option **in_decoded_options ATTRIBUTE_UNUSED, + unsigned int *in_decoded_options_count ATTRIBUTE_UNUSED, + int *in_added_libraries ATTRIBUTE_UNUSED) +{ + /* Not used for jit. */ +} + +/* Called before linking. Returns 0 on success and -1 on failure. */ +int +lang_specific_pre_link (void) +{ + return 0; /* Not used for jit. */ +} + +/* Number of extra output files that lang_specific_pre_link may generate. */ +int lang_specific_extra_outfiles = 0; /* Not used for jit. */ |