2009-10-03 23:10:11 +02:00
|
|
|
/* Wrapper to call lto. Used by collect2 and the linker plugin.
|
2015-01-05 13:33:28 +01:00
|
|
|
Copyright (C) 2009-2015 Free Software Foundation, Inc.
|
2009-10-03 23:10:11 +02:00
|
|
|
|
|
|
|
Factored out of collect2 by Rafael Espindola <espindola@google.com>
|
|
|
|
|
|
|
|
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/>. */
|
|
|
|
|
|
|
|
|
|
|
|
/* This program is passed a gcc, a list of gcc arguments and a list of
|
|
|
|
object files containing IL. It scans the argument list to check if
|
|
|
|
we are in whopr mode or not modifies the arguments and needed and
|
|
|
|
prints a list of output files on stdout.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
$ lto-wrapper gcc/xgcc -B gcc a.o b.o -o test -flto
|
|
|
|
|
|
|
|
The above will print something like
|
|
|
|
/tmp/ccwbQ8B2.lto.o
|
|
|
|
|
2010-11-11 23:54:53 +01:00
|
|
|
If WHOPR is used instead, more than one file might be produced
|
2009-10-03 23:10:11 +02:00
|
|
|
./ccXj2DTk.lto.ltrans.o
|
|
|
|
./ccCJuXGv.lto.ltrans.o
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
Makefile.in (READ_MD_H): New variable.
gcc/
* Makefile.in (READ_MD_H): New variable.
(BUILD_RTL): Add build/read-md.o.
(lto-wrapper.o): Depend on coretypes.h instead of defaults.h.
(build/gensupport.o, build/read-rtl.o, build/genattr.o)
(build/genattrtab.o, build/genconditions.o build/genemit.o)
(build/genextract.o, build/genflags.o, build/genoutput.o)
(build/genpreds.o, build/genrecog.o): Depend on $(READ_MD_H).
(build/read-md.o): New rule.
* defaults.h (obstack_chunk_alloc, obstack_chunk_free)
(OBSTACK_CHUNK_SIZE, gcc_obstack_init): Move to...
* coretypes.h: ...here.
* lto-wrapper.c: Include coretypes.h instead of defaults.h.
* pretty-print.c (obstack_chunk_alloc, obstack_chunk_free): Delete.
* genattr.c: Include read-md.h.
* genattrtab.c: Likewise.
* genconditions.c: Likewise.
* genemit.c: Likewise.
* genextract.c: Likewise.
* genflags.c: Likewise.
* genoutput.c: Likewise.
* genpreds.c: Likewise.
* genrecog.c: Likewise.
* rtl.h (read_skip_spaces, copy_rtx_ptr_loc, print_rtx_ptr_loc)
(join_c_conditions, print_c_condition, read_rtx_filename)
(read_rtx_lineno): Move to read-md.h.
* read-rtl.c: Include read-md.h.
(ptr_loc, string_obstack, ptr_locs, ptr_loc_obstack)
(joined_conditions, joined_conditions_obstack, read_rtx_lineno)
(read_rtx_filename, fatal_with_file_and_line, fatal_expected_char)
(leading_ptr_hash, leading_ptr_eq_p, set_rtx_ptr_loc, get_rtx_ptr_loc)
(copy_rtx_ptr_loc, print_rtx_ptr_loc, join_c_conditions)
(print_c_condition, read_skip_spaces, read_escape, read_quoted_string)
(read_braced_string, read_string): Move to read-md.c.
(read_rtx): Move some initialization to init_md_reader and call
init_md_reader here.
* gensupport.h (message_with_line, n_comma_elts, scan_comma_elt):
Move to read-md.h.
* gensupport.c: Include read-md.h.
(message_with_line, n_comma_elts, scan_comma_elt): Move to
read-md.c.
* read-md.h, read-md.c: New files.
From-SVN: r160570
2010-06-10 22:21:23 +02:00
|
|
|
#include "coretypes.h"
|
2009-10-03 23:10:11 +02:00
|
|
|
#include "intl.h"
|
Makefile.in (LIBDEPS): Add libcommon.a.
* Makefile.in (LIBDEPS): Add libcommon.a.
(LIBS): Likewise.
(GCC_OBJS): Remove diagnostic.o, pretty-print.o and input.o.
(OBJS-common): Remove diagnostic.o, input.o, intl.o,
pretty-print.o and version.o.
(OBJS-libcommon): New.
(ALL_HOST_BACKEND_OBJS): Add $(OBJS-libcommon).
(BACKEND): Add libcommon.a.
(MOSTLYCLEANFILES): Likewise.
(libcommon.a): New.
(xgcc$(exeext)): Don't explicitly use version.o and intl.o.
(cpp$(exeext)): Likewise.
(COLLECT2_OBJS): Remove intl.o, version.o, diagnostic.o,
pretty-print.o and input.o.
(lto-wrapper$(exeext)): Don't explicitly use intl.o.
(lto-wrapper.o): Depend on $(DIAGNOSTIC_H).
(errors.o): Remove.
(mips-tfile): Don't explicitly use version.o.
(mips-tdump): Likewise.
(gcov.o): Depend on $(DIAGNOSTIC_H).
(gcov-dump.o): Depend on intl.h and $(DIAGNOSTIC_H).
(GCOV_OBJS): Remove intl.o, version.o and errors.o.
(GCOV_DUMP_OBJS): Remove version.o and errors.o.
* gcov-dump.c: Include intl.h and diagnostic.h.
(main): Initialize diagnostics.
* gcov.c: Include diagnostic.h.
(fnotice): Remove.
(main): Initialize diagnostics.
* lto-wrapper.c: Include diagnostic.h.
(main): Initialize diagnostics.
ada:
* gcc-interface/Make-lang.in (EXTRA_GNATBIND_OBJS): Remove
version.o.
* gcc-interface/Makefile.in (EXTRA_GNATTOOLS_OBJS): Use
libcommon.a instead of version.o.
cp:
* Make-lang.in (GXX_OBJS): Remove intl.o and version.o.
fortran:
* Make-lang.in (GFORTRAN_D_OBJS): Remove version.o and intl.o.
go:
* Make-lang.in (GCCGO_OBJS): Remove intl.o and version.o.
java:
* Make-lang.in ($(XGCJ)$(exeext)): Don't explicitly use intl.o and
version.o.
(JCFDUMP_OBJS): Remove errors.o, version.o and intl.o.
(JVGENMAIN_OBJS): Remove errors.o and intl.o.
(java/jcf-dump.o, java/jvgenmain.o): Depend in $(DIAGNOSTIC_H).
* jcf-dump.c: Include diagnostic.h.
(main): Initialize diagnostics.
* jvgenmain.c: Include diagnostic.h.
(main): Initialize diagnostics.
From-SVN: r173958
2011-05-20 17:19:05 +02:00
|
|
|
#include "diagnostic.h"
|
2010-05-07 17:52:01 +02:00
|
|
|
#include "obstack.h"
|
2011-10-26 11:30:29 +02:00
|
|
|
#include "opts.h"
|
|
|
|
#include "options.h"
|
2011-11-03 15:46:26 +01:00
|
|
|
#include "simple-object.h"
|
2014-05-22 18:21:18 +02:00
|
|
|
#include "lto-section-names.h"
|
2014-06-26 11:16:11 +02:00
|
|
|
#include "collect-utils.h"
|
2009-10-03 23:10:11 +02:00
|
|
|
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
/* Environment variable, used for passing the names of offload targets from GCC
|
|
|
|
driver to lto-wrapper. */
|
|
|
|
#define OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES"
|
|
|
|
|
2009-10-03 23:10:11 +02:00
|
|
|
enum lto_mode_d {
|
2010-05-18 17:11:01 +02:00
|
|
|
LTO_MODE_NONE, /* Not doing LTO. */
|
|
|
|
LTO_MODE_LTO, /* Normal LTO. */
|
|
|
|
LTO_MODE_WHOPR /* WHOPR. */
|
2009-10-03 23:10:11 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Current LTO mode. */
|
|
|
|
static enum lto_mode_d lto_mode = LTO_MODE_NONE;
|
|
|
|
|
2009-10-09 15:24:59 +02:00
|
|
|
static char *ltrans_output_file;
|
|
|
|
static char *flto_out;
|
2010-05-25 17:47:28 +02:00
|
|
|
static unsigned int nr;
|
|
|
|
static char **input_names;
|
|
|
|
static char **output_names;
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
static char **offload_names;
|
|
|
|
static const char *offloadbegin, *offloadend;
|
2010-05-25 17:47:28 +02:00
|
|
|
static char *makefile;
|
2009-10-09 15:24:59 +02:00
|
|
|
|
2014-06-26 11:16:11 +02:00
|
|
|
const char tool_name[] = "lto-wrapper";
|
2009-10-09 15:24:59 +02:00
|
|
|
|
2014-06-26 11:16:11 +02:00
|
|
|
/* Delete tempfiles. Called from utils_cleanup. */
|
2009-10-09 15:24:59 +02:00
|
|
|
|
2014-06-26 11:16:11 +02:00
|
|
|
void
|
Part 2 of the collect-utils library, now also used for collect2.
* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
(LTO_WRAPPER_OBJS): New variable.
(lto-wrapper$(exeext)): Use it.
* collect2.c: Include "collect-utils.h".
(verbose, debug): Remove variables.
(at_file_supplied): No longer static.
(tool_name): New variable.
(do_wait, fork_execute, maybe_unlink): Don't declare.
(tool_cleanup): No longer static.
(notice): Remove function.
(maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
fork_execute calls.
(collect_wait, do_wait, collect_execute): Remove functions.
(maybe_unlink): No longer static.
* collect2.h (verbose, debug): Don't declare.
(at_file_supplied): Declare.
* collect-utils.c (utils_cleanup): New arg from_signal. All callers
changed.
(collect_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(collect_wait): Replace with implementation from collect2.
(maybe_unlink_file): Remove function.
(fork_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(do_wait): Add call to utils_cleanup to the error path.
* collect-utils.h (collect_execute, fork_execute, utils_cleanup,
tool_cleanup): Adjust declarations.
* lto-wrapper.c (tool_cleanup): Add unused bool argument.
* tlink.c: Include "collect-utils.h".
(tlink_execute): New arg use_atfile. All callers changed.
(tlink_init, tlink_execute): Remove declarations.
From-SVN: r212020
2014-06-26 11:16:28 +02:00
|
|
|
tool_cleanup (bool)
|
2009-10-09 15:24:59 +02:00
|
|
|
{
|
2010-06-02 15:58:27 +02:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (ltrans_output_file)
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (ltrans_output_file);
|
2010-06-02 15:58:27 +02:00
|
|
|
if (flto_out)
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (flto_out);
|
2010-06-02 15:58:27 +02:00
|
|
|
if (makefile)
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (makefile);
|
2010-06-02 15:58:27 +02:00
|
|
|
for (i = 0; i < nr; ++i)
|
2009-11-24 16:00:15 +01:00
|
|
|
{
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (input_names[i]);
|
2010-06-02 15:58:27 +02:00
|
|
|
if (output_names[i])
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (output_names[i]);
|
2009-11-24 16:00:15 +01:00
|
|
|
}
|
2010-06-02 15:58:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-26 11:16:11 +02:00
|
|
|
lto_wrapper_cleanup (void)
|
2009-10-03 23:10:11 +02:00
|
|
|
{
|
Part 2 of the collect-utils library, now also used for collect2.
* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
(LTO_WRAPPER_OBJS): New variable.
(lto-wrapper$(exeext)): Use it.
* collect2.c: Include "collect-utils.h".
(verbose, debug): Remove variables.
(at_file_supplied): No longer static.
(tool_name): New variable.
(do_wait, fork_execute, maybe_unlink): Don't declare.
(tool_cleanup): No longer static.
(notice): Remove function.
(maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
fork_execute calls.
(collect_wait, do_wait, collect_execute): Remove functions.
(maybe_unlink): No longer static.
* collect2.h (verbose, debug): Don't declare.
(at_file_supplied): Declare.
* collect-utils.c (utils_cleanup): New arg from_signal. All callers
changed.
(collect_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(collect_wait): Replace with implementation from collect2.
(maybe_unlink_file): Remove function.
(fork_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(do_wait): Add call to utils_cleanup to the error path.
* collect-utils.h (collect_execute, fork_execute, utils_cleanup,
tool_cleanup): Adjust declarations.
* lto-wrapper.c (tool_cleanup): Add unused bool argument.
* tlink.c: Include "collect-utils.h".
(tlink_execute): New arg use_atfile. All callers changed.
(tlink_init, tlink_execute): Remove declarations.
From-SVN: r212020
2014-06-26 11:16:28 +02:00
|
|
|
utils_cleanup (false);
|
2009-10-03 23:10:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Unlink a temporary LTRANS file unless requested otherwise. */
|
|
|
|
|
2014-06-26 11:16:11 +02:00
|
|
|
void
|
|
|
|
maybe_unlink (const char *file)
|
2009-10-03 23:10:11 +02:00
|
|
|
{
|
2014-06-26 11:16:19 +02:00
|
|
|
if (!save_temps)
|
2009-10-03 23:10:11 +02:00
|
|
|
{
|
2010-05-27 12:33:08 +02:00
|
|
|
if (unlink_if_ordinary (file)
|
|
|
|
&& errno != ENOENT)
|
2014-06-04 20:23:30 +02:00
|
|
|
fatal_error ("deleting LTRANS file %s: %m", file);
|
2009-10-03 23:10:11 +02:00
|
|
|
}
|
2014-03-13 10:50:26 +01:00
|
|
|
else if (verbose)
|
2009-10-03 23:10:11 +02:00
|
|
|
fprintf (stderr, "[Leaving LTRANS %s]\n", file);
|
|
|
|
}
|
|
|
|
|
2010-05-07 17:52:01 +02:00
|
|
|
/* Template of LTRANS dumpbase suffix. */
|
|
|
|
#define DUMPBASE_SUFFIX ".ltrans18446744073709551615"
|
2009-10-03 23:10:11 +02:00
|
|
|
|
2011-10-26 11:30:29 +02:00
|
|
|
/* Create decoded options from the COLLECT_GCC and COLLECT_GCC_OPTIONS
|
|
|
|
environment according to LANG_MASK. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
get_options_from_collect_gcc_options (const char *collect_gcc,
|
|
|
|
const char *collect_gcc_options,
|
|
|
|
unsigned int lang_mask,
|
|
|
|
struct cl_decoded_option **decoded_options,
|
|
|
|
unsigned int *decoded_options_count)
|
|
|
|
{
|
2011-11-03 14:13:33 +01:00
|
|
|
struct obstack argv_obstack;
|
2011-10-26 11:30:29 +02:00
|
|
|
char *argv_storage;
|
|
|
|
const char **argv;
|
2011-11-03 14:13:33 +01:00
|
|
|
int j, k, argc;
|
|
|
|
|
2011-10-26 11:30:29 +02:00
|
|
|
argv_storage = xstrdup (collect_gcc_options);
|
2011-11-03 14:13:33 +01:00
|
|
|
obstack_init (&argv_obstack);
|
|
|
|
obstack_ptr_grow (&argv_obstack, collect_gcc);
|
|
|
|
|
|
|
|
for (j = 0, k = 0; argv_storage[j] != '\0'; ++j)
|
2011-10-26 11:30:29 +02:00
|
|
|
{
|
|
|
|
if (argv_storage[j] == '\'')
|
|
|
|
{
|
2011-11-03 14:13:33 +01:00
|
|
|
obstack_ptr_grow (&argv_obstack, &argv_storage[k]);
|
|
|
|
++j;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (argv_storage[j] == '\0')
|
2014-06-04 20:23:30 +02:00
|
|
|
fatal_error ("malformed COLLECT_GCC_OPTIONS");
|
2011-11-03 14:13:33 +01:00
|
|
|
else if (strncmp (&argv_storage[j], "'\\''", 4) == 0)
|
|
|
|
{
|
|
|
|
argv_storage[k++] = '\'';
|
|
|
|
j += 4;
|
|
|
|
}
|
|
|
|
else if (argv_storage[j] == '\'')
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
argv_storage[k++] = argv_storage[j++];
|
|
|
|
}
|
|
|
|
while (1);
|
|
|
|
argv_storage[k++] = '\0';
|
2011-10-26 11:30:29 +02:00
|
|
|
}
|
|
|
|
}
|
2011-11-03 14:13:33 +01:00
|
|
|
|
|
|
|
obstack_ptr_grow (&argv_obstack, NULL);
|
|
|
|
argc = obstack_object_size (&argv_obstack) / sizeof (void *) - 1;
|
|
|
|
argv = XOBFINISH (&argv_obstack, const char **);
|
2011-10-26 11:30:29 +02:00
|
|
|
|
|
|
|
decode_cmdline_options_to_array (argc, (const char **)argv,
|
|
|
|
lang_mask,
|
|
|
|
decoded_options, decoded_options_count);
|
2011-11-03 14:13:33 +01:00
|
|
|
obstack_free (&argv_obstack, NULL);
|
2011-10-26 11:30:29 +02:00
|
|
|
}
|
|
|
|
|
2011-11-03 15:46:26 +01:00
|
|
|
/* Append OPTION to the options array DECODED_OPTIONS with size
|
|
|
|
DECODED_OPTIONS_COUNT. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
append_option (struct cl_decoded_option **decoded_options,
|
|
|
|
unsigned int *decoded_options_count,
|
|
|
|
struct cl_decoded_option *option)
|
|
|
|
{
|
|
|
|
++*decoded_options_count;
|
|
|
|
*decoded_options
|
|
|
|
= (struct cl_decoded_option *)
|
|
|
|
xrealloc (*decoded_options,
|
|
|
|
(*decoded_options_count
|
|
|
|
* sizeof (struct cl_decoded_option)));
|
|
|
|
memcpy (&(*decoded_options)[*decoded_options_count - 1], option,
|
|
|
|
sizeof (struct cl_decoded_option));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Try to merge and complain about options FDECODED_OPTIONS when applied
|
|
|
|
ontop of DECODED_OPTIONS. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
merge_and_complain (struct cl_decoded_option **decoded_options,
|
|
|
|
unsigned int *decoded_options_count,
|
|
|
|
struct cl_decoded_option *fdecoded_options,
|
|
|
|
unsigned int fdecoded_options_count)
|
|
|
|
{
|
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
/* ??? Merge options from files. Most cases can be
|
|
|
|
handled by either unioning or intersecting
|
|
|
|
(for example -fwrapv is a case for unioning,
|
|
|
|
-ffast-math is for intersection). Most complaints
|
|
|
|
about real conflicts between different options can
|
|
|
|
be deferred to the compiler proper. Options that
|
|
|
|
we can neither safely handle by intersection nor
|
|
|
|
unioning would need to be complained about here.
|
|
|
|
Ideally we'd have a flag in the opt files that
|
|
|
|
tells whether to union or intersect or reject.
|
|
|
|
In absence of that it's unclear what a good default is.
|
|
|
|
It's also difficult to get positional handling correct. */
|
|
|
|
|
|
|
|
/* The following does what the old LTO option code did,
|
|
|
|
union all target and a selected set of common options. */
|
|
|
|
for (i = 0; i < fdecoded_options_count; ++i)
|
|
|
|
{
|
|
|
|
struct cl_decoded_option *foption = &fdecoded_options[i];
|
|
|
|
switch (foption->opt_index)
|
|
|
|
{
|
2012-11-27 14:56:31 +01:00
|
|
|
case OPT_SPECIAL_unknown:
|
|
|
|
case OPT_SPECIAL_ignore:
|
|
|
|
case OPT_SPECIAL_program_name:
|
|
|
|
case OPT_SPECIAL_input_file:
|
|
|
|
break;
|
|
|
|
|
2011-11-03 15:46:26 +01:00
|
|
|
default:
|
|
|
|
if (!(cl_options[foption->opt_index].flags & CL_TARGET))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Fallthru. */
|
|
|
|
case OPT_fPIC:
|
|
|
|
case OPT_fpic:
|
2014-03-25 11:10:31 +01:00
|
|
|
case OPT_fPIE:
|
2011-11-03 15:46:26 +01:00
|
|
|
case OPT_fpie:
|
|
|
|
case OPT_fcommon:
|
|
|
|
case OPT_fexceptions:
|
2013-11-04 21:29:36 +01:00
|
|
|
case OPT_fnon_call_exceptions:
|
2012-01-19 14:57:04 +01:00
|
|
|
case OPT_fgnu_tm:
|
2011-11-03 15:46:26 +01:00
|
|
|
/* Do what the old LTO code did - collect exactly one option
|
|
|
|
setting per OPT code, we pick the first we encounter.
|
|
|
|
??? This doesn't make too much sense, but when it doesn't
|
|
|
|
then we should complain. */
|
|
|
|
for (j = 0; j < *decoded_options_count; ++j)
|
|
|
|
if ((*decoded_options)[j].opt_index == foption->opt_index)
|
|
|
|
break;
|
|
|
|
if (j == *decoded_options_count)
|
|
|
|
append_option (decoded_options, decoded_options_count, foption);
|
|
|
|
break;
|
2012-05-04 13:47:06 +02:00
|
|
|
|
2014-02-25 09:57:42 +01:00
|
|
|
case OPT_ftrapv:
|
|
|
|
case OPT_fstrict_overflow:
|
2013-11-20 11:31:24 +01:00
|
|
|
case OPT_ffp_contract_:
|
|
|
|
/* For selected options we can merge conservatively. */
|
|
|
|
for (j = 0; j < *decoded_options_count; ++j)
|
|
|
|
if ((*decoded_options)[j].opt_index == foption->opt_index)
|
|
|
|
break;
|
|
|
|
if (j == *decoded_options_count)
|
|
|
|
append_option (decoded_options, decoded_options_count, foption);
|
2014-02-25 09:57:42 +01:00
|
|
|
/* FP_CONTRACT_OFF < FP_CONTRACT_ON < FP_CONTRACT_FAST,
|
|
|
|
-fno-trapv < -ftrapv,
|
|
|
|
-fno-strict-overflow < -fstrict-overflow */
|
2013-11-20 11:31:24 +01:00
|
|
|
else if (foption->value < (*decoded_options)[j].value)
|
|
|
|
(*decoded_options)[j] = *foption;
|
|
|
|
break;
|
|
|
|
|
2014-10-07 09:56:43 +02:00
|
|
|
case OPT_fmath_errno:
|
|
|
|
case OPT_fsigned_zeros:
|
|
|
|
case OPT_ftrapping_math:
|
2014-02-25 09:57:42 +01:00
|
|
|
case OPT_fwrapv:
|
|
|
|
/* For selected options we can merge conservatively. */
|
|
|
|
for (j = 0; j < *decoded_options_count; ++j)
|
|
|
|
if ((*decoded_options)[j].opt_index == foption->opt_index)
|
|
|
|
break;
|
|
|
|
if (j == *decoded_options_count)
|
|
|
|
append_option (decoded_options, decoded_options_count, foption);
|
2014-10-07 09:56:43 +02:00
|
|
|
/* -fmath-errno > -fno-math-errno,
|
|
|
|
-fsigned-zeros > -fno-signed-zeros,
|
|
|
|
-ftrapping-math -> -fno-trapping-math,
|
|
|
|
-fwrapv > -fno-wrapv. */
|
2014-02-25 09:57:42 +01:00
|
|
|
else if (foption->value > (*decoded_options)[j].value)
|
|
|
|
(*decoded_options)[j] = *foption;
|
|
|
|
break;
|
|
|
|
|
2012-05-04 13:47:06 +02:00
|
|
|
case OPT_freg_struct_return:
|
|
|
|
case OPT_fpcc_struct_return:
|
2014-03-08 11:54:05 +01:00
|
|
|
case OPT_fshort_double:
|
2012-05-04 13:47:06 +02:00
|
|
|
for (j = 0; j < *decoded_options_count; ++j)
|
|
|
|
if ((*decoded_options)[j].opt_index == foption->opt_index)
|
|
|
|
break;
|
|
|
|
if (j == *decoded_options_count)
|
2014-06-04 20:23:30 +02:00
|
|
|
fatal_error ("Option %s not used consistently in all LTO input"
|
|
|
|
" files", foption->orig_option_with_args_text);
|
2012-05-04 13:47:06 +02:00
|
|
|
break;
|
2014-03-06 09:48:01 +01:00
|
|
|
|
2014-11-13 14:54:07 +01:00
|
|
|
case OPT_foffload_abi_:
|
|
|
|
for (j = 0; j < *decoded_options_count; ++j)
|
|
|
|
if ((*decoded_options)[j].opt_index == foption->opt_index)
|
|
|
|
break;
|
|
|
|
if (j == *decoded_options_count)
|
|
|
|
append_option (decoded_options, decoded_options_count, foption);
|
|
|
|
else if (foption->value != (*decoded_options)[j].value)
|
|
|
|
fatal_error ("Option %s not used consistently in all LTO input"
|
|
|
|
" files", foption->orig_option_with_args_text);
|
|
|
|
break;
|
|
|
|
|
2014-03-06 09:48:01 +01:00
|
|
|
case OPT_O:
|
|
|
|
case OPT_Ofast:
|
|
|
|
case OPT_Og:
|
|
|
|
case OPT_Os:
|
|
|
|
for (j = 0; j < *decoded_options_count; ++j)
|
|
|
|
if ((*decoded_options)[j].opt_index == OPT_O
|
|
|
|
|| (*decoded_options)[j].opt_index == OPT_Ofast
|
|
|
|
|| (*decoded_options)[j].opt_index == OPT_Og
|
|
|
|
|| (*decoded_options)[j].opt_index == OPT_Os)
|
|
|
|
break;
|
|
|
|
if (j == *decoded_options_count)
|
|
|
|
append_option (decoded_options, decoded_options_count, foption);
|
|
|
|
else if ((*decoded_options)[j].opt_index == foption->opt_index
|
|
|
|
&& foption->opt_index != OPT_O)
|
|
|
|
/* Exact same options get merged. */
|
|
|
|
;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* For mismatched option kinds preserve the optimization
|
|
|
|
level only, thus merge it as -On. This also handles
|
|
|
|
merging of same optimization level -On. */
|
|
|
|
int level = 0;
|
|
|
|
switch (foption->opt_index)
|
|
|
|
{
|
|
|
|
case OPT_O:
|
|
|
|
if (foption->arg[0] == '\0')
|
|
|
|
level = MAX (level, 1);
|
|
|
|
else
|
|
|
|
level = MAX (level, atoi (foption->arg));
|
|
|
|
break;
|
|
|
|
case OPT_Ofast:
|
|
|
|
level = MAX (level, 3);
|
|
|
|
break;
|
|
|
|
case OPT_Og:
|
|
|
|
level = MAX (level, 1);
|
|
|
|
break;
|
|
|
|
case OPT_Os:
|
|
|
|
level = MAX (level, 2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gcc_unreachable ();
|
|
|
|
}
|
|
|
|
switch ((*decoded_options)[j].opt_index)
|
|
|
|
{
|
|
|
|
case OPT_O:
|
|
|
|
if ((*decoded_options)[j].arg[0] == '\0')
|
|
|
|
level = MAX (level, 1);
|
|
|
|
else
|
|
|
|
level = MAX (level, atoi ((*decoded_options)[j].arg));
|
|
|
|
break;
|
|
|
|
case OPT_Ofast:
|
|
|
|
level = MAX (level, 3);
|
|
|
|
break;
|
|
|
|
case OPT_Og:
|
|
|
|
level = MAX (level, 1);
|
|
|
|
break;
|
|
|
|
case OPT_Os:
|
|
|
|
level = MAX (level, 2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
gcc_unreachable ();
|
|
|
|
}
|
|
|
|
(*decoded_options)[j].opt_index = OPT_O;
|
|
|
|
char *tem;
|
2014-12-31 11:38:33 +01:00
|
|
|
tem = xasprintf ("-O%d", level);
|
2014-03-06 09:48:01 +01:00
|
|
|
(*decoded_options)[j].arg = &tem[2];
|
|
|
|
(*decoded_options)[j].canonical_option[0] = tem;
|
|
|
|
(*decoded_options)[j].value = 1;
|
|
|
|
}
|
|
|
|
break;
|
2014-11-13 14:54:07 +01:00
|
|
|
|
|
|
|
case OPT_foffload_:
|
|
|
|
append_option (decoded_options, decoded_options_count, foption);
|
|
|
|
break;
|
2011-11-03 15:46:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-26 11:30:29 +02:00
|
|
|
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
/* Auxiliary function that frees elements of PTR and PTR itself.
|
|
|
|
N is number of elements to be freed. If PTR is NULL, nothing is freed.
|
|
|
|
If an element is NULL, subsequent elements are not freed. */
|
|
|
|
|
|
|
|
static void **
|
|
|
|
free_array_of_ptrs (void **ptr, unsigned n)
|
|
|
|
{
|
|
|
|
if (!ptr)
|
|
|
|
return NULL;
|
|
|
|
for (unsigned i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
if (!ptr[i])
|
|
|
|
break;
|
|
|
|
free (ptr[i]);
|
|
|
|
}
|
|
|
|
free (ptr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse STR, saving found tokens into PVALUES and return their number.
|
|
|
|
Tokens are assumed to be delimited by ':'. If APPEND is non-null,
|
|
|
|
append it to every token we find. */
|
|
|
|
|
|
|
|
static unsigned
|
|
|
|
parse_env_var (const char *str, char ***pvalues, const char *append)
|
|
|
|
{
|
|
|
|
const char *curval, *nextval;
|
|
|
|
char **values;
|
|
|
|
unsigned num = 1, i;
|
|
|
|
|
|
|
|
curval = strchr (str, ':');
|
|
|
|
while (curval)
|
|
|
|
{
|
|
|
|
num++;
|
|
|
|
curval = strchr (curval + 1, ':');
|
|
|
|
}
|
|
|
|
|
|
|
|
values = (char**) xmalloc (num * sizeof (char*));
|
|
|
|
curval = str;
|
2014-11-13 23:06:15 +01:00
|
|
|
nextval = strchr (curval, ':');
|
|
|
|
if (nextval == NULL)
|
|
|
|
nextval = strchr (curval, '\0');
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
|
|
|
|
int append_len = append ? strlen (append) : 0;
|
|
|
|
for (i = 0; i < num; i++)
|
|
|
|
{
|
|
|
|
int l = nextval - curval;
|
|
|
|
values[i] = (char*) xmalloc (l + 1 + append_len);
|
|
|
|
memcpy (values[i], curval, l);
|
|
|
|
values[i][l] = 0;
|
|
|
|
if (append)
|
|
|
|
strcat (values[i], append);
|
|
|
|
curval = nextval + 1;
|
2014-11-13 23:06:15 +01:00
|
|
|
nextval = strchr (curval, ':');
|
|
|
|
if (nextval == NULL)
|
|
|
|
nextval = strchr (curval, '\0');
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
}
|
|
|
|
*pvalues = values;
|
|
|
|
return num;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:54:07 +01:00
|
|
|
/* Append options OPTS from lto or offload_lto sections to ARGV_OBSTACK. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
append_compiler_options (obstack *argv_obstack, struct cl_decoded_option *opts,
|
|
|
|
unsigned int count)
|
|
|
|
{
|
|
|
|
/* Append compiler driver arguments as far as they were merged. */
|
|
|
|
for (unsigned int j = 1; j < count; ++j)
|
|
|
|
{
|
|
|
|
struct cl_decoded_option *option = &opts[j];
|
|
|
|
|
|
|
|
/* File options have been properly filtered by lto-opts.c. */
|
|
|
|
switch (option->opt_index)
|
|
|
|
{
|
|
|
|
/* Drop arguments that we want to take from the link line. */
|
|
|
|
case OPT_flto_:
|
|
|
|
case OPT_flto:
|
|
|
|
case OPT_flto_partition_:
|
|
|
|
continue;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* For now do what the original LTO option code was doing - pass
|
|
|
|
on any CL_TARGET flag and a few selected others. */
|
|
|
|
switch (option->opt_index)
|
|
|
|
{
|
|
|
|
case OPT_fPIC:
|
|
|
|
case OPT_fpic:
|
|
|
|
case OPT_fPIE:
|
|
|
|
case OPT_fpie:
|
|
|
|
case OPT_fcommon:
|
|
|
|
case OPT_fexceptions:
|
|
|
|
case OPT_fnon_call_exceptions:
|
|
|
|
case OPT_fgnu_tm:
|
|
|
|
case OPT_freg_struct_return:
|
|
|
|
case OPT_fpcc_struct_return:
|
|
|
|
case OPT_fshort_double:
|
|
|
|
case OPT_ffp_contract_:
|
|
|
|
case OPT_fmath_errno:
|
|
|
|
case OPT_fsigned_zeros:
|
|
|
|
case OPT_ftrapping_math:
|
|
|
|
case OPT_fwrapv:
|
|
|
|
case OPT_ftrapv:
|
|
|
|
case OPT_fstrict_overflow:
|
|
|
|
case OPT_foffload_abi_:
|
|
|
|
case OPT_O:
|
|
|
|
case OPT_Ofast:
|
|
|
|
case OPT_Og:
|
|
|
|
case OPT_Os:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (!(cl_options[option->opt_index].flags & CL_TARGET))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pass the option on. */
|
|
|
|
for (unsigned int i = 0; i < option->canonical_option_num_elements; ++i)
|
|
|
|
obstack_ptr_grow (argv_obstack, option->canonical_option[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append linker options OPTS to ARGV_OBSTACK. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
append_linker_options (obstack *argv_obstack, struct cl_decoded_option *opts,
|
|
|
|
unsigned int count)
|
|
|
|
{
|
|
|
|
/* Append linker driver arguments. Compiler options from the linker
|
|
|
|
driver arguments will override / merge with those from the compiler. */
|
|
|
|
for (unsigned int j = 1; j < count; ++j)
|
|
|
|
{
|
|
|
|
struct cl_decoded_option *option = &opts[j];
|
|
|
|
|
|
|
|
/* Do not pass on frontend specific flags not suitable for lto. */
|
|
|
|
if (!(cl_options[option->opt_index].flags
|
|
|
|
& (CL_COMMON|CL_TARGET|CL_DRIVER|CL_LTO)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (option->opt_index)
|
|
|
|
{
|
|
|
|
case OPT_o:
|
|
|
|
case OPT_flto_:
|
|
|
|
case OPT_flto:
|
|
|
|
/* We've handled these LTO options, do not pass them on. */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
case OPT_freg_struct_return:
|
|
|
|
case OPT_fpcc_struct_return:
|
|
|
|
case OPT_fshort_double:
|
|
|
|
/* Ignore these, they are determined by the input files.
|
|
|
|
??? We fail to diagnose a possible mismatch here. */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Pass the option on. */
|
|
|
|
for (unsigned int i = 0; i < option->canonical_option_num_elements; ++i)
|
|
|
|
obstack_ptr_grow (argv_obstack, option->canonical_option[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Extract options for TARGET offload compiler from OPTIONS and append
|
|
|
|
them to ARGV_OBSTACK. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
append_offload_options (obstack *argv_obstack, const char *target,
|
|
|
|
struct cl_decoded_option *options,
|
|
|
|
unsigned int options_count)
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < options_count; i++)
|
|
|
|
{
|
|
|
|
const char *cur, *next, *opts;
|
|
|
|
char **argv;
|
|
|
|
unsigned argc;
|
|
|
|
struct cl_decoded_option *option = &options[i];
|
|
|
|
|
|
|
|
if (option->opt_index != OPT_foffload_)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* If option argument starts with '-' then no target is specified. That
|
|
|
|
means offload options are specified for all targets, so we need to
|
|
|
|
append them. */
|
|
|
|
if (option->arg[0] == '-')
|
|
|
|
opts = option->arg;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
opts = strchr (option->arg, '=');
|
|
|
|
if (!opts)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cur = option->arg;
|
|
|
|
|
|
|
|
while (cur < opts)
|
|
|
|
{
|
2014-11-13 23:06:15 +01:00
|
|
|
next = strchr (cur, ',');
|
|
|
|
if (next == NULL)
|
2014-11-25 14:56:03 +01:00
|
|
|
next = opts;
|
2014-11-13 14:54:07 +01:00
|
|
|
next = (next > opts) ? opts : next;
|
|
|
|
|
|
|
|
if (strlen (target) == (size_t) (next - cur)
|
|
|
|
&& strncmp (target, cur, next - cur) == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
cur = next + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur >= opts)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
opts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
argv = buildargv (opts);
|
|
|
|
for (argc = 0; argv[argc]; argc++)
|
|
|
|
obstack_ptr_grow (argv_obstack, argv[argc]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
/* Check whether NAME can be accessed in MODE. This is like access,
|
|
|
|
except that it never considers directories to be executable. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
access_check (const char *name, int mode)
|
|
|
|
{
|
|
|
|
if (mode == X_OK)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
if (stat (name, &st) < 0
|
|
|
|
|| S_ISDIR (st.st_mode))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return access (name, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Prepare a target image for offload TARGET, using mkoffload tool from
|
|
|
|
COMPILER_PATH. Return the name of the resultant object file. */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
compile_offload_image (const char *target, const char *compiler_path,
|
2014-11-13 14:54:07 +01:00
|
|
|
unsigned in_argc, char *in_argv[],
|
|
|
|
struct cl_decoded_option *compiler_opts,
|
|
|
|
unsigned int compiler_opt_count,
|
|
|
|
struct cl_decoded_option *linker_opts,
|
|
|
|
unsigned int linker_opt_count)
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
{
|
|
|
|
char *filename = NULL;
|
|
|
|
char **argv;
|
|
|
|
char *suffix
|
|
|
|
= XALLOCAVEC (char, sizeof ("/accel//mkoffload") + strlen (target));
|
|
|
|
strcpy (suffix, "/accel/");
|
|
|
|
strcat (suffix, target);
|
|
|
|
strcat (suffix, "/mkoffload");
|
|
|
|
|
|
|
|
char **paths = NULL;
|
|
|
|
unsigned n_paths = parse_env_var (compiler_path, &paths, suffix);
|
|
|
|
|
|
|
|
const char *compiler = NULL;
|
|
|
|
for (unsigned i = 0; i < n_paths; i++)
|
|
|
|
if (access_check (paths[i], X_OK) == 0)
|
|
|
|
{
|
|
|
|
compiler = paths[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (compiler)
|
|
|
|
{
|
|
|
|
/* Generate temporary output file name. */
|
|
|
|
filename = make_temp_file (".target.o");
|
|
|
|
|
|
|
|
struct obstack argv_obstack;
|
|
|
|
obstack_init (&argv_obstack);
|
|
|
|
obstack_ptr_grow (&argv_obstack, compiler);
|
|
|
|
obstack_ptr_grow (&argv_obstack, "-o");
|
|
|
|
obstack_ptr_grow (&argv_obstack, filename);
|
|
|
|
|
2014-11-13 14:54:07 +01:00
|
|
|
/* Append names of input object files. */
|
2014-12-09 23:44:16 +01:00
|
|
|
for (unsigned i = 0; i < in_argc; i++)
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
obstack_ptr_grow (&argv_obstack, in_argv[i]);
|
|
|
|
|
2014-11-13 14:54:07 +01:00
|
|
|
/* Append options from offload_lto sections. */
|
|
|
|
append_compiler_options (&argv_obstack, compiler_opts,
|
|
|
|
compiler_opt_count);
|
|
|
|
|
|
|
|
/* Append options specified by -foffload last. In case of conflicting
|
|
|
|
options we expect offload compiler to choose the latest. */
|
|
|
|
append_offload_options (&argv_obstack, target, compiler_opts,
|
|
|
|
compiler_opt_count);
|
|
|
|
append_offload_options (&argv_obstack, target, linker_opts,
|
|
|
|
linker_opt_count);
|
|
|
|
|
|
|
|
obstack_ptr_grow (&argv_obstack, NULL);
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
argv = XOBFINISH (&argv_obstack, char **);
|
|
|
|
fork_execute (argv[0], argv, true);
|
|
|
|
obstack_free (&argv_obstack, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
free_array_of_ptrs ((void **) paths, n_paths);
|
|
|
|
return filename;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* The main routine dealing with offloading.
|
|
|
|
The routine builds a target image for each offload target. IN_ARGC and
|
|
|
|
IN_ARGV specify options and input object files. As all of them could contain
|
|
|
|
target sections, we pass them all to target compilers. */
|
|
|
|
|
|
|
|
static void
|
2014-11-13 14:54:07 +01:00
|
|
|
compile_images_for_offload_targets (unsigned in_argc, char *in_argv[],
|
|
|
|
struct cl_decoded_option *compiler_opts,
|
|
|
|
unsigned int compiler_opt_count,
|
|
|
|
struct cl_decoded_option *linker_opts,
|
|
|
|
unsigned int linker_opt_count)
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
{
|
|
|
|
char **names = NULL;
|
|
|
|
const char *target_names = getenv (OFFLOAD_TARGET_NAMES_ENV);
|
|
|
|
if (!target_names)
|
|
|
|
return;
|
|
|
|
unsigned num_targets = parse_env_var (target_names, &names, NULL);
|
|
|
|
|
|
|
|
const char *compiler_path = getenv ("COMPILER_PATH");
|
|
|
|
if (!compiler_path)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
/* Prepare an image for each target and save the name of the resultant object
|
|
|
|
file to the OFFLOAD_NAMES array. It is terminated by a NULL entry. */
|
|
|
|
offload_names = XCNEWVEC (char *, num_targets + 1);
|
|
|
|
for (unsigned i = 0; i < num_targets; i++)
|
|
|
|
{
|
2014-11-13 14:54:07 +01:00
|
|
|
offload_names[i]
|
|
|
|
= compile_offload_image (names[i], compiler_path, in_argc, in_argv,
|
|
|
|
compiler_opts, compiler_opt_count,
|
|
|
|
linker_opts, linker_opt_count);
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
if (!offload_names[i])
|
|
|
|
fatal_error ("problem with building target image for %s\n", names[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
free_array_of_ptrs ((void **) names, num_targets);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy a file from SRC to DEST. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
copy_file (const char *dest, const char *src)
|
|
|
|
{
|
|
|
|
FILE *d = fopen (dest, "wb");
|
|
|
|
FILE *s = fopen (src, "rb");
|
|
|
|
char buffer[512];
|
|
|
|
while (!feof (s))
|
|
|
|
{
|
|
|
|
size_t len = fread (buffer, 1, 512, s);
|
|
|
|
if (ferror (s) != 0)
|
|
|
|
fatal_error ("reading input file");
|
|
|
|
if (len > 0)
|
|
|
|
{
|
|
|
|
fwrite (buffer, 1, len, d);
|
|
|
|
if (ferror (d) != 0)
|
|
|
|
fatal_error ("writing output file");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find the crtoffloadbegin.o and crtoffloadend.o files in LIBRARY_PATH, make
|
|
|
|
copies and store the names of the copies in offloadbegin and offloadend. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
find_offloadbeginend (void)
|
|
|
|
{
|
|
|
|
char **paths = NULL;
|
|
|
|
const char *library_path = getenv ("LIBRARY_PATH");
|
|
|
|
if (!library_path)
|
|
|
|
return;
|
|
|
|
unsigned n_paths = parse_env_var (library_path, &paths, "/crtoffloadbegin.o");
|
|
|
|
|
|
|
|
unsigned i;
|
|
|
|
for (i = 0; i < n_paths; i++)
|
|
|
|
if (access_check (paths[i], R_OK) == 0)
|
|
|
|
{
|
|
|
|
size_t len = strlen (paths[i]);
|
|
|
|
char *tmp = xstrdup (paths[i]);
|
|
|
|
strcpy (paths[i] + len - strlen ("begin.o"), "end.o");
|
|
|
|
if (access_check (paths[i], R_OK) != 0)
|
|
|
|
fatal_error ("installation error, can't find crtoffloadend.o");
|
|
|
|
/* The linker will delete the filenames we give it, so make
|
|
|
|
copies. */
|
|
|
|
offloadbegin = make_temp_file (".o");
|
|
|
|
offloadend = make_temp_file (".o");
|
|
|
|
copy_file (offloadbegin, tmp);
|
|
|
|
copy_file (offloadend, paths[i]);
|
|
|
|
free (tmp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == n_paths)
|
|
|
|
fatal_error ("installation error, can't find crtoffloadbegin.o");
|
|
|
|
|
|
|
|
free_array_of_ptrs ((void **) paths, n_paths);
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:54:07 +01:00
|
|
|
/* A subroutine of run_gcc. Examine the open file FD for lto sections with
|
|
|
|
name prefix PREFIX, at FILE_OFFSET, and store any options we find in OPTS
|
|
|
|
and OPT_COUNT. Return true if we found a matchingn section, false
|
|
|
|
otherwise. COLLECT_GCC holds the value of the environment variable with
|
|
|
|
the same name. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
find_and_merge_options (int fd, off_t file_offset, const char *prefix,
|
|
|
|
struct cl_decoded_option **opts,
|
|
|
|
unsigned int *opt_count, const char *collect_gcc)
|
|
|
|
{
|
|
|
|
off_t offset, length;
|
|
|
|
char *data;
|
|
|
|
char *fopts;
|
|
|
|
const char *errmsg;
|
|
|
|
int err;
|
|
|
|
struct cl_decoded_option *fdecoded_options = *opts;
|
|
|
|
unsigned int fdecoded_options_count = *opt_count;
|
|
|
|
|
|
|
|
simple_object_read *sobj;
|
|
|
|
sobj = simple_object_start_read (fd, file_offset, "__GNU_LTO",
|
|
|
|
&errmsg, &err);
|
|
|
|
if (!sobj)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
char *secname = XALLOCAVEC (char, strlen (prefix) + sizeof (".opts"));
|
|
|
|
strcpy (secname, prefix);
|
|
|
|
strcat (secname, ".opts");
|
|
|
|
if (!simple_object_find_section (sobj, secname, &offset, &length,
|
|
|
|
&errmsg, &err))
|
|
|
|
{
|
|
|
|
simple_object_release_read (sobj);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
lseek (fd, file_offset + offset, SEEK_SET);
|
|
|
|
data = (char *)xmalloc (length);
|
|
|
|
read (fd, data, length);
|
|
|
|
fopts = data;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
struct cl_decoded_option *f2decoded_options;
|
|
|
|
unsigned int f2decoded_options_count;
|
|
|
|
get_options_from_collect_gcc_options (collect_gcc,
|
|
|
|
fopts, CL_LANG_ALL,
|
|
|
|
&f2decoded_options,
|
|
|
|
&f2decoded_options_count);
|
|
|
|
if (!fdecoded_options)
|
|
|
|
{
|
|
|
|
fdecoded_options = f2decoded_options;
|
|
|
|
fdecoded_options_count = f2decoded_options_count;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
merge_and_complain (&fdecoded_options,
|
|
|
|
&fdecoded_options_count,
|
|
|
|
f2decoded_options, f2decoded_options_count);
|
|
|
|
|
|
|
|
fopts += strlen (fopts) + 1;
|
|
|
|
}
|
|
|
|
while (fopts - data < length);
|
|
|
|
|
|
|
|
free (data);
|
|
|
|
simple_object_release_read (sobj);
|
|
|
|
*opts = fdecoded_options;
|
|
|
|
*opt_count = fdecoded_options_count;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-03 23:10:11 +02:00
|
|
|
/* Execute gcc. ARGC is the number of arguments. ARGV contains the arguments. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
run_gcc (unsigned argc, char *argv[])
|
|
|
|
{
|
2010-05-18 17:11:01 +02:00
|
|
|
unsigned i, j;
|
2009-10-03 23:10:11 +02:00
|
|
|
const char **new_argv;
|
|
|
|
const char **argv_ptr;
|
|
|
|
char *list_option_full = NULL;
|
2010-05-18 17:11:01 +02:00
|
|
|
const char *linker_output = NULL;
|
2011-10-26 11:30:29 +02:00
|
|
|
const char *collect_gcc, *collect_gcc_options;
|
2010-05-19 17:43:22 +02:00
|
|
|
int parallel = 0;
|
2010-08-31 18:58:46 +02:00
|
|
|
int jobserver = 0;
|
2010-11-11 23:54:53 +01:00
|
|
|
bool no_partition = false;
|
2011-11-03 15:46:26 +01:00
|
|
|
struct cl_decoded_option *fdecoded_options = NULL;
|
2014-11-13 14:54:07 +01:00
|
|
|
struct cl_decoded_option *offload_fdecoded_options = NULL;
|
2011-11-03 15:46:26 +01:00
|
|
|
unsigned int fdecoded_options_count = 0;
|
2014-11-13 14:54:07 +01:00
|
|
|
unsigned int offload_fdecoded_options_count = 0;
|
2011-10-26 11:30:29 +02:00
|
|
|
struct cl_decoded_option *decoded_options;
|
|
|
|
unsigned int decoded_options_count;
|
2011-10-28 11:46:26 +02:00
|
|
|
struct obstack argv_obstack;
|
|
|
|
int new_head_argc;
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
bool have_lto = false;
|
|
|
|
bool have_offload = false;
|
2014-12-09 23:44:16 +01:00
|
|
|
unsigned lto_argc = 0, offload_argc = 0;
|
|
|
|
char **lto_argv, **offload_argv;
|
2010-05-18 17:11:01 +02:00
|
|
|
|
|
|
|
/* Get the driver and options. */
|
|
|
|
collect_gcc = getenv ("COLLECT_GCC");
|
|
|
|
if (!collect_gcc)
|
2014-06-04 20:23:30 +02:00
|
|
|
fatal_error ("environment variable COLLECT_GCC must be set");
|
2010-05-18 17:11:01 +02:00
|
|
|
collect_gcc_options = getenv ("COLLECT_GCC_OPTIONS");
|
|
|
|
if (!collect_gcc_options)
|
2014-06-04 20:23:30 +02:00
|
|
|
fatal_error ("environment variable COLLECT_GCC_OPTIONS must be set");
|
2011-10-26 11:30:29 +02:00
|
|
|
get_options_from_collect_gcc_options (collect_gcc, collect_gcc_options,
|
|
|
|
CL_LANG_ALL,
|
|
|
|
&decoded_options,
|
|
|
|
&decoded_options_count);
|
2010-05-18 17:11:01 +02:00
|
|
|
|
2014-12-09 23:44:16 +01:00
|
|
|
/* Allocate arrays for input object files with LTO or offload IL,
|
|
|
|
and for possible preceding arguments. */
|
|
|
|
lto_argv = XNEWVEC (char *, argc);
|
|
|
|
offload_argv = XNEWVEC (char *, argc);
|
|
|
|
|
2011-11-03 15:46:26 +01:00
|
|
|
/* Look at saved options in the IL files. */
|
|
|
|
for (i = 1; i < argc; ++i)
|
|
|
|
{
|
2014-11-13 14:54:07 +01:00
|
|
|
char *p;
|
2011-11-03 15:46:26 +01:00
|
|
|
int fd;
|
2014-11-13 14:54:07 +01:00
|
|
|
off_t file_offset = 0;
|
2011-11-03 15:46:26 +01:00
|
|
|
long loffset;
|
|
|
|
int consumed;
|
|
|
|
char *filename = argv[i];
|
2014-11-13 14:54:07 +01:00
|
|
|
|
2011-11-03 15:46:26 +01:00
|
|
|
if ((p = strrchr (argv[i], '@'))
|
|
|
|
&& p != argv[i]
|
|
|
|
&& sscanf (p, "@%li%n", &loffset, &consumed) >= 1
|
|
|
|
&& strlen (p) == (unsigned int) consumed)
|
|
|
|
{
|
|
|
|
filename = XNEWVEC (char, p - argv[i] + 1);
|
|
|
|
memcpy (filename, argv[i], p - argv[i]);
|
|
|
|
filename[p - argv[i]] = '\0';
|
|
|
|
file_offset = (off_t) loffset;
|
|
|
|
}
|
|
|
|
fd = open (argv[i], O_RDONLY);
|
|
|
|
if (fd == -1)
|
2014-12-09 23:44:16 +01:00
|
|
|
{
|
|
|
|
lto_argv[lto_argc++] = argv[i];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (find_and_merge_options (fd, file_offset, LTO_SECTION_NAME_PREFIX,
|
|
|
|
&fdecoded_options, &fdecoded_options_count,
|
|
|
|
collect_gcc))
|
|
|
|
{
|
|
|
|
have_lto = true;
|
|
|
|
lto_argv[lto_argc++] = argv[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (find_and_merge_options (fd, file_offset, OFFLOAD_SECTION_NAME_PREFIX,
|
|
|
|
&offload_fdecoded_options,
|
|
|
|
&offload_fdecoded_options_count, collect_gcc))
|
|
|
|
{
|
|
|
|
have_offload = true;
|
|
|
|
offload_argv[offload_argc++] = argv[i];
|
|
|
|
}
|
2011-11-03 15:46:26 +01:00
|
|
|
|
|
|
|
close (fd);
|
|
|
|
}
|
|
|
|
|
2010-05-18 17:11:01 +02:00
|
|
|
/* Initalize the common arguments for the driver. */
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_init (&argv_obstack);
|
|
|
|
obstack_ptr_grow (&argv_obstack, collect_gcc);
|
|
|
|
obstack_ptr_grow (&argv_obstack, "-xlto");
|
|
|
|
obstack_ptr_grow (&argv_obstack, "-c");
|
2011-11-03 15:46:26 +01:00
|
|
|
|
2014-11-13 14:54:07 +01:00
|
|
|
append_compiler_options (&argv_obstack, fdecoded_options,
|
|
|
|
fdecoded_options_count);
|
|
|
|
append_linker_options (&argv_obstack, decoded_options, decoded_options_count);
|
2011-11-03 15:46:26 +01:00
|
|
|
|
2014-11-13 14:54:07 +01:00
|
|
|
/* Scan linker driver arguments for things that are of relevance to us. */
|
2011-10-26 11:30:29 +02:00
|
|
|
for (j = 1; j < decoded_options_count; ++j)
|
|
|
|
{
|
|
|
|
struct cl_decoded_option *option = &decoded_options[j];
|
|
|
|
switch (option->opt_index)
|
|
|
|
{
|
|
|
|
case OPT_o:
|
|
|
|
linker_output = option->arg;
|
2014-11-13 14:54:07 +01:00
|
|
|
break;
|
2011-10-26 11:30:29 +02:00
|
|
|
|
|
|
|
case OPT_save_temps:
|
2014-06-26 11:16:19 +02:00
|
|
|
save_temps = 1;
|
2011-10-26 11:30:29 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OPT_v:
|
2010-05-18 17:11:01 +02:00
|
|
|
verbose = 1;
|
2011-10-26 11:30:29 +02:00
|
|
|
break;
|
2010-05-18 17:11:01 +02:00
|
|
|
|
2014-04-15 14:56:16 +02:00
|
|
|
case OPT_flto_partition_:
|
|
|
|
if (strcmp (option->arg, "none") == 0)
|
|
|
|
no_partition = true;
|
2011-10-26 11:30:29 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case OPT_flto_:
|
|
|
|
if (strcmp (option->arg, "jobserver") == 0)
|
|
|
|
{
|
|
|
|
jobserver = 1;
|
|
|
|
parallel = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
parallel = atoi (option->arg);
|
|
|
|
if (parallel <= 1)
|
|
|
|
parallel = 0;
|
|
|
|
}
|
|
|
|
/* Fallthru. */
|
|
|
|
|
|
|
|
case OPT_flto:
|
|
|
|
lto_mode = LTO_MODE_WHOPR;
|
2014-11-13 14:54:07 +01:00
|
|
|
break;
|
2012-05-04 13:47:06 +02:00
|
|
|
|
2011-10-26 11:30:29 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-11-11 23:54:53 +01:00
|
|
|
if (no_partition)
|
|
|
|
{
|
|
|
|
lto_mode = LTO_MODE_LTO;
|
|
|
|
jobserver = 0;
|
|
|
|
parallel = 0;
|
|
|
|
}
|
2010-05-18 17:11:01 +02:00
|
|
|
|
|
|
|
if (linker_output)
|
|
|
|
{
|
|
|
|
char *output_dir, *base, *name;
|
2011-02-01 15:42:08 +01:00
|
|
|
bool bit_bucket = strcmp (linker_output, HOST_BIT_BUCKET) == 0;
|
2009-10-03 23:10:11 +02:00
|
|
|
|
2010-05-18 17:11:01 +02:00
|
|
|
output_dir = xstrdup (linker_output);
|
|
|
|
base = output_dir;
|
|
|
|
for (name = base; *name; name++)
|
|
|
|
if (IS_DIR_SEPARATOR (*name))
|
|
|
|
base = name + 1;
|
|
|
|
*base = '\0';
|
|
|
|
|
|
|
|
linker_output = &linker_output[base - output_dir];
|
|
|
|
if (*output_dir == '\0')
|
|
|
|
{
|
|
|
|
static char current_dir[] = { '.', DIR_SEPARATOR, '\0' };
|
|
|
|
output_dir = current_dir;
|
|
|
|
}
|
2011-02-01 15:42:08 +01:00
|
|
|
if (!bit_bucket)
|
|
|
|
{
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_ptr_grow (&argv_obstack, "-dumpdir");
|
|
|
|
obstack_ptr_grow (&argv_obstack, output_dir);
|
2011-02-01 15:42:08 +01:00
|
|
|
}
|
2010-05-18 17:11:01 +02:00
|
|
|
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_ptr_grow (&argv_obstack, "-dumpbase");
|
2010-05-18 17:11:01 +02:00
|
|
|
}
|
2011-10-28 11:46:26 +02:00
|
|
|
|
|
|
|
/* Remember at which point we can scrub args to re-use the commons. */
|
|
|
|
new_head_argc = obstack_object_size (&argv_obstack) / sizeof (void *);
|
2009-10-03 23:10:11 +02:00
|
|
|
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
if (have_offload)
|
|
|
|
{
|
2014-12-09 23:44:16 +01:00
|
|
|
compile_images_for_offload_targets (offload_argc, offload_argv,
|
|
|
|
offload_fdecoded_options,
|
2014-11-13 14:54:07 +01:00
|
|
|
offload_fdecoded_options_count,
|
|
|
|
decoded_options,
|
|
|
|
decoded_options_count);
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
if (offload_names)
|
|
|
|
{
|
|
|
|
find_offloadbeginend ();
|
|
|
|
for (i = 0; offload_names[i]; i++)
|
|
|
|
printf ("%s\n", offload_names[i]);
|
|
|
|
free_array_of_ptrs ((void **) offload_names, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (offloadbegin)
|
|
|
|
printf ("%s\n", offloadbegin);
|
|
|
|
|
|
|
|
/* If object files contain offload sections, but do not contain LTO sections,
|
|
|
|
then there is no need to perform a link-time recompilation, i.e.
|
|
|
|
lto-wrapper is used only for a compilation of offload images. */
|
|
|
|
if (have_offload && !have_lto)
|
|
|
|
{
|
|
|
|
for (i = 1; i < argc; ++i)
|
|
|
|
if (strncmp (argv[i], "-fresolution=", sizeof ("-fresolution=") - 1))
|
|
|
|
{
|
|
|
|
char *out_file;
|
|
|
|
/* Can be ".o" or ".so". */
|
|
|
|
char *ext = strrchr (argv[i], '.');
|
|
|
|
if (ext == NULL)
|
|
|
|
out_file = make_temp_file ("");
|
|
|
|
else
|
|
|
|
out_file = make_temp_file (ext);
|
|
|
|
/* The linker will delete the files we give it, so make copies. */
|
|
|
|
copy_file (out_file, argv[i]);
|
|
|
|
printf ("%s\n", out_file);
|
|
|
|
}
|
|
|
|
goto finish;
|
|
|
|
}
|
|
|
|
|
2009-10-03 23:10:11 +02:00
|
|
|
if (lto_mode == LTO_MODE_LTO)
|
|
|
|
{
|
|
|
|
flto_out = make_temp_file (".lto.o");
|
2010-05-18 17:11:01 +02:00
|
|
|
if (linker_output)
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_ptr_grow (&argv_obstack, linker_output);
|
|
|
|
obstack_ptr_grow (&argv_obstack, "-o");
|
|
|
|
obstack_ptr_grow (&argv_obstack, flto_out);
|
2009-10-03 23:10:11 +02:00
|
|
|
}
|
2011-01-05 17:07:09 +01:00
|
|
|
else
|
2009-10-03 23:10:11 +02:00
|
|
|
{
|
|
|
|
const char *list_option = "-fltrans-output-list=";
|
|
|
|
size_t list_option_len = strlen (list_option);
|
|
|
|
char *tmp;
|
|
|
|
|
2010-05-18 17:11:01 +02:00
|
|
|
if (linker_output)
|
|
|
|
{
|
|
|
|
char *dumpbase = (char *) xmalloc (strlen (linker_output)
|
2010-05-28 14:48:54 +02:00
|
|
|
+ sizeof (".wpa") + 1);
|
2010-05-18 17:11:01 +02:00
|
|
|
strcpy (dumpbase, linker_output);
|
|
|
|
strcat (dumpbase, ".wpa");
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_ptr_grow (&argv_obstack, dumpbase);
|
2010-05-18 17:11:01 +02:00
|
|
|
}
|
|
|
|
|
2014-06-26 11:16:19 +02:00
|
|
|
if (linker_output && save_temps)
|
2010-05-28 14:48:54 +02:00
|
|
|
{
|
|
|
|
ltrans_output_file = (char *) xmalloc (strlen (linker_output)
|
|
|
|
+ sizeof (".ltrans.out") + 1);
|
|
|
|
strcpy (ltrans_output_file, linker_output);
|
|
|
|
strcat (ltrans_output_file, ".ltrans.out");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ltrans_output_file = make_temp_file (".ltrans.out");
|
2009-10-03 23:10:11 +02:00
|
|
|
list_option_full = (char *) xmalloc (sizeof (char) *
|
|
|
|
(strlen (ltrans_output_file) + list_option_len + 1));
|
|
|
|
tmp = list_option_full;
|
|
|
|
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_ptr_grow (&argv_obstack, tmp);
|
2009-10-03 23:10:11 +02:00
|
|
|
strcpy (tmp, list_option);
|
|
|
|
tmp += list_option_len;
|
|
|
|
strcpy (tmp, ltrans_output_file);
|
|
|
|
|
2014-02-05 18:21:07 +01:00
|
|
|
if (jobserver)
|
|
|
|
obstack_ptr_grow (&argv_obstack, xstrdup ("-fwpa=jobserver"));
|
|
|
|
else if (parallel > 1)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
sprintf (buf, "-fwpa=%i", parallel);
|
|
|
|
obstack_ptr_grow (&argv_obstack, xstrdup (buf));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
obstack_ptr_grow (&argv_obstack, "-fwpa");
|
2009-10-03 23:10:11 +02:00
|
|
|
}
|
|
|
|
|
2012-05-29 16:14:06 +02:00
|
|
|
/* Append the input objects and possible preceding arguments. */
|
2014-12-09 23:44:16 +01:00
|
|
|
for (i = 0; i < lto_argc; ++i)
|
|
|
|
obstack_ptr_grow (&argv_obstack, lto_argv[i]);
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_ptr_grow (&argv_obstack, NULL);
|
2009-10-03 23:10:11 +02:00
|
|
|
|
2011-10-28 11:46:26 +02:00
|
|
|
new_argv = XOBFINISH (&argv_obstack, const char **);
|
|
|
|
argv_ptr = &new_argv[new_head_argc];
|
Part 2 of the collect-utils library, now also used for collect2.
* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
(LTO_WRAPPER_OBJS): New variable.
(lto-wrapper$(exeext)): Use it.
* collect2.c: Include "collect-utils.h".
(verbose, debug): Remove variables.
(at_file_supplied): No longer static.
(tool_name): New variable.
(do_wait, fork_execute, maybe_unlink): Don't declare.
(tool_cleanup): No longer static.
(notice): Remove function.
(maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
fork_execute calls.
(collect_wait, do_wait, collect_execute): Remove functions.
(maybe_unlink): No longer static.
* collect2.h (verbose, debug): Don't declare.
(at_file_supplied): Declare.
* collect-utils.c (utils_cleanup): New arg from_signal. All callers
changed.
(collect_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(collect_wait): Replace with implementation from collect2.
(maybe_unlink_file): Remove function.
(fork_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(do_wait): Add call to utils_cleanup to the error path.
* collect-utils.h (collect_execute, fork_execute, utils_cleanup,
tool_cleanup): Adjust declarations.
* lto-wrapper.c (tool_cleanup): Add unused bool argument.
* tlink.c: Include "collect-utils.h".
(tlink_execute): New arg use_atfile. All callers changed.
(tlink_init, tlink_execute): Remove declarations.
From-SVN: r212020
2014-06-26 11:16:28 +02:00
|
|
|
fork_execute (new_argv[0], CONST_CAST (char **, new_argv), true);
|
2010-05-07 17:52:01 +02:00
|
|
|
|
2009-10-03 23:10:11 +02:00
|
|
|
if (lto_mode == LTO_MODE_LTO)
|
|
|
|
{
|
alloc-pool.c, [...]: Add missing whitespace before "(".
gcc/
* alloc-pool.c, asan.c, auto-inc-dec.c, basic-block.h, bb-reorder.c,
bitmap.c, bitmap.h, bt-load.c, builtins.c, calls.c, cfgcleanup.c,
cfgexpand.c, cfghooks.c, cfgloop.c, cfgloopmanip.c, cfgrtl.c, cgraph.c,
cgraph.h, cgraphbuild.c, cgraphclones.c, cgraphunit.c, collect2.c,
combine-stack-adj.c, combine.c, compare-elim.c, context.c, context.h,
cprop.c, cse.c, cselib.c, dbxout.c, dce.c, defaults.h, df-core.c,
df-problems.c, df-scan.c, df.h, diagnostic.c, double-int.c, dse.c,
dumpfile.c, dwarf2asm.c, dwarf2cfi.c, dwarf2out.c, emit-rtl.c,
errors.c, except.c, expmed.c, expr.c, file-find.c, final.c,
fixed-value.c, fold-const.c, function.c, fwprop.c, gcc-ar.c, gcc.c,
gcov-io.c, gcov-io.h, gcov.c, gcse.c, genattr-common.c, genattr.c,
genattrtab.c, genautomata.c, genconfig.c, genemit.c, genextract.c,
genflags.c, gengenrtl.c, gengtype-state.c, gengtype.c, genmodes.c,
genopinit.c, genoutput.c, genpeep.c, genpreds.c, genrecog.c,
gensupport.c, ggc-common.c, ggc-page.c, gimple-fold.c, gimple-low.c,
gimple-pretty-print.c, gimple-ssa-strength-reduction.c, gimple.c,
gimple.h, godump.c, graphite-clast-to-gimple.c,
graphite-optimize-isl.c, graphite-poly.h, graphite-sese-to-poly.c,
graphite.c, haifa-sched.c, hash-table.c, hash-table.h, hwint.c,
hwint.h, ifcvt.c, incpath.c, init-regs.c, input.h, intl.c, intl.h,
ipa-cp.c, ipa-devirt.c, ipa-inline-analysis.c, ipa-inline.c,
ipa-profile.c, ipa-pure-const.c, ipa-reference.c, ipa-split.c,
ipa-utils.c, ipa.c, ira-build.c, ira.c, jump.c, loop-doloop.c,
loop-init.c, loop-invariant.c, loop-iv.c, lower-subreg.c, lto-cgraph.c,
lto-streamer-in.c, lto-streamer-out.c, lto-wrapper.c, mcf.c,
mode-switching.c, modulo-sched.c, omp-low.c, optabs.c, opts.c,
pass_manager.h, passes.c, plugin.c, postreload-gcse.c, postreload.c,
predict.c, prefix.c, pretty-print.c, print-rtl.c, print-tree.c,
profile.c, read-md.c, real.c, real.h, recog.c, ree.c, reg-stack.c,
regcprop.c, reginfo.c, regmove.c, regrename.c, regs.h, regstat.c,
reload1.c, reorg.c, rtl.c, rtl.h, rtlanal.c, sbitmap.c, sched-rgn.c,
sdbout.c, sel-sched-ir.c, sel-sched.c, sparseset.c, stack-ptr-mod.c,
statistics.c, stmt.c, stor-layout.c, store-motion.c, streamer-hooks.h,
system.h, target-hooks-macros.h, targhooks.c, targhooks.h, toplev.c,
tracer.c, trans-mem.c, tree-browser.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-data-ref.c, tree-data-ref.h,
tree-eh.c, tree-emutls.c, tree-flow.h, tree-if-conv.c, tree-into-ssa.c,
tree-iterator.c, tree-loop-distribution.c, tree-mudflap.c,
tree-nested.c, tree-nomudflap.c, tree-nrv.c, tree-object-size.c,
tree-optimize.c, tree-pass.h, tree-pretty-print.c, tree-profile.c,
tree-scalar-evolution.c, tree-sra.c, tree-ssa-ccp.c,
tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-copyrename.c,
tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-live.c, tree-ssa-loop-ch.c,
tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop.c, tree-ssa-math-opts.c, tree-ssa-operands.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-threadedge.c, tree-ssa-threadupdate.c,
tree-ssa-uncprop.c, tree-ssa-uninit.c, tree-ssa.c, tree-ssanames.c,
tree-stdarg.c, tree-switch-conversion.c, tree-tailcall.c,
tree-vect-data-refs.c, tree-vect-generic.c, tree-vect-loop-manip.c,
tree-vect-stmts.c, tree-vectorizer.c, tree-vectorizer.h, tree-vrp.c,
tree.c, tree.h, tsan.c, tsystem.h, value-prof.c, var-tracking.c,
varasm.c, vec.h, vmsdbgout.c, vtable-verify.c, web.c: Add missing
whitespace before "(".
From-SVN: r203004
2013-09-28 10:42:34 +02:00
|
|
|
printf ("%s\n", flto_out);
|
2009-10-03 23:10:11 +02:00
|
|
|
free (flto_out);
|
|
|
|
flto_out = NULL;
|
|
|
|
}
|
2011-01-05 17:07:09 +01:00
|
|
|
else
|
2009-10-03 23:10:11 +02:00
|
|
|
{
|
|
|
|
FILE *stream = fopen (ltrans_output_file, "r");
|
2010-05-19 17:43:22 +02:00
|
|
|
FILE *mstream = NULL;
|
2011-10-26 13:48:09 +02:00
|
|
|
struct obstack env_obstack;
|
2009-10-03 23:10:11 +02:00
|
|
|
|
|
|
|
if (!stream)
|
2014-06-04 20:23:30 +02:00
|
|
|
fatal_error ("fopen: %s: %m", ltrans_output_file);
|
2009-10-03 23:10:11 +02:00
|
|
|
|
2010-05-25 17:47:28 +02:00
|
|
|
/* Parse the list of LTRANS inputs from the WPA stage. */
|
2011-10-26 13:48:09 +02:00
|
|
|
obstack_init (&env_obstack);
|
2010-05-25 17:47:28 +02:00
|
|
|
nr = 0;
|
2010-05-07 17:52:01 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
const unsigned piece = 32;
|
2010-05-25 17:47:28 +02:00
|
|
|
char *output_name = NULL;
|
2010-05-07 17:52:01 +02:00
|
|
|
char *buf, *input_name = (char *)xmalloc (piece);
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
buf = input_name;
|
|
|
|
cont:
|
|
|
|
if (!fgets (buf, piece, stream))
|
|
|
|
break;
|
|
|
|
len = strlen (input_name);
|
|
|
|
if (input_name[len - 1] != '\n')
|
|
|
|
{
|
|
|
|
input_name = (char *)xrealloc (input_name, len + piece);
|
|
|
|
buf = input_name + len;
|
|
|
|
goto cont;
|
|
|
|
}
|
|
|
|
input_name[len - 1] = '\0';
|
|
|
|
|
|
|
|
if (input_name[0] == '*')
|
2010-05-19 17:43:22 +02:00
|
|
|
output_name = &input_name[1];
|
2010-05-07 17:52:01 +02:00
|
|
|
|
2010-05-19 17:43:22 +02:00
|
|
|
nr++;
|
|
|
|
input_names = (char **)xrealloc (input_names, nr * sizeof (char *));
|
|
|
|
output_names = (char **)xrealloc (output_names, nr * sizeof (char *));
|
|
|
|
input_names[nr-1] = input_name;
|
|
|
|
output_names[nr-1] = output_name;
|
|
|
|
}
|
2010-05-25 17:47:28 +02:00
|
|
|
fclose (stream);
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (ltrans_output_file);
|
2010-05-25 17:47:28 +02:00
|
|
|
ltrans_output_file = NULL;
|
|
|
|
|
|
|
|
if (parallel)
|
|
|
|
{
|
|
|
|
makefile = make_temp_file (".mk");
|
|
|
|
mstream = fopen (makefile, "w");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Execute the LTRANS stage for each input file (or prepare a
|
|
|
|
makefile to invoke this in parallel). */
|
|
|
|
for (i = 0; i < nr; ++i)
|
|
|
|
{
|
|
|
|
char *output_name;
|
|
|
|
char *input_name = input_names[i];
|
|
|
|
/* If it's a pass-through file do nothing. */
|
|
|
|
if (output_names[i])
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Replace the .o suffix with a .ltrans.o suffix and write
|
|
|
|
the resulting name to the LTRANS output list. */
|
|
|
|
obstack_grow (&env_obstack, input_name, strlen (input_name) - 2);
|
|
|
|
obstack_grow (&env_obstack, ".ltrans.o", sizeof (".ltrans.o"));
|
|
|
|
output_name = XOBFINISH (&env_obstack, char *);
|
|
|
|
|
|
|
|
/* Adjust the dumpbase if the linker output file was seen. */
|
|
|
|
if (linker_output)
|
|
|
|
{
|
|
|
|
char *dumpbase
|
|
|
|
= (char *) xmalloc (strlen (linker_output)
|
alloc-pool.c, [...]: Add missing whitespace before "(".
gcc/
* alloc-pool.c, asan.c, auto-inc-dec.c, basic-block.h, bb-reorder.c,
bitmap.c, bitmap.h, bt-load.c, builtins.c, calls.c, cfgcleanup.c,
cfgexpand.c, cfghooks.c, cfgloop.c, cfgloopmanip.c, cfgrtl.c, cgraph.c,
cgraph.h, cgraphbuild.c, cgraphclones.c, cgraphunit.c, collect2.c,
combine-stack-adj.c, combine.c, compare-elim.c, context.c, context.h,
cprop.c, cse.c, cselib.c, dbxout.c, dce.c, defaults.h, df-core.c,
df-problems.c, df-scan.c, df.h, diagnostic.c, double-int.c, dse.c,
dumpfile.c, dwarf2asm.c, dwarf2cfi.c, dwarf2out.c, emit-rtl.c,
errors.c, except.c, expmed.c, expr.c, file-find.c, final.c,
fixed-value.c, fold-const.c, function.c, fwprop.c, gcc-ar.c, gcc.c,
gcov-io.c, gcov-io.h, gcov.c, gcse.c, genattr-common.c, genattr.c,
genattrtab.c, genautomata.c, genconfig.c, genemit.c, genextract.c,
genflags.c, gengenrtl.c, gengtype-state.c, gengtype.c, genmodes.c,
genopinit.c, genoutput.c, genpeep.c, genpreds.c, genrecog.c,
gensupport.c, ggc-common.c, ggc-page.c, gimple-fold.c, gimple-low.c,
gimple-pretty-print.c, gimple-ssa-strength-reduction.c, gimple.c,
gimple.h, godump.c, graphite-clast-to-gimple.c,
graphite-optimize-isl.c, graphite-poly.h, graphite-sese-to-poly.c,
graphite.c, haifa-sched.c, hash-table.c, hash-table.h, hwint.c,
hwint.h, ifcvt.c, incpath.c, init-regs.c, input.h, intl.c, intl.h,
ipa-cp.c, ipa-devirt.c, ipa-inline-analysis.c, ipa-inline.c,
ipa-profile.c, ipa-pure-const.c, ipa-reference.c, ipa-split.c,
ipa-utils.c, ipa.c, ira-build.c, ira.c, jump.c, loop-doloop.c,
loop-init.c, loop-invariant.c, loop-iv.c, lower-subreg.c, lto-cgraph.c,
lto-streamer-in.c, lto-streamer-out.c, lto-wrapper.c, mcf.c,
mode-switching.c, modulo-sched.c, omp-low.c, optabs.c, opts.c,
pass_manager.h, passes.c, plugin.c, postreload-gcse.c, postreload.c,
predict.c, prefix.c, pretty-print.c, print-rtl.c, print-tree.c,
profile.c, read-md.c, real.c, real.h, recog.c, ree.c, reg-stack.c,
regcprop.c, reginfo.c, regmove.c, regrename.c, regs.h, regstat.c,
reload1.c, reorg.c, rtl.c, rtl.h, rtlanal.c, sbitmap.c, sched-rgn.c,
sdbout.c, sel-sched-ir.c, sel-sched.c, sparseset.c, stack-ptr-mod.c,
statistics.c, stmt.c, stor-layout.c, store-motion.c, streamer-hooks.h,
system.h, target-hooks-macros.h, targhooks.c, targhooks.h, toplev.c,
tracer.c, trans-mem.c, tree-browser.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-data-ref.c, tree-data-ref.h,
tree-eh.c, tree-emutls.c, tree-flow.h, tree-if-conv.c, tree-into-ssa.c,
tree-iterator.c, tree-loop-distribution.c, tree-mudflap.c,
tree-nested.c, tree-nomudflap.c, tree-nrv.c, tree-object-size.c,
tree-optimize.c, tree-pass.h, tree-pretty-print.c, tree-profile.c,
tree-scalar-evolution.c, tree-sra.c, tree-ssa-ccp.c,
tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-copyrename.c,
tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-live.c, tree-ssa-loop-ch.c,
tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop.c, tree-ssa-math-opts.c, tree-ssa-operands.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-threadedge.c, tree-ssa-threadupdate.c,
tree-ssa-uncprop.c, tree-ssa-uninit.c, tree-ssa.c, tree-ssanames.c,
tree-stdarg.c, tree-switch-conversion.c, tree-tailcall.c,
tree-vect-data-refs.c, tree-vect-generic.c, tree-vect-loop-manip.c,
tree-vect-stmts.c, tree-vectorizer.c, tree-vectorizer.h, tree-vrp.c,
tree.c, tree.h, tsan.c, tsystem.h, value-prof.c, var-tracking.c,
varasm.c, vec.h, vmsdbgout.c, vtable-verify.c, web.c: Add missing
whitespace before "(".
From-SVN: r203004
2013-09-28 10:42:34 +02:00
|
|
|
+ sizeof (DUMPBASE_SUFFIX) + 1);
|
2010-05-25 17:47:28 +02:00
|
|
|
snprintf (dumpbase,
|
alloc-pool.c, [...]: Add missing whitespace before "(".
gcc/
* alloc-pool.c, asan.c, auto-inc-dec.c, basic-block.h, bb-reorder.c,
bitmap.c, bitmap.h, bt-load.c, builtins.c, calls.c, cfgcleanup.c,
cfgexpand.c, cfghooks.c, cfgloop.c, cfgloopmanip.c, cfgrtl.c, cgraph.c,
cgraph.h, cgraphbuild.c, cgraphclones.c, cgraphunit.c, collect2.c,
combine-stack-adj.c, combine.c, compare-elim.c, context.c, context.h,
cprop.c, cse.c, cselib.c, dbxout.c, dce.c, defaults.h, df-core.c,
df-problems.c, df-scan.c, df.h, diagnostic.c, double-int.c, dse.c,
dumpfile.c, dwarf2asm.c, dwarf2cfi.c, dwarf2out.c, emit-rtl.c,
errors.c, except.c, expmed.c, expr.c, file-find.c, final.c,
fixed-value.c, fold-const.c, function.c, fwprop.c, gcc-ar.c, gcc.c,
gcov-io.c, gcov-io.h, gcov.c, gcse.c, genattr-common.c, genattr.c,
genattrtab.c, genautomata.c, genconfig.c, genemit.c, genextract.c,
genflags.c, gengenrtl.c, gengtype-state.c, gengtype.c, genmodes.c,
genopinit.c, genoutput.c, genpeep.c, genpreds.c, genrecog.c,
gensupport.c, ggc-common.c, ggc-page.c, gimple-fold.c, gimple-low.c,
gimple-pretty-print.c, gimple-ssa-strength-reduction.c, gimple.c,
gimple.h, godump.c, graphite-clast-to-gimple.c,
graphite-optimize-isl.c, graphite-poly.h, graphite-sese-to-poly.c,
graphite.c, haifa-sched.c, hash-table.c, hash-table.h, hwint.c,
hwint.h, ifcvt.c, incpath.c, init-regs.c, input.h, intl.c, intl.h,
ipa-cp.c, ipa-devirt.c, ipa-inline-analysis.c, ipa-inline.c,
ipa-profile.c, ipa-pure-const.c, ipa-reference.c, ipa-split.c,
ipa-utils.c, ipa.c, ira-build.c, ira.c, jump.c, loop-doloop.c,
loop-init.c, loop-invariant.c, loop-iv.c, lower-subreg.c, lto-cgraph.c,
lto-streamer-in.c, lto-streamer-out.c, lto-wrapper.c, mcf.c,
mode-switching.c, modulo-sched.c, omp-low.c, optabs.c, opts.c,
pass_manager.h, passes.c, plugin.c, postreload-gcse.c, postreload.c,
predict.c, prefix.c, pretty-print.c, print-rtl.c, print-tree.c,
profile.c, read-md.c, real.c, real.h, recog.c, ree.c, reg-stack.c,
regcprop.c, reginfo.c, regmove.c, regrename.c, regs.h, regstat.c,
reload1.c, reorg.c, rtl.c, rtl.h, rtlanal.c, sbitmap.c, sched-rgn.c,
sdbout.c, sel-sched-ir.c, sel-sched.c, sparseset.c, stack-ptr-mod.c,
statistics.c, stmt.c, stor-layout.c, store-motion.c, streamer-hooks.h,
system.h, target-hooks-macros.h, targhooks.c, targhooks.h, toplev.c,
tracer.c, trans-mem.c, tree-browser.c, tree-call-cdce.c, tree-cfg.c,
tree-cfgcleanup.c, tree-complex.c, tree-data-ref.c, tree-data-ref.h,
tree-eh.c, tree-emutls.c, tree-flow.h, tree-if-conv.c, tree-into-ssa.c,
tree-iterator.c, tree-loop-distribution.c, tree-mudflap.c,
tree-nested.c, tree-nomudflap.c, tree-nrv.c, tree-object-size.c,
tree-optimize.c, tree-pass.h, tree-pretty-print.c, tree-profile.c,
tree-scalar-evolution.c, tree-sra.c, tree-ssa-ccp.c,
tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-copyrename.c,
tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-forwprop.c,
tree-ssa-ifcombine.c, tree-ssa-live.c, tree-ssa-loop-ch.c,
tree-ssa-loop-im.c, tree-ssa-loop-ivopts.c, tree-ssa-loop-prefetch.c,
tree-ssa-loop.c, tree-ssa-math-opts.c, tree-ssa-operands.c,
tree-ssa-phiopt.c, tree-ssa-phiprop.c, tree-ssa-pre.c,
tree-ssa-reassoc.c, tree-ssa-sink.c, tree-ssa-strlen.c,
tree-ssa-structalias.c, tree-ssa-threadedge.c, tree-ssa-threadupdate.c,
tree-ssa-uncprop.c, tree-ssa-uninit.c, tree-ssa.c, tree-ssanames.c,
tree-stdarg.c, tree-switch-conversion.c, tree-tailcall.c,
tree-vect-data-refs.c, tree-vect-generic.c, tree-vect-loop-manip.c,
tree-vect-stmts.c, tree-vectorizer.c, tree-vectorizer.h, tree-vrp.c,
tree.c, tree.h, tsan.c, tsystem.h, value-prof.c, var-tracking.c,
varasm.c, vec.h, vmsdbgout.c, vtable-verify.c, web.c: Add missing
whitespace before "(".
From-SVN: r203004
2013-09-28 10:42:34 +02:00
|
|
|
strlen (linker_output) + sizeof (DUMPBASE_SUFFIX),
|
2010-05-28 14:48:54 +02:00
|
|
|
"%s.ltrans%u", linker_output, i);
|
2010-05-25 17:47:28 +02:00
|
|
|
argv_ptr[0] = dumpbase;
|
|
|
|
}
|
|
|
|
|
|
|
|
argv_ptr[1] = "-fltrans";
|
|
|
|
argv_ptr[2] = "-o";
|
|
|
|
argv_ptr[3] = output_name;
|
|
|
|
argv_ptr[4] = input_name;
|
|
|
|
argv_ptr[5] = NULL;
|
|
|
|
if (parallel)
|
|
|
|
{
|
|
|
|
fprintf (mstream, "%s:\n\t@%s ", output_name, new_argv[0]);
|
|
|
|
for (j = 1; new_argv[j] != NULL; ++j)
|
|
|
|
fprintf (mstream, " '%s'", new_argv[j]);
|
|
|
|
fprintf (mstream, "\n");
|
2011-12-15 15:50:25 +01:00
|
|
|
/* If we are not preserving the ltrans input files then
|
|
|
|
truncate them as soon as we have processed it. This
|
|
|
|
reduces temporary disk-space usage. */
|
2014-06-26 11:16:19 +02:00
|
|
|
if (! save_temps)
|
2011-12-15 15:50:25 +01:00
|
|
|
fprintf (mstream, "\t@-touch -r %s %s.tem > /dev/null 2>&1 "
|
|
|
|
"&& mv %s.tem %s\n",
|
|
|
|
input_name, input_name, input_name, input_name);
|
2010-05-25 17:47:28 +02:00
|
|
|
}
|
|
|
|
else
|
2011-12-15 15:50:25 +01:00
|
|
|
{
|
Part 2 of the collect-utils library, now also used for collect2.
* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
(LTO_WRAPPER_OBJS): New variable.
(lto-wrapper$(exeext)): Use it.
* collect2.c: Include "collect-utils.h".
(verbose, debug): Remove variables.
(at_file_supplied): No longer static.
(tool_name): New variable.
(do_wait, fork_execute, maybe_unlink): Don't declare.
(tool_cleanup): No longer static.
(notice): Remove function.
(maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
fork_execute calls.
(collect_wait, do_wait, collect_execute): Remove functions.
(maybe_unlink): No longer static.
* collect2.h (verbose, debug): Don't declare.
(at_file_supplied): Declare.
* collect-utils.c (utils_cleanup): New arg from_signal. All callers
changed.
(collect_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(collect_wait): Replace with implementation from collect2.
(maybe_unlink_file): Remove function.
(fork_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(do_wait): Add call to utils_cleanup to the error path.
* collect-utils.h (collect_execute, fork_execute, utils_cleanup,
tool_cleanup): Adjust declarations.
* lto-wrapper.c (tool_cleanup): Add unused bool argument.
* tlink.c: Include "collect-utils.h".
(tlink_execute): New arg use_atfile. All callers changed.
(tlink_init, tlink_execute): Remove declarations.
From-SVN: r212020
2014-06-26 11:16:28 +02:00
|
|
|
fork_execute (new_argv[0], CONST_CAST (char **, new_argv),
|
|
|
|
true);
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (input_name);
|
2011-12-15 15:50:25 +01:00
|
|
|
}
|
2010-05-25 17:47:28 +02:00
|
|
|
|
|
|
|
output_names[i] = output_name;
|
|
|
|
}
|
2010-05-19 17:43:22 +02:00
|
|
|
if (parallel)
|
|
|
|
{
|
|
|
|
struct pex_obj *pex;
|
|
|
|
char jobs[32];
|
2010-08-31 18:58:46 +02:00
|
|
|
|
2010-05-19 17:43:22 +02:00
|
|
|
fprintf (mstream, "all:");
|
|
|
|
for (i = 0; i < nr; ++i)
|
|
|
|
fprintf (mstream, " \\\n\t%s", output_names[i]);
|
|
|
|
fprintf (mstream, "\n");
|
|
|
|
fclose (mstream);
|
2010-08-31 18:58:46 +02:00
|
|
|
if (!jobserver)
|
|
|
|
{
|
|
|
|
/* Avoid passing --jobserver-fd= and similar flags
|
|
|
|
unless jobserver mode is explicitly enabled. */
|
|
|
|
putenv (xstrdup ("MAKEFLAGS="));
|
|
|
|
putenv (xstrdup ("MFLAGS="));
|
|
|
|
}
|
2010-05-23 16:36:07 +02:00
|
|
|
new_argv[0] = getenv ("MAKE");
|
|
|
|
if (!new_argv[0])
|
|
|
|
new_argv[0] = "make";
|
2010-05-19 17:43:22 +02:00
|
|
|
new_argv[1] = "-f";
|
|
|
|
new_argv[2] = makefile;
|
2010-08-31 18:58:46 +02:00
|
|
|
i = 3;
|
|
|
|
if (!jobserver)
|
|
|
|
{
|
|
|
|
snprintf (jobs, 31, "-j%d", parallel);
|
|
|
|
new_argv[i++] = jobs;
|
|
|
|
}
|
|
|
|
new_argv[i++] = "all";
|
|
|
|
new_argv[i++] = NULL;
|
Part 2 of the collect-utils library, now also used for collect2.
* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
(LTO_WRAPPER_OBJS): New variable.
(lto-wrapper$(exeext)): Use it.
* collect2.c: Include "collect-utils.h".
(verbose, debug): Remove variables.
(at_file_supplied): No longer static.
(tool_name): New variable.
(do_wait, fork_execute, maybe_unlink): Don't declare.
(tool_cleanup): No longer static.
(notice): Remove function.
(maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
fork_execute calls.
(collect_wait, do_wait, collect_execute): Remove functions.
(maybe_unlink): No longer static.
* collect2.h (verbose, debug): Don't declare.
(at_file_supplied): Declare.
* collect-utils.c (utils_cleanup): New arg from_signal. All callers
changed.
(collect_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(collect_wait): Replace with implementation from collect2.
(maybe_unlink_file): Remove function.
(fork_execute): Replace with implementation from collect2, plus a
new arg use_atfile. All callers changed.
(do_wait): Add call to utils_cleanup to the error path.
* collect-utils.h (collect_execute, fork_execute, utils_cleanup,
tool_cleanup): Adjust declarations.
* lto-wrapper.c (tool_cleanup): Add unused bool argument.
* tlink.c: Include "collect-utils.h".
(tlink_execute): New arg use_atfile. All callers changed.
(tlink_init, tlink_execute): Remove declarations.
From-SVN: r212020
2014-06-26 11:16:28 +02:00
|
|
|
pex = collect_execute (new_argv[0], CONST_CAST (char **, new_argv),
|
|
|
|
NULL, NULL, PEX_SEARCH, false);
|
|
|
|
do_wait (new_argv[0], pex);
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (makefile);
|
2010-05-25 17:47:28 +02:00
|
|
|
makefile = NULL;
|
2011-12-15 15:50:25 +01:00
|
|
|
for (i = 0; i < nr; ++i)
|
2014-06-26 11:16:11 +02:00
|
|
|
maybe_unlink (input_names[i]);
|
2010-05-19 17:43:22 +02:00
|
|
|
}
|
|
|
|
for (i = 0; i < nr; ++i)
|
|
|
|
{
|
|
|
|
fputs (output_names[i], stdout);
|
2010-05-07 17:52:01 +02:00
|
|
|
putc ('\n', stdout);
|
2010-05-19 17:43:22 +02:00
|
|
|
free (input_names[i]);
|
2010-05-07 17:52:01 +02:00
|
|
|
}
|
2010-05-25 17:47:28 +02:00
|
|
|
nr = 0;
|
2010-05-19 17:43:22 +02:00
|
|
|
free (output_names);
|
|
|
|
free (input_names);
|
2009-10-03 23:10:11 +02:00
|
|
|
free (list_option_full);
|
2011-10-26 13:48:09 +02:00
|
|
|
obstack_free (&env_obstack, NULL);
|
2009-10-03 23:10:11 +02:00
|
|
|
}
|
2011-10-28 11:46:26 +02:00
|
|
|
|
[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
2014-11-13 14:47:46 +01:00
|
|
|
finish:
|
|
|
|
if (offloadend)
|
|
|
|
printf ("%s\n", offloadend);
|
|
|
|
|
2014-12-09 23:44:16 +01:00
|
|
|
XDELETE (lto_argv);
|
|
|
|
XDELETE (offload_argv);
|
2011-10-28 11:46:26 +02:00
|
|
|
obstack_free (&argv_obstack, NULL);
|
2009-10-03 23:10:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Entry point. */
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
Makefile.in (LIBDEPS): Add libcommon.a.
* Makefile.in (LIBDEPS): Add libcommon.a.
(LIBS): Likewise.
(GCC_OBJS): Remove diagnostic.o, pretty-print.o and input.o.
(OBJS-common): Remove diagnostic.o, input.o, intl.o,
pretty-print.o and version.o.
(OBJS-libcommon): New.
(ALL_HOST_BACKEND_OBJS): Add $(OBJS-libcommon).
(BACKEND): Add libcommon.a.
(MOSTLYCLEANFILES): Likewise.
(libcommon.a): New.
(xgcc$(exeext)): Don't explicitly use version.o and intl.o.
(cpp$(exeext)): Likewise.
(COLLECT2_OBJS): Remove intl.o, version.o, diagnostic.o,
pretty-print.o and input.o.
(lto-wrapper$(exeext)): Don't explicitly use intl.o.
(lto-wrapper.o): Depend on $(DIAGNOSTIC_H).
(errors.o): Remove.
(mips-tfile): Don't explicitly use version.o.
(mips-tdump): Likewise.
(gcov.o): Depend on $(DIAGNOSTIC_H).
(gcov-dump.o): Depend on intl.h and $(DIAGNOSTIC_H).
(GCOV_OBJS): Remove intl.o, version.o and errors.o.
(GCOV_DUMP_OBJS): Remove version.o and errors.o.
* gcov-dump.c: Include intl.h and diagnostic.h.
(main): Initialize diagnostics.
* gcov.c: Include diagnostic.h.
(fnotice): Remove.
(main): Initialize diagnostics.
* lto-wrapper.c: Include diagnostic.h.
(main): Initialize diagnostics.
ada:
* gcc-interface/Make-lang.in (EXTRA_GNATBIND_OBJS): Remove
version.o.
* gcc-interface/Makefile.in (EXTRA_GNATTOOLS_OBJS): Use
libcommon.a instead of version.o.
cp:
* Make-lang.in (GXX_OBJS): Remove intl.o and version.o.
fortran:
* Make-lang.in (GFORTRAN_D_OBJS): Remove version.o and intl.o.
go:
* Make-lang.in (GCCGO_OBJS): Remove intl.o and version.o.
java:
* Make-lang.in ($(XGCJ)$(exeext)): Don't explicitly use intl.o and
version.o.
(JCFDUMP_OBJS): Remove errors.o, version.o and intl.o.
(JVGENMAIN_OBJS): Remove errors.o and intl.o.
(java/jcf-dump.o, java/jvgenmain.o): Depend in $(DIAGNOSTIC_H).
* jcf-dump.c: Include diagnostic.h.
(main): Initialize diagnostics.
* jvgenmain.c: Include diagnostic.h.
(main): Initialize diagnostics.
From-SVN: r173958
2011-05-20 17:19:05 +02:00
|
|
|
const char *p;
|
|
|
|
|
2013-02-27 08:28:09 +01:00
|
|
|
gcc_obstack_init (&opts_obstack);
|
|
|
|
|
Makefile.in (LIBDEPS): Add libcommon.a.
* Makefile.in (LIBDEPS): Add libcommon.a.
(LIBS): Likewise.
(GCC_OBJS): Remove diagnostic.o, pretty-print.o and input.o.
(OBJS-common): Remove diagnostic.o, input.o, intl.o,
pretty-print.o and version.o.
(OBJS-libcommon): New.
(ALL_HOST_BACKEND_OBJS): Add $(OBJS-libcommon).
(BACKEND): Add libcommon.a.
(MOSTLYCLEANFILES): Likewise.
(libcommon.a): New.
(xgcc$(exeext)): Don't explicitly use version.o and intl.o.
(cpp$(exeext)): Likewise.
(COLLECT2_OBJS): Remove intl.o, version.o, diagnostic.o,
pretty-print.o and input.o.
(lto-wrapper$(exeext)): Don't explicitly use intl.o.
(lto-wrapper.o): Depend on $(DIAGNOSTIC_H).
(errors.o): Remove.
(mips-tfile): Don't explicitly use version.o.
(mips-tdump): Likewise.
(gcov.o): Depend on $(DIAGNOSTIC_H).
(gcov-dump.o): Depend on intl.h and $(DIAGNOSTIC_H).
(GCOV_OBJS): Remove intl.o, version.o and errors.o.
(GCOV_DUMP_OBJS): Remove version.o and errors.o.
* gcov-dump.c: Include intl.h and diagnostic.h.
(main): Initialize diagnostics.
* gcov.c: Include diagnostic.h.
(fnotice): Remove.
(main): Initialize diagnostics.
* lto-wrapper.c: Include diagnostic.h.
(main): Initialize diagnostics.
ada:
* gcc-interface/Make-lang.in (EXTRA_GNATBIND_OBJS): Remove
version.o.
* gcc-interface/Makefile.in (EXTRA_GNATTOOLS_OBJS): Use
libcommon.a instead of version.o.
cp:
* Make-lang.in (GXX_OBJS): Remove intl.o and version.o.
fortran:
* Make-lang.in (GFORTRAN_D_OBJS): Remove version.o and intl.o.
go:
* Make-lang.in (GCCGO_OBJS): Remove intl.o and version.o.
java:
* Make-lang.in ($(XGCJ)$(exeext)): Don't explicitly use intl.o and
version.o.
(JCFDUMP_OBJS): Remove errors.o, version.o and intl.o.
(JVGENMAIN_OBJS): Remove errors.o and intl.o.
(java/jcf-dump.o, java/jvgenmain.o): Depend in $(DIAGNOSTIC_H).
* jcf-dump.c: Include diagnostic.h.
(main): Initialize diagnostics.
* jvgenmain.c: Include diagnostic.h.
(main): Initialize diagnostics.
From-SVN: r173958
2011-05-20 17:19:05 +02:00
|
|
|
p = argv[0] + strlen (argv[0]);
|
|
|
|
while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
|
|
|
|
--p;
|
|
|
|
progname = p;
|
|
|
|
|
|
|
|
xmalloc_set_program_name (progname);
|
|
|
|
|
2009-10-03 23:10:11 +02:00
|
|
|
gcc_init_libintl ();
|
|
|
|
|
Makefile.in (LIBDEPS): Add libcommon.a.
* Makefile.in (LIBDEPS): Add libcommon.a.
(LIBS): Likewise.
(GCC_OBJS): Remove diagnostic.o, pretty-print.o and input.o.
(OBJS-common): Remove diagnostic.o, input.o, intl.o,
pretty-print.o and version.o.
(OBJS-libcommon): New.
(ALL_HOST_BACKEND_OBJS): Add $(OBJS-libcommon).
(BACKEND): Add libcommon.a.
(MOSTLYCLEANFILES): Likewise.
(libcommon.a): New.
(xgcc$(exeext)): Don't explicitly use version.o and intl.o.
(cpp$(exeext)): Likewise.
(COLLECT2_OBJS): Remove intl.o, version.o, diagnostic.o,
pretty-print.o and input.o.
(lto-wrapper$(exeext)): Don't explicitly use intl.o.
(lto-wrapper.o): Depend on $(DIAGNOSTIC_H).
(errors.o): Remove.
(mips-tfile): Don't explicitly use version.o.
(mips-tdump): Likewise.
(gcov.o): Depend on $(DIAGNOSTIC_H).
(gcov-dump.o): Depend on intl.h and $(DIAGNOSTIC_H).
(GCOV_OBJS): Remove intl.o, version.o and errors.o.
(GCOV_DUMP_OBJS): Remove version.o and errors.o.
* gcov-dump.c: Include intl.h and diagnostic.h.
(main): Initialize diagnostics.
* gcov.c: Include diagnostic.h.
(fnotice): Remove.
(main): Initialize diagnostics.
* lto-wrapper.c: Include diagnostic.h.
(main): Initialize diagnostics.
ada:
* gcc-interface/Make-lang.in (EXTRA_GNATBIND_OBJS): Remove
version.o.
* gcc-interface/Makefile.in (EXTRA_GNATTOOLS_OBJS): Use
libcommon.a instead of version.o.
cp:
* Make-lang.in (GXX_OBJS): Remove intl.o and version.o.
fortran:
* Make-lang.in (GFORTRAN_D_OBJS): Remove version.o and intl.o.
go:
* Make-lang.in (GCCGO_OBJS): Remove intl.o and version.o.
java:
* Make-lang.in ($(XGCJ)$(exeext)): Don't explicitly use intl.o and
version.o.
(JCFDUMP_OBJS): Remove errors.o, version.o and intl.o.
(JVGENMAIN_OBJS): Remove errors.o and intl.o.
(java/jcf-dump.o, java/jvgenmain.o): Depend in $(DIAGNOSTIC_H).
* jcf-dump.c: Include diagnostic.h.
(main): Initialize diagnostics.
* jvgenmain.c: Include diagnostic.h.
(main): Initialize diagnostics.
From-SVN: r173958
2011-05-20 17:19:05 +02:00
|
|
|
diagnostic_initialize (global_dc, 0);
|
|
|
|
|
2014-11-19 12:48:48 +01:00
|
|
|
if (atexit (lto_wrapper_cleanup) != 0)
|
|
|
|
fatal_error ("atexit failed");
|
|
|
|
|
2010-06-02 15:58:27 +02:00
|
|
|
if (signal (SIGINT, SIG_IGN) != SIG_IGN)
|
|
|
|
signal (SIGINT, fatal_signal);
|
|
|
|
#ifdef SIGHUP
|
|
|
|
if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
|
|
|
|
signal (SIGHUP, fatal_signal);
|
|
|
|
#endif
|
|
|
|
if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
|
|
|
|
signal (SIGTERM, fatal_signal);
|
|
|
|
#ifdef SIGPIPE
|
|
|
|
if (signal (SIGPIPE, SIG_IGN) != SIG_IGN)
|
|
|
|
signal (SIGPIPE, fatal_signal);
|
|
|
|
#endif
|
|
|
|
#ifdef SIGCHLD
|
|
|
|
/* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will
|
|
|
|
receive the signal. A different setting is inheritable */
|
|
|
|
signal (SIGCHLD, SIG_DFL);
|
|
|
|
#endif
|
|
|
|
|
2009-10-03 23:10:11 +02:00
|
|
|
/* We may be called with all the arguments stored in some file and
|
|
|
|
passed with @file. Expand them into argv before processing. */
|
|
|
|
expandargv (&argc, &argv);
|
2011-10-26 11:30:29 +02:00
|
|
|
|
2010-05-18 17:11:01 +02:00
|
|
|
run_gcc (argc, argv);
|
2009-10-03 23:10:11 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|