* [Patch] gcc.c: Add -foffload= to display_help
@ 2021-06-30 12:24 Tobias Burnus
2021-06-30 12:26 ` Jakub Jelinek
2021-06-30 12:43 ` RFC: --help for Driver options (was: [Patch] gcc.c: Add -foffload= to display_help) Tobias Burnus
0 siblings, 2 replies; 4+ messages in thread
From: Tobias Burnus @ 2021-06-30 12:24 UTC (permalink / raw)
To: gcc-patches, Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 396 bytes --]
This is a side effect of removing 'foffload=' from Common
as Driver only does not show up with --help=... but only
as hard-coded list via display_help.
OK?
Tobias
PS: additional remarks in the next email.
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
[-- Attachment #2: helpfix.diff --]
[-- Type: text/x-patch, Size: 1569 bytes --]
gcc.c: Add -foffload= to display_help
gcc/ChangeLog:
* common.opt (foffload): Remove help as Driver only.
* gcc.c (display_help): Add -foffload.
diff --git a/gcc/common.opt b/gcc/common.opt
index 2f5ff9f02e9..5b03bbc6662 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -2100,11 +2100,8 @@ fnon-call-exceptions
Common Var(flag_non_call_exceptions) Optimization
Support synchronous non-call exceptions.
-; -foffload=<targets> is documented
-; -foffload=<targets>=<options> is supported for backward compatibility
foffload=
Driver Joined MissingArgError(targets missing after %qs)
--foffload=<targets> Specify offloading targets.
foffload-options=
Common Driver Joined MissingArgError(options or targets=options missing after %qs)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index f802148e567..c8dbff61307 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3752,6 +3752,7 @@ display_help (void)
fputs (_(" -dumpspecs Display all of the built in spec strings.\n"), stdout);
fputs (_(" -dumpversion Display the version of the compiler.\n"), stdout);
fputs (_(" -dumpmachine Display the compiler's target processor.\n"), stdout);
+ fputs (_(" -foffload=<targets> Specify offloading targets.\n"), stdout);
fputs (_(" -print-search-dirs Display the directories in the compiler's search path.\n"), stdout);
fputs (_(" -print-libgcc-file-name Display the name of the compiler's companion library.\n"), stdout);
fputs (_(" -print-file-name=<lib> Display the full path to library <lib>.\n"), stdout);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Patch] gcc.c: Add -foffload= to display_help
2021-06-30 12:24 [Patch] gcc.c: Add -foffload= to display_help Tobias Burnus
@ 2021-06-30 12:26 ` Jakub Jelinek
2021-06-30 12:43 ` RFC: --help for Driver options (was: [Patch] gcc.c: Add -foffload= to display_help) Tobias Burnus
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2021-06-30 12:26 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches
On Wed, Jun 30, 2021 at 02:24:51PM +0200, Tobias Burnus wrote:
> This is a side effect of removing 'foffload=' from Common
> as Driver only does not show up with --help=... but only
> as hard-coded list via display_help.
>
> OK?
>
> Tobias
>
> PS: additional remarks in the next email.
>
> -----------------
> Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
> gcc.c: Add -foffload= to display_help
>
> gcc/ChangeLog:
>
> * common.opt (foffload): Remove help as Driver only.
> * gcc.c (display_help): Add -foffload.
Ok, thanks.
Jakub
^ permalink raw reply [flat|nested] 4+ messages in thread
* RFC: --help for Driver options (was: [Patch] gcc.c: Add -foffload= to display_help)
2021-06-30 12:24 [Patch] gcc.c: Add -foffload= to display_help Tobias Burnus
2021-06-30 12:26 ` Jakub Jelinek
@ 2021-06-30 12:43 ` Tobias Burnus
2021-06-30 18:08 ` Joseph Myers
1 sibling, 1 reply; 4+ messages in thread
From: Tobias Burnus @ 2021-06-30 12:43 UTC (permalink / raw)
To: gcc-patches, Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 2082 bytes --]
RFC for this topic. Comments are welcome as is someone volunteering to
cleanup this mess :-)
On 30.06.21 14:24, Tobias Burnus wrote:
> This is a side effect of removing 'foffload=' from Common
> as Driver only does not show up with --help=... but only
> as hard-coded list via display_help.
While looking at that issue, Jakub and I wondered whether there
should be some warning if a Driver option has a help text,
which never appears.
Jakub mentioned
-dumpdir
but that's also in Common and, hence, shows up with
--help=common
but admittedly not with --help
* * *
However, the following items are Drivar and neither LTO, C, Fortran nor
Common and do have a help text (that never shows up).
(Extracted with the first attached patch, as we wondered whether a
warning could make sense.)
* Those appear with --help as they have a puts line in gcc.c's display_help():
common.opt no-pie
common.opt pie
common.opt shared
common.opt static-pie
* While those don't but they also cannot be added to gcc.c
as they are FE specific driver options:
c-family/c.opt static-libmpx
c-family/c.opt static-libmpxwrappers
common.opt foffload=
d/lang.opt debuglib=
d/lang.opt defaultlib=
d/lang.opt dstartfiles
d/lang.opt nophoboslib
d/lang.opt shared-libphobos
d/lang.opt static-libphobos
* * *
Additionally, I was wondering whether having --help=driver makes sense.
That I tried with the following patch, but it looks as if I missed some
fineprint as Driver-only flags were still not printed, if I recall
correctly.
BTW: -help='s helptext differs between the hard-coded one in gcc.c
(used by --help) and the one in common.opt (shown, e.g., by --help=common).
Even with that patch applied, --help= does not really have a useful
error message while --help=something-invalid has.
Tobias
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf
[-- Attachment #2: driver-help.diff --]
[-- Type: text/x-patch, Size: 897 bytes --]
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 880ac776d8a..d63407c5c88 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -275,6 +275,25 @@ for (i = 0; i < n_opts; i++) {
indices[opts[i]] = j;
}
j++;
+ if (help[i] != "" && flag_set_p("Driver", flags[i]) \
+ && !flag_set_p("Common", flags[i])) {
+ nflags = split(switch_flags(flags[i]), flag_array, " | ")
+ help_warn = 1
+ for (j = 0; j < nflags; j++) {
+ if (flag_array[j] != "" \
+ && flag_array[j] != "|" \
+ && flag_array[j] != "CL_DRIVER" \
+ && flag_array[j] != "CL_SEPARATE" \
+ && flag_array[j] != "CL_JOINED" \
+ && flag_array[j] != "CL_UNDOCUMENTED") {
+ help_warn = 0
+ }
+ }
+ if (help_warn != 0)
+ print "#warning Help text provided for Driver only " \
+ "option '" opts[i] "' move it to gcc.c's " \
+ "display_help: " help[i]
+ }
}
optindex = 0
[-- Attachment #3: opts.diff --]
[-- Type: text/x-patch, Size: 3975 bytes --]
diff --git a/gcc/opts.c b/gcc/opts.c
index f159bb35130..df5e2462d76 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1815,7 +1815,9 @@ print_specific_help (unsigned int include_flags,
{
if (any_flags == 0)
{
- if (include_flags & CL_UNDOCUMENTED)
+ if (include_flags & CL_DRIVER)
+ description = _("The following options control the driver");
+ else if (include_flags & CL_UNDOCUMENTED)
description = _("The following options are not documented");
else if (include_flags & CL_SEPARATE)
description = _("The following options take separate arguments");
@@ -2276,30 +2278,38 @@ print_help (struct gcc_options *opts, unsigned int lang_mask,
if (lang_mask == CL_DRIVER)
return;
+ static const struct
+ {
+ const char *string;
+ unsigned int flag;
+ }
+ specifics[] =
+ {
+ { "common", CL_COMMON },
+ { "driver", CL_DRIVER },
+ { "joined", CL_JOINED },
+ { "optimizers", CL_OPTIMIZATION },
+ { "params", CL_PARAMS },
+ { "separate", CL_SEPARATE },
+ { "target", CL_TARGET },
+ { "undocumented", CL_UNDOCUMENTED },
+ { "warnings", CL_WARNING },
+ { NULL, 0 }
+ };
+
+ auto_vec <const char *> candidates;
+ for (unsigned int i = 0; specifics[i].string != NULL; i++)
+ candidates.safe_push (specifics[i].string);
+ for (unsigned int i = 0; i < cl_lang_count; i++)
+ candidates.safe_push (lang_names[i]);
+
/* Walk along the argument string, parsing each word in turn.
The format is:
arg = [^]{word}[,{arg}]
- word = {optimizers|target|warnings|undocumented|
- params|common|<language>} */
+ word = {common|driver|joined|optimizers|params|separate
+ |target|undocumented|warnings|<language>} */
while (*a != 0)
{
- static const struct
- {
- const char *string;
- unsigned int flag;
- }
- specifics[] =
- {
- { "optimizers", CL_OPTIMIZATION },
- { "target", CL_TARGET },
- { "warnings", CL_WARNING },
- { "undocumented", CL_UNDOCUMENTED },
- { "params", CL_PARAMS },
- { "joined", CL_JOINED },
- { "separate", CL_SEPARATE },
- { "common", CL_COMMON },
- { NULL, 0 }
- };
unsigned int *pflags;
const char *comma;
unsigned int lang_flag, specific_flag;
@@ -2311,7 +2321,11 @@ print_help (struct gcc_options *opts, unsigned int lang_mask,
++a;
if (*a == '\0')
{
+ char *s;
error ("missing argument to %qs", "--help=^");
+ candidates_list_and_hint ("", s, candidates);
+ inform (UNKNOWN_LOCATION, "valid arguments to %qs are: %s", "--help=^", s);
+ XDELETEVEC (s);
break;
}
pflags = &exclude_flags;
@@ -2365,18 +2379,38 @@ print_help (struct gcc_options *opts, unsigned int lang_mask,
if (strncasecmp (a, "c", len) == 0)
*pflags |= lang_flag;
else
- warning (0,
- "%<--help%> argument %q.*s is ambiguous, "
- "please be more specific",
- len, a);
+ {
+ char *s;
+ warning (0,
+ "%<--help%> argument %q.*s is ambiguous, "
+ "please be more specific",
+ len, a);
+ candidates_list_and_hint ("", s, candidates);
+ inform (UNKNOWN_LOCATION,
+ "valid arguments to %qs are: %s", "--help=", s);
+ XDELETEVEC (s);
+ }
}
}
else if (lang_flag != 0)
*pflags |= lang_flag;
else
- warning (0,
- "unrecognized argument to %<--help=%> option: %q.*s",
- len, a);
+ {
+ char *s;
+ char *arg = XALLOCAVEC (char, len + 1);
+ memcpy (arg, a, len);
+ arg[len] = '\0';
+ warning (0, "unrecognized argument to %<--help=%> option: %qs", arg);
+ const char *hint = candidates_list_and_hint (arg, s, candidates);
+ if (hint)
+ inform (UNKNOWN_LOCATION,
+ "valid arguments to %qs are: %s; did you mean %qs?",
+ "--help", s, hint);
+ else
+ inform (UNKNOWN_LOCATION,
+ "valid arguments to %qs are: %s", "--help=", s);
+ XDELETEVEC (s);
+ }
if (comma == NULL)
break;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFC: --help for Driver options (was: [Patch] gcc.c: Add -foffload= to display_help)
2021-06-30 12:43 ` RFC: --help for Driver options (was: [Patch] gcc.c: Add -foffload= to display_help) Tobias Burnus
@ 2021-06-30 18:08 ` Joseph Myers
0 siblings, 0 replies; 4+ messages in thread
From: Joseph Myers @ 2021-06-30 18:08 UTC (permalink / raw)
To: Tobias Burnus; +Cc: gcc-patches, Jakub Jelinek
On Wed, 30 Jun 2021, Tobias Burnus wrote:
> While looking at that issue, Jakub and I wondered whether there
> should be some warning if a Driver option has a help text,
> which never appears.
Migrating from hardcoded help text in gcc.c to using .opt help text for
Driver options to generate --help output might be a good idea.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-30 18:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30 12:24 [Patch] gcc.c: Add -foffload= to display_help Tobias Burnus
2021-06-30 12:26 ` Jakub Jelinek
2021-06-30 12:43 ` RFC: --help for Driver options (was: [Patch] gcc.c: Add -foffload= to display_help) Tobias Burnus
2021-06-30 18:08 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).