|
|
5cc31e |
2017-01-20 Jakub Jelinek <jakub@redhat.com>
|
|
|
5cc31e |
|
|
|
5cc31e |
* gcc.c (offload_targets_default): New variable.
|
|
|
5cc31e |
(process_command): Set it if -foffload is defaulted.
|
|
|
5cc31e |
(driver::maybe_putenv_OFFLOAD_TARGETS): Add OFFLOAD_TARGET_DEFAULT=1
|
|
|
5cc31e |
into environment if -foffload has been defaulted.
|
|
|
5cc31e |
* lto-wrapper.c (OFFLOAD_TARGET_DEFAULT_ENV): Define.
|
|
|
5cc31e |
(compile_images_for_offload_targets): If OFFLOAD_TARGET_DEFAULT
|
|
|
5cc31e |
is in the environment, don't fail if corresponding mkoffload
|
|
|
5cc31e |
can't be found. Free and clear offload_names if no valid offload
|
|
|
5cc31e |
is found.
|
|
|
5cc31e |
libgomp/
|
|
|
5cc31e |
* target.c (gomp_load_plugin_for_device): If a plugin can't be
|
|
|
5cc31e |
dlopened, assume it has no devices silently.
|
|
|
5cc31e |
|
|
|
5cc31e |
--- gcc/gcc.c.jj 2017-01-17 10:28:40.000000000 +0100
|
|
|
5cc31e |
+++ gcc/gcc.c 2017-01-20 16:26:29.649962902 +0100
|
|
|
5cc31e |
@@ -290,6 +290,10 @@ static const char *spec_host_machine = D
|
|
|
5cc31e |
|
|
|
5cc31e |
static char *offload_targets = NULL;
|
|
|
5cc31e |
|
|
|
5cc31e |
+/* Set to true if -foffload has not been used and offload_targets
|
|
|
5cc31e |
+ is set to the configured in default. */
|
|
|
5cc31e |
+static bool offload_targets_default;
|
|
|
5cc31e |
+
|
|
|
5cc31e |
/* Nonzero if cross-compiling.
|
|
|
5cc31e |
When -b is used, the value comes from the `specs' file. */
|
|
|
5cc31e |
|
|
|
5cc31e |
@@ -4457,7 +4461,10 @@ process_command (unsigned int decoded_op
|
|
|
5cc31e |
/* If the user didn't specify any, default to all configured offload
|
|
|
5cc31e |
targets. */
|
|
|
5cc31e |
if (ENABLE_OFFLOADING && offload_targets == NULL)
|
|
|
5cc31e |
- handle_foffload_option (OFFLOAD_TARGETS);
|
|
|
5cc31e |
+ {
|
|
|
5cc31e |
+ handle_foffload_option (OFFLOAD_TARGETS);
|
|
|
5cc31e |
+ offload_targets_default = true;
|
|
|
5cc31e |
+ }
|
|
|
5cc31e |
|
|
|
5cc31e |
if (output_file
|
|
|
5cc31e |
&& strcmp (output_file, "-") != 0
|
|
|
5cc31e |
@@ -7693,6 +7700,8 @@ driver::maybe_putenv_OFFLOAD_TARGETS ()
|
|
|
5cc31e |
obstack_grow (&collect_obstack, offload_targets,
|
|
|
5cc31e |
strlen (offload_targets) + 1);
|
|
|
5cc31e |
xputenv (XOBFINISH (&collect_obstack, char *));
|
|
|
5cc31e |
+ if (offload_targets_default)
|
|
|
5cc31e |
+ xputenv ("OFFLOAD_TARGET_DEFAULT=1");
|
|
|
5cc31e |
}
|
|
|
5cc31e |
|
|
|
5cc31e |
free (offload_targets);
|
|
|
5cc31e |
--- gcc/lto-wrapper.c.jj 2017-01-01 12:45:34.000000000 +0100
|
|
|
5cc31e |
+++ gcc/lto-wrapper.c 2017-01-20 16:34:18.294016997 +0100
|
|
|
5cc31e |
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
|
|
|
5cc31e |
/* Environment variable, used for passing the names of offload targets from GCC
|
|
|
5cc31e |
driver to lto-wrapper. */
|
|
|
5cc31e |
#define OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES"
|
|
|
5cc31e |
+#define OFFLOAD_TARGET_DEFAULT_ENV "OFFLOAD_TARGET_DEFAULT"
|
|
|
5cc31e |
|
|
|
5cc31e |
enum lto_mode_d {
|
|
|
5cc31e |
LTO_MODE_NONE, /* Not doing LTO. */
|
|
|
5cc31e |
@@ -790,8 +791,10 @@ compile_images_for_offload_targets (unsi
|
|
|
5cc31e |
if (!target_names)
|
|
|
5cc31e |
return;
|
|
|
5cc31e |
unsigned num_targets = parse_env_var (target_names, &names, NULL);
|
|
|
5cc31e |
+ const char *target_names_default = getenv (OFFLOAD_TARGET_DEFAULT_ENV);
|
|
|
5cc31e |
|
|
|
5cc31e |
int next_name_entry = 0;
|
|
|
5cc31e |
+ bool hsa_seen = false;
|
|
|
5cc31e |
const char *compiler_path = getenv ("COMPILER_PATH");
|
|
|
5cc31e |
if (!compiler_path)
|
|
|
5cc31e |
goto out;
|
|
|
5cc31e |
@@ -804,18 +807,32 @@ compile_images_for_offload_targets (unsi
|
|
|
5cc31e |
/* HSA does not use LTO-like streaming and a different compiler, skip
|
|
|
5cc31e |
it. */
|
|
|
5cc31e |
if (strcmp (names[i], "hsa") == 0)
|
|
|
5cc31e |
- continue;
|
|
|
5cc31e |
+ {
|
|
|
5cc31e |
+ hsa_seen = true;
|
|
|
5cc31e |
+ continue;
|
|
|
5cc31e |
+ }
|
|
|
5cc31e |
|
|
|
5cc31e |
offload_names[next_name_entry]
|
|
|
5cc31e |
= compile_offload_image (names[i], compiler_path, in_argc, in_argv,
|
|
|
5cc31e |
compiler_opts, compiler_opt_count,
|
|
|
5cc31e |
linker_opts, linker_opt_count);
|
|
|
5cc31e |
if (!offload_names[next_name_entry])
|
|
|
5cc31e |
- fatal_error (input_location,
|
|
|
5cc31e |
- "problem with building target image for %s\n", names[i]);
|
|
|
5cc31e |
+ {
|
|
|
5cc31e |
+ if (target_names_default != NULL)
|
|
|
5cc31e |
+ continue;
|
|
|
5cc31e |
+ fatal_error (input_location,
|
|
|
5cc31e |
+ "problem with building target image for %s\n",
|
|
|
5cc31e |
+ names[i]);
|
|
|
5cc31e |
+ }
|
|
|
5cc31e |
next_name_entry++;
|
|
|
5cc31e |
}
|
|
|
5cc31e |
|
|
|
5cc31e |
+ if (next_name_entry == 0 && !hsa_seen)
|
|
|
5cc31e |
+ {
|
|
|
5cc31e |
+ free (offload_names);
|
|
|
5cc31e |
+ offload_names = NULL;
|
|
|
5cc31e |
+ }
|
|
|
5cc31e |
+
|
|
|
5cc31e |
out:
|
|
|
5cc31e |
free_array_of_ptrs ((void **) names, num_targets);
|
|
|
5cc31e |
}
|
|
|
5cc31e |
--- libgomp/target.c.jj 2017-01-01 12:45:52.000000000 +0100
|
|
|
5cc31e |
+++ libgomp/target.c 2017-01-20 20:12:13.756710875 +0100
|
|
|
5cc31e |
@@ -2356,7 +2356,7 @@ gomp_load_plugin_for_device (struct gomp
|
|
|
5cc31e |
|
|
|
5cc31e |
void *plugin_handle = dlopen (plugin_name, RTLD_LAZY);
|
|
|
5cc31e |
if (!plugin_handle)
|
|
|
5cc31e |
- goto dl_fail;
|
|
|
5cc31e |
+ return 0;
|
|
|
5cc31e |
|
|
|
5cc31e |
/* Check if all required functions are available in the plugin and store
|
|
|
5cc31e |
their handlers. None of the symbols can legitimately be NULL,
|