diff options
author | Ilya Verbin <ilya.verbin@intel.com> | 2014-11-13 13:47:46 +0000 |
---|---|---|
committer | Kirill Yukhin <kyukhin@gcc.gnu.org> | 2014-11-13 13:47:46 +0000 |
commit | fc8b3540d23168b5a35988b35336ba70c4174091 (patch) | |
tree | 01939e74e91ddfabc8de28a27fd8c4f87e5feb2c /lto-plugin | |
parent | ec6fe917cd323dfe1f84aebe9f3c2eda2b5cbdd1 (diff) | |
download | gcc-fc8b3540d23168b5a35988b35336ba70c4174091.zip gcc-fc8b3540d23168b5a35988b35336ba70c4174091.tar.gz gcc-fc8b3540d23168b5a35988b35336ba70c4174091.tar.bz2 |
[PATCH 4/7] OpenMP 4.0 offloading infrastructure: lto-wrapper.
gcc/
* gcc.c (spec_host_machine, accel_dir_suffix): New variables.
(process_command): Tweak path construction for the possibility
of being configured as an offload compiler.
(driver::maybe_putenv_OFFLOAD_TARGETS): New function.
(driver::main): Call maybe_putenv_OFFLOAD_TARGETS.
(driver::set_up_specs): Tweak path construction for the possibility of
being configured as an offload compiler.
* lto-wrapper.c (OFFLOAD_TARGET_NAMES_ENV): Define.
(offload_names, offloadbegin, offloadend): New static variables.
(free_array_of_ptrs, parse_env_var, access_check, compile_offload_image)
(compile_images_for_offload_targets, copy_file, find_offloadbeginend):
New static functions.
(run_gcc): Determine whether offload sections are present. If so, run
compile_images_for_offload_targets and return the names of new generated
objects to linker. If there are offload sections, but no LTO sections,
then return the copies of input objects without link-time recompilation.
lto-plugin/
* lto-plugin.c (OFFLOAD_SECTION, OFFLOAD_SECTION_LEN): Define.
(struct plugin_objfile): Add new field "offload".
(process_offload_section): New static function.
(claim_file_handler): Claim file if it contains offload sections.
Co-Authored-By: Andrey Turetskiy <andrey.turetskiy@intel.com>
Co-Authored-By: Bernd Schmidt <bernds@codesourcery.com>
Co-Authored-By: Michael Zolotukhin <michael.v.zolotukhin@intel.com>
From-SVN: r217491
Diffstat (limited to 'lto-plugin')
-rw-r--r-- | lto-plugin/ChangeLog | 10 | ||||
-rw-r--r-- | lto-plugin/lto-plugin.c | 25 |
2 files changed, 34 insertions, 1 deletions
diff --git a/lto-plugin/ChangeLog b/lto-plugin/ChangeLog index 195ab45..69af781 100644 --- a/lto-plugin/ChangeLog +++ b/lto-plugin/ChangeLog @@ -1,3 +1,13 @@ +2014-11-13 Ilya Verbin <ilya.verbin@intel.com> + Bernd Schmidt <bernds@codesourcery.com> + Andrey Turetskiy <andrey.turetskiy@intel.com> + Michael Zolotukhin <michael.v.zolotukhin@intel.com> + + * lto-plugin.c (OFFLOAD_SECTION, OFFLOAD_SECTION_LEN): Define. + (struct plugin_objfile): Add new field "offload". + (process_offload_section): New static function. + (claim_file_handler): Claim file if it contains offload sections. + 2014-11-13 Bernd Schmidt <bernds@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> Ilya Verbin <ilya.verbin@intel.com> diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c index 910e23c..fb6555d 100644 --- a/lto-plugin/lto-plugin.c +++ b/lto-plugin/lto-plugin.c @@ -86,6 +86,8 @@ along with this program; see the file COPYING3. If not see #define LTO_SECTION_PREFIX ".gnu.lto_.symtab" #define LTO_SECTION_PREFIX_LEN (sizeof (LTO_SECTION_PREFIX) - 1) +#define OFFLOAD_SECTION ".gnu.offload_lto_.opts" +#define OFFLOAD_SECTION_LEN (sizeof (OFFLOAD_SECTION) - 1) /* The part of the symbol table the plugin has to keep track of. Note that we must keep SYMS until all_symbols_read is called to give the linker time to @@ -111,6 +113,7 @@ struct plugin_symtab struct plugin_objfile { int found; + int offload; simple_object_read *objfile; struct plugin_symtab *out; const struct ld_plugin_input_file *file; @@ -862,6 +865,21 @@ err: return 0; } +/* Find an offload section of an object file. */ + +static int +process_offload_section (void *data, const char *name, off_t offset, off_t len) +{ + if (!strncmp (name, OFFLOAD_SECTION, OFFLOAD_SECTION_LEN)) + { + struct plugin_objfile *obj = (struct plugin_objfile *) data; + obj->offload = 1; + return 0; + } + + return 1; +} + /* Callback used by gold to check if the plugin will claim FILE. Writes the result in CLAIMED. */ @@ -899,6 +917,7 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) *claimed = 0; obj.file = file; obj.found = 0; + obj.offload = 0; obj.out = <o_file.symtab; errmsg = NULL; obj.objfile = simple_object_start_read (file->fd, file->offset, LTO_SEGMENT_NAME, @@ -920,7 +939,11 @@ claim_file_handler (const struct ld_plugin_input_file *file, int *claimed) goto err; } - if (obj.found == 0) + if (obj.objfile) + simple_object_find_sections (obj.objfile, process_offload_section, + &obj, &err); + + if (obj.found == 0 && obj.offload == 0) goto err; if (obj.found > 1) |