gcc/gcc11-foffload-default.patch

117 lines
4.1 KiB
Diff
Raw Normal View History

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