return decoded;
}
-/* Find option in OPTIONS based on OPT_INDEX. -1 value is returned
- if the option is not present. */
+/* Find option in OPTIONS based on OPT_INDEX, starting at START. -1
+ value is returned if the option is not present. */
static int
-find_option (vec<cl_decoded_option> &options, size_t opt_index)
+find_option (vec<cl_decoded_option> &options, size_t opt_index,
+ unsigned start = 0)
{
- for (unsigned i = 0; i < options.length (); ++i)
+ for (unsigned i = start; i < options.length (); ++i)
if (options[i].opt_index == opt_index)
return i;
else
j++;
+ int existing_opt_index, existing_opt2_index;
if (!xassembler_options_error)
- for (i = j = 0; ; i++, j++)
+ for (existing_opt_index = existing_opt2_index = 0; ;
+ existing_opt_index++, existing_opt2_index++)
{
- int existing_opt_index
- = find_option (decoded_options, OPT_Xassembler);
- int existing_opt2_index
- = find_option (fdecoded_options, OPT_Xassembler);
+ existing_opt_index
+ = find_option (decoded_options, OPT_Xassembler, existing_opt_index);
+ existing_opt2_index
+ = find_option (fdecoded_options, OPT_Xassembler,
+ existing_opt2_index);
cl_decoded_option *existing_opt = NULL;
cl_decoded_option *existing_opt2 = NULL;
static bool
find_and_merge_options (int fd, off_t file_offset, const char *prefix,
- vec<cl_decoded_option> decoded_cl_options,
+ vec<cl_decoded_option> decoded_cl_options, bool first,
vec<cl_decoded_option> *opts, const char *collect_gcc)
{
off_t offset, length;
int err;
vec<cl_decoded_option> fdecoded_options;
+ if (!first)
+ fdecoded_options = *opts;
+
simple_object_read *sobj;
sobj = simple_object_start_read (fd, file_offset, "__GNU_LTO",
&errmsg, &err);
data = (char *)xmalloc (length);
read (fd, data, length);
fopts = data;
- bool first = true;
do
{
vec<cl_decoded_option> f2decoded_options
int auto_parallel = 0;
bool no_partition = false;
const char *jobserver_error = NULL;
+ bool fdecoded_options_first = true;
vec<cl_decoded_option> fdecoded_options;
fdecoded_options.create (16);
+ bool offload_fdecoded_options_first = true;
vec<cl_decoded_option> offload_fdecoded_options = vNULL;
struct obstack argv_obstack;
int new_head_argc;
}
if (find_and_merge_options (fd, file_offset, LTO_SECTION_NAME_PREFIX,
- decoded_options, &fdecoded_options,
+ decoded_options, fdecoded_options_first,
+ &fdecoded_options,
collect_gcc))
{
have_lto = true;
ltoobj_argv[ltoobj_argc++] = argv[i];
+ fdecoded_options_first = false;
}
close (fd);
}
fatal_error (input_location, "cannot open %s: %m", filename);
if (!find_and_merge_options (fd, file_offset,
OFFLOAD_SECTION_NAME_PREFIX,
- decoded_options, &offload_fdecoded_options,
+ decoded_options,
+ offload_fdecoded_options_first,
+ &offload_fdecoded_options,
collect_gcc))
fatal_error (input_location, "cannot read %s: %m", filename);
+ offload_fdecoded_options_first = false;
close (fd);
if (filename != offload_argv[i])
XDELETEVEC (filename);