+2014-12-09 Ilya Verbin <ilya.verbin@intel.com>
+
+ * lto-wrapper.c (compile_offload_image): Start processing in_argv
+ from 0 instead of 1.
+ (run_gcc): Put offload objects into offload_argv, put LTO objects and
+ possible preceding arguments into lto_argv.
+ Pass offload_argv to compile_images_for_offload_targets instead of argv.
+ Use lto_argv for LTO recompilation instead of argv.
+
2014-12-09 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
* doc/install.texi: Describe --with-aix-soname option.
obstack_ptr_grow (&argv_obstack, filename);
/* Append names of input object files. */
- for (unsigned i = 1; i < in_argc; i++)
+ for (unsigned i = 0; i < in_argc; i++)
obstack_ptr_grow (&argv_obstack, in_argv[i]);
/* Append options from offload_lto sections. */
int new_head_argc;
bool have_lto = false;
bool have_offload = false;
+ unsigned lto_argc = 0, offload_argc = 0;
+ char **lto_argv, **offload_argv;
/* Get the driver and options. */
collect_gcc = getenv ("COLLECT_GCC");
&decoded_options,
&decoded_options_count);
+ /* 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);
+
/* Look at saved options in the IL files. */
for (i = 1; i < argc; ++i)
{
}
fd = open (argv[i], O_RDONLY);
if (fd == -1)
- continue;
+ {
+ 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];
+ }
- have_lto
- |= find_and_merge_options (fd, file_offset, LTO_SECTION_NAME_PREFIX,
- &fdecoded_options, &fdecoded_options_count,
- collect_gcc);
- have_offload
- |= find_and_merge_options (fd, file_offset, OFFLOAD_SECTION_NAME_PREFIX,
- &offload_fdecoded_options,
- &offload_fdecoded_options_count,
- collect_gcc);
close (fd);
}
if (have_offload)
{
- compile_images_for_offload_targets (argc, argv, offload_fdecoded_options,
+ compile_images_for_offload_targets (offload_argc, offload_argv,
+ offload_fdecoded_options,
offload_fdecoded_options_count,
decoded_options,
decoded_options_count);
}
/* Append the input objects and possible preceding arguments. */
- for (i = 1; i < argc; ++i)
- obstack_ptr_grow (&argv_obstack, argv[i]);
+ for (i = 0; i < lto_argc; ++i)
+ obstack_ptr_grow (&argv_obstack, lto_argv[i]);
obstack_ptr_grow (&argv_obstack, NULL);
new_argv = XOBFINISH (&argv_obstack, const char **);
if (offloadend)
printf ("%s\n", offloadend);
+ XDELETE (lto_argv);
+ XDELETE (offload_argv);
obstack_free (&argv_obstack, NULL);
}
+2014-12-09 Ilya Verbin <ilya.verbin@intel.com>
+
+ * lto-plugin.c (offload_files, num_offload_files): New static variables.
+ (free_1): Use arguments instead of global variables.
+ (free_2): Free offload_files.
+ (all_symbols_read_handler): Add names from offload_files to lto-wrapper
+ arguments.
+ (claim_file_handler): Do not add file to claimed_files if it contains
+ offload sections without LTO sections. Add it to offload_files instead.
+
2014-11-21 H.J. Lu <hongjiu.lu@intel.com>
PR bootstrap/63784
static struct plugin_file_info *claimed_files = NULL;
static unsigned int num_claimed_files = 0;
+static struct plugin_file_info *offload_files = NULL;
+static unsigned int num_offload_files = 0;
+
static char **output_files = NULL;
static unsigned int num_output_files = 0;
resolution. */
static void
-free_1 (void)
+free_1 (struct plugin_file_info *files, unsigned num_files)
{
unsigned int i;
- for (i = 0; i < num_claimed_files; i++)
+ for (i = 0; i < num_files; i++)
{
- struct plugin_file_info *info = &claimed_files[i];
+ struct plugin_file_info *info = &files[i];
struct plugin_symtab *symtab = &info->symtab;
unsigned int j;
for (j = 0; j < symtab->nsyms; j++)
free (info->name);
}
+ for (i = 0; i < num_offload_files; i++)
+ {
+ struct plugin_file_info *info = &offload_files[i];
+ struct plugin_symtab *symtab = &info->symtab;
+ free (symtab->aux);
+ free (info->name);
+ }
+
for (i = 0; i < num_output_files; i++)
free (output_files[i]);
free (output_files);
claimed_files = NULL;
num_claimed_files = 0;
+ free (offload_files);
+ offload_files = NULL;
+ num_offload_files = 0;
+
free (arguments_file_name);
arguments_file_name = NULL;
}
all_symbols_read_handler (void)
{
unsigned i;
- unsigned num_lto_args = num_claimed_files + lto_wrapper_num_args + 1;
+ unsigned num_lto_args
+ = num_claimed_files + num_offload_files + lto_wrapper_num_args + 1;
char **lto_argv;
const char **lto_arg_ptr;
- if (num_claimed_files == 0)
+ if (num_claimed_files + num_offload_files == 0)
return LDPS_OK;
if (nop)
write_resolution ();
- free_1 ();
+ free_1 (claimed_files, num_claimed_files);
+ free_1 (offload_files, num_offload_files);
for (i = 0; i < lto_wrapper_num_args; i++)
*lto_arg_ptr++ = lto_wrapper_argv[i];
*lto_arg_ptr++ = info->name;
}
+ for (i = 0; i < num_offload_files; i++)
+ {
+ struct plugin_file_info *info = &offload_files[i];
+
+ *lto_arg_ptr++ = info->name;
+ }
+
*lto_arg_ptr++ = NULL;
exec_lto_wrapper (lto_argv);
if (obj.found > 1)
resolve_conflicts (<o_file.symtab, <o_file.conflicts);
- status = add_symbols (file->handle, lto_file.symtab.nsyms,
- lto_file.symtab.syms);
- check (status == LDPS_OK, LDPL_FATAL, "could not add symbols");
+ if (obj.found > 0)
+ {
+ status = add_symbols (file->handle, lto_file.symtab.nsyms,
+ lto_file.symtab.syms);
+ check (status == LDPS_OK, LDPL_FATAL, "could not add symbols");
+
+ num_claimed_files++;
+ claimed_files =
+ xrealloc (claimed_files,
+ num_claimed_files * sizeof (struct plugin_file_info));
+ claimed_files[num_claimed_files - 1] = lto_file;
+ }
+
+ if (obj.found == 0 && obj.offload == 1)
+ {
+ num_offload_files++;
+ offload_files =
+ xrealloc (offload_files,
+ num_offload_files * sizeof (struct plugin_file_info));
+ offload_files[num_offload_files - 1] = lto_file;
+ }
*claimed = 1;
- num_claimed_files++;
- claimed_files =
- xrealloc (claimed_files,
- num_claimed_files * sizeof (struct plugin_file_info));
- claimed_files[num_claimed_files - 1] = lto_file;
goto cleanup;