|
|
6f0f47 |
2019-01-17 Jakub Jelinek <jakub@redhat.com>
|
|
|
6f0f47 |
|
|
|
6f0f47 |
* gcc.c (offload_targets_default): New variable.
|
|
|
6f0f47 |
(process_command): Set it if -foffload is defaulted.
|
|
|
6f0f47 |
(driver::maybe_putenv_OFFLOAD_TARGETS): Add OFFLOAD_TARGET_DEFAULT=1
|
|
|
6f0f47 |
into environment if -foffload has been defaulted.
|
|
|
6f0f47 |
* lto-wrapper.c (OFFLOAD_TARGET_DEFAULT_ENV): Define.
|
|
|
6f0f47 |
(compile_offload_image): If OFFLOAD_TARGET_DEFAULT
|
|
|
6f0f47 |
is in the environment, don't fail if corresponding mkoffload
|
|
|
6f0f47 |
can't be found.
|
|
|
6f0f47 |
(compile_images_for_offload_targets): Likewise. Free and clear
|
|
|
6f0f47 |
offload_names if no valid offload is found.
|
|
|
6f0f47 |
libgomp/
|
|
|
6f0f47 |
* target.c (gomp_load_plugin_for_device): If a plugin can't be
|
|
|
6f0f47 |
dlopened, assume it has no devices silently.
|
|
|
6f0f47 |
|
|
|
6f0f47 |
--- gcc/gcc.c.jj 2017-01-17 10:28:40.000000000 +0100
|
|
|
6f0f47 |
+++ gcc/gcc.c 2017-01-20 16:26:29.649962902 +0100
|
|
|
6f0f47 |
@@ -319,6 +319,10 @@ static const char *spec_host_machine = D
|
|
|
6f0f47 |
|
|
|
6f0f47 |
static char *offload_targets = NULL;
|
|
|
6f0f47 |
|
|
|
6f0f47 |
+/* Set to true if -foffload has not been used and offload_targets
|
|
|
6f0f47 |
+ is set to the configured in default. */
|
|
|
6f0f47 |
+static bool offload_targets_default;
|
|
|
6f0f47 |
+
|
|
|
6f0f47 |
/* Nonzero if cross-compiling.
|
|
|
6f0f47 |
When -b is used, the value comes from the `specs' file. */
|
|
|
6f0f47 |
|
|
|
6f0f47 |
@@ -4828,7 +4832,10 @@ process_command (unsigned int decoded_op
|
|
|
6f0f47 |
/* If the user didn't specify any, default to all configured offload
|
|
|
6f0f47 |
targets. */
|
|
|
6f0f47 |
if (ENABLE_OFFLOADING && offload_targets == NULL)
|
|
|
6f0f47 |
- handle_foffload_option (OFFLOAD_TARGETS);
|
|
|
6f0f47 |
+ {
|
|
|
6f0f47 |
+ handle_foffload_option (OFFLOAD_TARGETS);
|
|
|
6f0f47 |
+ offload_targets_default = true;
|
|
|
6f0f47 |
+ }
|
|
|
6f0f47 |
|
|
|
6f0f47 |
/* Handle -gtoggle as it would later in toplev.c:process_options to
|
|
|
6f0f47 |
make the debug-level-gt spec function work as expected. */
|
|
|
6f0f47 |
@@ -8494,6 +8501,8 @@ driver::maybe_putenv_OFFLOAD_TARGETS ()
|
|
|
6f0f47 |
obstack_grow (&collect_obstack, offload_targets,
|
|
|
6f0f47 |
strlen (offload_targets) + 1);
|
|
|
6f0f47 |
xputenv (XOBFINISH (&collect_obstack, char *));
|
|
|
6f0f47 |
+ if (offload_targets_default)
|
|
|
6f0f47 |
+ xputenv ("OFFLOAD_TARGET_DEFAULT=1");
|
|
|
6f0f47 |
}
|
|
|
6f0f47 |
|
|
|
6f0f47 |
free (offload_targets);
|
|
|
6f0f47 |
--- gcc/lto-wrapper.c.jj 2017-01-01 12:45:34.000000000 +0100
|
|
|
6f0f47 |
+++ gcc/lto-wrapper.c 2017-01-20 16:34:18.294016997 +0100
|
|
|
6f0f47 |
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
|
|
|
6f0f47 |
/* Environment variable, used for passing the names of offload targets from GCC
|
|
|
6f0f47 |
driver to lto-wrapper. */
|
|
|
6f0f47 |
#define OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES"
|
|
|
6f0f47 |
+#define OFFLOAD_TARGET_DEFAULT_ENV "OFFLOAD_TARGET_DEFAULT"
|
|
|
6f0f47 |
|
|
|
6f0f47 |
/* By default there is no special suffix for target executables. */
|
|
|
6f0f47 |
#ifdef TARGET_EXECUTABLE_SUFFIX
|
|
|
6f0f47 |
@@ -906,6 +907,12 @@ compile_offload_image (const char *targe
|
|
|
6f0f47 |
break;
|
|
|
6f0f47 |
}
|
|
|
6f0f47 |
|
|
|
6f0f47 |
+ if (!compiler && getenv (OFFLOAD_TARGET_DEFAULT_ENV))
|
|
|
6f0f47 |
+ {
|
|
|
6f0f47 |
+ free_array_of_ptrs ((void **) paths, n_paths);
|
|
|
6f0f47 |
+ return NULL;
|
|
|
6f0f47 |
+ }
|
|
|
6f0f47 |
+
|
|
|
6f0f47 |
if (!compiler)
|
|
|
6f0f47 |
fatal_error (input_location,
|
|
|
6f0f47 |
"could not find %s in %s (consider using %<-B%>)",
|
|
|
6f0f47 |
@@ -975,6 +982,7 @@ compile_images_for_offload_targets (unsi
|
|
|
6f0f47 |
if (!target_names)
|
|
|
6f0f47 |
return;
|
|
|
6f0f47 |
unsigned num_targets = parse_env_var (target_names, &names, NULL);
|
|
|
6f0f47 |
+ int next_name_entry = 0;
|
|
|
6f0f47 |
|
|
|
6f0f47 |
const char *compiler_path = getenv ("COMPILER_PATH");
|
|
|
6f0f47 |
if (!compiler_path)
|
|
|
6f0f47 |
@@ -985,13 +993,19 @@ compile_images_for_offload_targets (unsi
|
|
|
6f0f47 |
offload_names = XCNEWVEC (char *, num_targets + 1);
|
|
|
6f0f47 |
for (unsigned i = 0; i < num_targets; i++)
|
|
|
6f0f47 |
{
|
|
|
6f0f47 |
- offload_names[i]
|
|
|
6f0f47 |
+ offload_names[next_name_entry]
|
|
|
6f0f47 |
= compile_offload_image (names[i], compiler_path, in_argc, in_argv,
|
|
|
6f0f47 |
compiler_opts, compiler_opt_count,
|
|
|
6f0f47 |
linker_opts, linker_opt_count);
|
|
|
6f0f47 |
- if (!offload_names[i])
|
|
|
6f0f47 |
- fatal_error (input_location,
|
|
|
6f0f47 |
- "problem with building target image for %s", names[i]);
|
|
|
6f0f47 |
+ if (!offload_names[next_name_entry])
|
|
|
6f0f47 |
+ continue;
|
|
|
6f0f47 |
+ next_name_entry++;
|
|
|
6f0f47 |
+ }
|
|
|
6f0f47 |
+
|
|
|
6f0f47 |
+ if (next_name_entry == 0)
|
|
|
6f0f47 |
+ {
|
|
|
6f0f47 |
+ free (offload_names);
|
|
|
6f0f47 |
+ offload_names = NULL;
|
|
|
6f0f47 |
}
|
|
|
6f0f47 |
|
|
|
6f0f47 |
out:
|
|
|
6f0f47 |
--- libgomp/target.c.jj 2017-01-01 12:45:52.000000000 +0100
|
|
|
6f0f47 |
+++ libgomp/target.c 2017-01-20 20:12:13.756710875 +0100
|
|
|
6f0f47 |
@@ -2356,7 +2356,7 @@ gomp_load_plugin_for_device (struct gomp
|
|
|
6f0f47 |
|
|
|
6f0f47 |
void *plugin_handle = dlopen (plugin_name, RTLD_LAZY);
|
|
|
6f0f47 |
if (!plugin_handle)
|
|
|
6f0f47 |
- goto dl_fail;
|
|
|
6f0f47 |
+ return 0;
|
|
|
6f0f47 |
|
|
|
6f0f47 |
/* Check if all required functions are available in the plugin and store
|
|
|
6f0f47 |
their handlers. None of the symbols can legitimately be NULL,
|