On Mon, Jun 28, 2021 at 05:51:30PM +0200, Tobias Burnus wrote:
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
I think it would be better to commit the reorderings in invoke.texi
separately from the -foffload* changes, because otherwise people will keep
wondering what actually really changed.
It can go in before or after (and please take into account Sandra's
review comments).
> --- a/gcc/gcc.c
> +++ b/gcc/gcc.c
> @@ -3977,6 +3977,68 @@ driver_wrong_lang_callback (const struct
> cl_decoded_option *decoded,
> static const char *spec_lang = 0;
> static int last_language_n_infiles;
>
> +
> +/* Check that GCC is configured to support the offload target. */
> +
> +static void
> +check_offload_target_name (const char *target, ptrdiff_t len)
> +{
> + const char *n, *c = OFFLOAD_TARGETS;
> + char *target2 = NULL;
> + while (c)
> + {
> + n = strchr (c, ',');
> + if (n == NULL)
> + n = strchr (c, '\0');
> + if (len == n - c && strncmp (target, c, n - c) == 0)
> + break;
> + c = *n ? n + 1 : NULL;
> + }
> + if (!c)
> + {
> + if (target[len] != '\0')
> + {
> + target2 = XNEWVEC (char, len + 1);
> + memcpy (target2, target, len);
> + target2[len] = '\0';
> + }
> + fatal_error (input_location,
> + "GCC is not configured to support %qs as offload target",
> + target2 ? target2 : target);
Can't this be done without target2 with
fatal_error (input_location,
"GCC is not configured to support %q.*s as offload target",
len, target);
instead, regardless if target[len] is 0 or not?
The message should be consistent between this function and
handle_foffload_option
(on the q in particular).
Also, wonder if we shouldn't print the list of configured targets in that
case, see candidates_list_and_hint functions and its callers.
And it is unclear why we use fatal_error, can't unknown offload target names
be simply ignored after emitting error?
> + XDELETEVEC (target2);
> + }
> +}
> +
> +/* Sanity check for -foffload-options. */
> +
> +static void
> +check_foffload_target_names (const char *arg)
> +{
> + const char *cur, *next, *end;
> + /* If option argument starts with '-' then no target is specified and we
> + do not need to parse it. */
> + if (arg[0] == '-')
> + return;
> + end = strchr (arg, '=');
> + if (end == NULL)
> + {
> + error ("%<=options%> missing after %<-foffload-options=target%>");
Neither options nor target are keywords, so IMHO those shouldn't appear in
between
%< and %> but after the %>, so
"%<=%>options missing after %%<-foffload-options=%>target"
?
Otherwise LGTM.
Jakub