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