/* Wrapper to call lto. Used by collect2 and the linker plugin.
- Copyright (C) 2009-2020 Free Software Foundation, Inc.
+ Copyright (C) 2009-2021 Free Software Foundation, Inc.
Factored out of collect2 by Rafael Espindola <espindola@google.com>
/* Environment variable, used for passing the names of offload targets from GCC
driver to lto-wrapper. */
#define OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES"
+#define OFFLOAD_TARGET_DEFAULT_ENV "OFFLOAD_TARGET_DEFAULT"
/* By default there is no special suffix for target executables. */
#ifdef TARGET_EXECUTABLE_SUFFIX
if (cf_protection_option
&& cf_protection_option->value == CF_CHECK)
fatal_error (input_location,
- "option -fcf-protection with mismatching values"
+ "option %qs with mismatching values"
" (%s, %s)",
+ "-fcf-protection",
(*decoded_options)[j].arg, foption->arg);
else
{
compiler = paths[i];
break;
}
+#if OFFLOAD_DEFAULTED
+ if (!compiler && getenv (OFFLOAD_TARGET_DEFAULT_ENV))
+ {
+ free_array_of_ptrs ((void **) paths, n_paths);
+ return NULL;
+ }
+#endif
if (!compiler)
fatal_error (input_location,
if (!target_names)
return;
unsigned num_targets = parse_env_var (target_names, &names, NULL);
+ int next_name_entry = 0;
const char *compiler_path = getenv ("COMPILER_PATH");
if (!compiler_path)
offload_names = XCNEWVEC (char *, num_targets + 1);
for (unsigned i = 0; i < num_targets; i++)
{
- offload_names[i]
+ offload_names[next_name_entry]
= compile_offload_image (names[i], compiler_path, in_argc, in_argv,
compiler_opts, compiler_opt_count,
linker_opts, linker_opt_count);
- if (!offload_names[i])
+ if (!offload_names[next_name_entry])
+#if OFFLOAD_DEFAULTED
+ continue;
+#else
fatal_error (input_location,
"problem with building target image for %s", names[i]);
+#endif
+ next_name_entry++;
}
+#if OFFLOAD_DEFAULTED
+ if (next_name_entry == 0)
+ {
+ free (offload_names);
+ offload_names = NULL;
+ }
+#endif
+
out:
free_array_of_ptrs ((void **) names, num_targets);
}
#endif
}
-/* FIXME: once using -std=c++11, we can use std::thread::hardware_concurrency. */
-
/* Test and return reason why a jobserver cannot be detected. */
static const char *
if (jobserver && jobserver_error != NULL)
{
warning (0, jobserver_error);
- parallel = 0;
+ /* Fall back to auto parallelism. */
jobserver = 0;
+ auto_parallel = 1;
}
else if (!jobserver && jobserver_error == NULL)
{
{
char buf[256];
init_num_threads ();
+ if (nthreads_var == 0)
+ nthreads_var = 1;
if (verbose)
fprintf (stderr, "LTO parallelism level set to %ld\n",
nthreads_var);