Re: [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
Hi, On Thu, 10 Oct 2019, David Malcolm wrote: > This patch uses the support for pretty-printing escaped URLs added in > the previous patch (PR 87488) so that in a sufficiently capable terminal > the [-Wname-of-option] emitted at the end of each diagnostic becomes a > hyperlink to the documentation for that option on the GCC website. > > I've tested it with Fedora 30's GNOME Terminal (3.32.2 with VTE 0.56.3); > the option text is printed with a dotted underline, hovering shows the > URL, and on right-clicking it offers menu items to visit/copy the URL. I don't think you can enable this by default as long as even the gist page only claims that 8 of 22 terminal emulators support this (and among those not supporting it are xterm, and all default terminal emulators of desktop environment other than GNOME). screen and tmux don't support it either, and the konsole feature request for this has a discussion about problems with the design from a security p.o.v. so there will probably be emulators that never implement this. That there's no way of detecting the capability, and, worse, that the normal default behaviour of terminals is to ignore unknown OCS sequences (which means that you don't see the URL but only the replacement text) also means information loss. Tieing the hyperlinks default capability to the colorize capability is bad as well, because colorization is an old concept, and better yet, supported by terminfo and termcap capabilities (hence can be translated meaningfully by terminal multiplexers), unlike the hyperlinking. So, for the above reasons IMHO the default can only be false. Ciao, Michael. > > Successfully bootstrapped on x86_64-pc-linux-gnu. > > Committed to trunk as r276843. > > gcc/ChangeLog: > PR 87488 > * Makefile.in (CFLAGS-opts.o): Pass in DOCUMENTATION_ROOT_URL via > -D. > * configure.ac (--with-documentation-root-url): New option. > * configure: Regenerate. > * diagnostic-format-json.cc (json_end_diagnostic): If there is an > option URL, add it as a new string field of the diagnostic option. > * diagnostic.c (diagnostic_initialize): Initialize get_option_url. > (print_option_information): If get_option_url is non-NULL, call > it, and if the result is non-NULL, potentially emit an escape > sequence to markup the option text with the resulting URL. > * diagnostic.h (diagnostic_context::get_option_url): New callback. > * doc/invoke.texi (-fdiagnostics-format=): Add "option_url" to > example of JSON output. > * opts-diagnostic.h (get_option_url): New decl. > * opts.c (get_option_url): New function. > * toplev.c (general_init): Initialize the get_option_url callback. > > gcc/testsuite/ChangeLog: > PR 87488 > * c-c++-common/diagnostic-format-json-2.c: Expect an "option_url" > field. > * c-c++-common/diagnostic-format-json-3.c: Likewise. > * gfortran.dg/diagnostic-format-json-2.F90: Likewise. > * gfortran.dg/diagnostic-format-json-3.F90: Likewise. > * jit.dg/test-error-array-bounds.c (create_code): Ensure that > error messages don't contain escaped URLs. > --- > gcc/Makefile.in | 2 ++ > gcc/configure.ac| 14 ++ > gcc/diagnostic-format-json.cc | 11 +++ > gcc/diagnostic.c| 12 > gcc/diagnostic.h| 6 ++ > gcc/doc/invoke.texi | 1 + > gcc/opts-diagnostic.h | 3 +++ > gcc/opts.c | 21 > + > .../c-c++-common/diagnostic-format-json-2.c | 1 + > .../c-c++-common/diagnostic-format-json-3.c | 1 + > .../c-c++-common/diagnostic-format-json-4.c | 10 -- > .../gfortran.dg/diagnostic-format-json-2.F90| 1 + > .../gfortran.dg/diagnostic-format-json-3.F90| 1 + > gcc/testsuite/jit.dg/test-error-array-bounds.c | 5 +++-- > gcc/toplev.c| 1 + > 15 files changed, 86 insertions(+), 4 deletions(-) > > diff --git a/gcc/Makefile.in b/gcc/Makefile.in > index 59adfaa..c82858f 100644 > --- a/gcc/Makefile.in > +++ b/gcc/Makefile.in > @@ -2142,6 +2142,8 @@ lto-wrapper$(exeext): $(LTO_WRAPPER_OBJS) > libcommon-target.a $(LIBDEPS) > $(LTO_WRAPPER_OBJS) libcommon-target.a $(LIBS) > mv -f T$@ $@ > > +CFLAGS-opts.o += -DDOCUMENTATION_ROOT_URL=\"@DOCUMENTATION_ROOT_URL@\" > + > # Files used by all variants of C or by the stand-alone pre-processor. > > CFLAGS-c-family/c-opts.o += @TARGET_SYSTEM_ROOT_DEFINE@ > diff --git a/gcc/configure.ac b/gcc/configure.ac > index 54a6715..62f4b26 100644 > --- a/gcc/configure.ac > +++ b/gcc/configure.ac > @@ -960,6 +960,20 @@ AC_SUBST(CONFIGURE_SPECS) >
Re: [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
On Sat, Oct 12, 2019 at 10:21:56AM -0400, David Malcolm wrote: > It seems like instead it's displaying this: > > https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local-Wshadow=local%1B]8 That's what it does for me (well, with weird escapes at both ends). And if run inside a tmux it just shows what you wanted to show, but there is no way to click it: the URL is not displayed at all. > What happens if you try this at the terminal: > > printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' In gnome term it shows a bunch of funny escapes. In xterm it just displays "This is a link", without any way to click it, like in the tmux scenario. The links are wrong btw, they should be version-specific? > I don't yet know if there's a way to query the terminal to see if the > escape is supported. My hope was that they would be silently > discarded. Just display the URL if you want this? That works, and has always worked, and many terminals have convenient ways to use that (have had that since forever, too). Can we have this *off* by default, please? The warnings are getting way too verbose. Often one warning does not fit on one screen already! > > Do you see a way to find out if the escape sequences are supported, > > or how to disable this function per configure option? > > Do you mean a GCC configure-time option to change the default? We have > that for colors; Do we? I've had GCC_COLORS= since forever; is this finally not needed anymore? Neat :-) Now just ASAN_OPTIONS=color=never TSAN_OPTIONS=color=never by default and there is a bit of sanity again. > Is this working/broken for other people? I've only tried your example so far, and that does not work :-( Segher
Re: [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
On 10/12/19 4:21 PM, David Malcolm wrote: > On Sat, 2019-10-12 at 07:00 +, Bernd Edlinger wrote: >> Hi David, >> >> I just wanted to say that this does not work right on ubuntu 14.04 at >> least: >> >> g++ -Wshadow=local -Wno-shadow=compatible-local -S Wshadow-1.c >> Wshadow-1.c: In function 'void foo(int*, int*)': >> Wshadow-1.c:8:9: warning: declaration of 'int d' shadows a parameter >> []8;; >> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local-Wshadow=local]8 >> ;;] >> 8 | int d = 0; /* { dg-warning "Wshadow=local" } >> */ >> | ^ >> Wshadow-1.c:4:23: note: shadowed declaration is here >> 4 | void foo(int *c, int *d) /* { dg-bogus "Wshadow" } */ >> | ~^ >> Wshadow-1.c: In function 'void bar(int*, int*)': >> Wshadow-1.c:15:15: warning: declaration of 'c' shadows a global >> declaration []8;; >> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8 >> ;;] >>15 | void bar(int *c, int *d) /* { dg-warning "Wshadow" } */ >> | ~^ >> Wshadow-1.c:3:5: note: shadowed declaration is here >> 3 | int c; >> | ^ >> Wshadow-1.c:19:9: warning: declaration of 'int d' shadows a parameter >> []8;; >> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8 >> ;;] >>19 | int d = 0; /* { dg-warning "Wshadow" } */ >> | ^ >> Wshadow-1.c:15:23: note: shadowed declaration is here >>15 | void bar(int *c, int *d) /* { dg-warning "Wshadow" } */ >> | ~^ >> Wshadow-1.c:22:10: warning: declaration of 'e' shadows a previous >> local []8;; >> https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8 >> ;;] >>22 | int *e = 0;/* { dg-warning "Wshadow" } */ >> | ^ >> Wshadow-1.c:17:8: note: shadowed declaration is here >>17 | int *e = d; >> |^ >> >> Coloring works, even the hyperlinks seem to work, when clicked at, >> although they jump just >> to the top of the page, and one has to scroll down to the warning >> manually. >> But the warning name is very hard to spot in all that glibberish long >> text :-( > > Thanks for the report. > > Bother. > > There are (at least) two issues here. > > (a) It sounds like your terminal doesn't handle the escape sequence my > patch is emitting. The expected outcome is that the terminal embeds > this URL: > > https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local > > within: > > [-Wshadow=local] > > i.e. equivalent to: > > [https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local; > ;;] > > It seems like instead it's displaying this: > > https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local-Wshadow=local%1B]8 > > When you say "even the hyperlinks seem to work" it seems like that URL > fragment is being handled by the terminal's regular "look for URLs in > the text" logic. > > Does your terminal have a "Copy URL" option (perhaps on a right-click > menu)? If so, what URL is copied? > Yes, the URL is "https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow; > Which terminal (and version) are you seeing this with? (if gnome > terminal, which vte version?) > I think the process that hosts the "Terminal" is /usr/bin/xfce4-terminal The a Help/About menu says: xfce4-terminal 0.6.3 > What happens if you try this at the terminal: > > printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' > I see this: ]8;;http://example.comThis is a link]8;; the ] is actually a little square with little 0101 in it. again the URL is copied. This time it is "http://example.comThis; > (hopefully that doesn't get mangled by my mailer; this is the example > from: > https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda > ) > Both show the same info. > I don't yet know if there's a way to query the terminal to see if the > escape is supported. My hope was that they would be silently > discarded. > I wonder why this is not done with a ncurses function? In case it helps this is the environment I have: $ export declare -x CLUTTER_IM_MODULE="xim" declare -x COLORTERM="xfce4-terminal" declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-Wh3VZkTGvf" declare -x DEFAULTS_PATH="/usr/share/gconf/ubuntustudio.default.path" declare -x DESKTOP_SESSION="ubuntustudio" declare -x DISPLAY=":0.0" declare -x GDMSESSION="ubuntustudio" declare -x GDM_LANG="de_DE" declare -x GLADE_CATALOG_PATH=":" declare -x GLADE_MODULE_PATH=":" declare -x GLADE_PIXMAP_PATH=":" declare -x GNOME_KEYRING_CONTROL="/run/user/1000/keyring-V870cQ" declare -x GNOME_KEYRING_PID="1770" declare -x GPG_AGENT_INFO="/run/user/1000/keyring-V870cQ/gpg:0:1" declare -x GTK_IM_MODULE="xim" declare -x HOME="/home/ed" declare -x IM_CONFIG_PHASE="1" declare -x INSTANCE="" declare -x JOB="dbus" declare -x
Re: [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
On Sat, 2019-10-12 at 07:00 +, Bernd Edlinger wrote: > Hi David, > > I just wanted to say that this does not work right on ubuntu 14.04 at > least: > > g++ -Wshadow=local -Wno-shadow=compatible-local -S Wshadow-1.c > Wshadow-1.c: In function 'void foo(int*, int*)': > Wshadow-1.c:8:9: warning: declaration of 'int d' shadows a parameter > []8;; > https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local-Wshadow=local]8 > ;;] > 8 | int d = 0; /* { dg-warning "Wshadow=local" } > */ > | ^ > Wshadow-1.c:4:23: note: shadowed declaration is here > 4 | void foo(int *c, int *d) /* { dg-bogus "Wshadow" } */ > | ~^ > Wshadow-1.c: In function 'void bar(int*, int*)': > Wshadow-1.c:15:15: warning: declaration of 'c' shadows a global > declaration []8;; > https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8 > ;;] >15 | void bar(int *c, int *d) /* { dg-warning "Wshadow" } */ > | ~^ > Wshadow-1.c:3:5: note: shadowed declaration is here > 3 | int c; > | ^ > Wshadow-1.c:19:9: warning: declaration of 'int d' shadows a parameter > []8;; > https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8 > ;;] >19 | int d = 0; /* { dg-warning "Wshadow" } */ > | ^ > Wshadow-1.c:15:23: note: shadowed declaration is here >15 | void bar(int *c, int *d) /* { dg-warning "Wshadow" } */ > | ~^ > Wshadow-1.c:22:10: warning: declaration of 'e' shadows a previous > local []8;; > https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8 > ;;] >22 | int *e = 0;/* { dg-warning "Wshadow" } */ > | ^ > Wshadow-1.c:17:8: note: shadowed declaration is here >17 | int *e = d; > |^ > > Coloring works, even the hyperlinks seem to work, when clicked at, > although they jump just > to the top of the page, and one has to scroll down to the warning > manually. > But the warning name is very hard to spot in all that glibberish long > text :-( Thanks for the report. Bother. There are (at least) two issues here. (a) It sounds like your terminal doesn't handle the escape sequence my patch is emitting. The expected outcome is that the terminal embeds this URL: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local within: [-Wshadow=local] i.e. equivalent to: [https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local; ;;] It seems like instead it's displaying this: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local-Wshadow=local%1B]8 When you say "even the hyperlinks seem to work" it seems like that URL fragment is being handled by the terminal's regular "look for URLs in the text" logic. Does your terminal have a "Copy URL" option (perhaps on a right-click menu)? If so, what URL is copied? Which terminal (and version) are you seeing this with? (if gnome terminal, which vte version?) What happens if you try this at the terminal: printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' (hopefully that doesn't get mangled by my mailer; this is the example from: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda ) I don't yet know if there's a way to query the terminal to see if the escape is supported. My hope was that they would be silently discarded. > Do you see a way to find out if the escape sequences are supported, > or how to disable this function per configure option? Do you mean a GCC configure-time option to change the default? We have that for colors; we could add one for URLs. (Though I'd prefer to know more about the scope of the problem first) The other problem: (b) The URL itself is wrong; for this option it ought to be: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow (i.e. without the "=local"). As noted by Manu it sounds like the implementation needs to be smarter about generating URLs. Thanks again for the report. Is this working/broken for other people? Thanks Dave
Re: [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
Hi David, I just wanted to say that this does not work right on ubuntu 14.04 at least: g++ -Wshadow=local -Wno-shadow=compatible-local -S Wshadow-1.c Wshadow-1.c: In function 'void foo(int*, int*)': Wshadow-1.c:8:9: warning: declaration of 'int d' shadows a parameter []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow=local-Wshadow=local]8;;] 8 | int d = 0; /* { dg-warning "Wshadow=local" } */ | ^ Wshadow-1.c:4:23: note: shadowed declaration is here 4 | void foo(int *c, int *d) /* { dg-bogus "Wshadow" } */ | ~^ Wshadow-1.c: In function 'void bar(int*, int*)': Wshadow-1.c:15:15: warning: declaration of 'c' shadows a global declaration []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8;;] 15 | void bar(int *c, int *d) /* { dg-warning "Wshadow" } */ | ~^ Wshadow-1.c:3:5: note: shadowed declaration is here 3 | int c; | ^ Wshadow-1.c:19:9: warning: declaration of 'int d' shadows a parameter []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8;;] 19 | int d = 0; /* { dg-warning "Wshadow" } */ | ^ Wshadow-1.c:15:23: note: shadowed declaration is here 15 | void bar(int *c, int *d) /* { dg-warning "Wshadow" } */ | ~^ Wshadow-1.c:22:10: warning: declaration of 'e' shadows a previous local []8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wshadow-Wshadow]8;;] 22 | int *e = 0;/* { dg-warning "Wshadow" } */ | ^ Wshadow-1.c:17:8: note: shadowed declaration is here 17 | int *e = d; |^ Coloring works, even the hyperlinks seem to work, when clicked at, although they jump just to the top of the page, and one has to scroll down to the warning manually. But the warning name is very hard to spot in all that glibberish long text :-( Do you see a way to find out if the escape sequences are supported, or how to disable this function per configure option? Thanks Bernd.
Re: [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
On 10/10/19, Manuel López-Ibáñez wrote: > Hi David, > > While I agree that this is quite cool to have, the following: > >> +/* DOCUMENTATION_ROOT_URL should be supplied via -D by the Makefile >> + (see --with-documentation-root-url). >> + >> + Expect an anchor of the form "index-Wfoo" e.g. >> + , and thus an id within >> + the URL of "#index-Wformat". */ >> +return concat (DOCUMENTATION_ROOT_URL, >> + "Warning-Options.html", >> + "#index", cl_options[option_index].opt_text, >> + NULL); > > will not work for many -W options: > > https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options > (scroll to the bottom) > > https://gcc.gnu.org/onlinedocs/gcc/Objective-C-and-Objective-C_002b_002b-Dialect-Options.html#Objective-C-and-Objective-C_002b_002b-Dialect-Options > (scroll to the bottom) > > https://gcc.gnu.org/onlinedocs/gcc-9.2.0/cpp/Invocation.html#index-Wcomment > > https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/Error-and-Warning-Options.html#Error-and-Warning-Options > > I would argue that some options are documented in the wrong place (I think all > C/C++ -W options should just go to Warning-Options.html), That's bug 71283, for reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71283 > but I also believe the HTML page should be language dependent. > > Cheers, > > Manuel. > >
Re: [PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
Hi David, While I agree that this is quite cool to have, the following: +/* DOCUMENTATION_ROOT_URL should be supplied via -D by the Makefile + (see --with-documentation-root-url). + + Expect an anchor of the form "index-Wfoo" e.g. + , and thus an id within + the URL of "#index-Wformat". */ +return concat (DOCUMENTATION_ROOT_URL, + "Warning-Options.html", + "#index", cl_options[option_index].opt_text, + NULL); will not work for many -W options: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options (scroll to the bottom) https://gcc.gnu.org/onlinedocs/gcc/Objective-C-and-Objective-C_002b_002b-Dialect-Options.html#Objective-C-and-Objective-C_002b_002b-Dialect-Options (scroll to the bottom) https://gcc.gnu.org/onlinedocs/gcc-9.2.0/cpp/Invocation.html#index-Wcomment https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gfortran/Error-and-Warning-Options.html#Error-and-Warning-Options I would argue that some options are documented in the wrong place (I think all C/C++ -W options should just go to Warning-Options.html), but I also believe the HTML page should be language dependent. Cheers, Manuel.
[PATCH 2/2] Documentation hyperlinks for [-Wname-of-option] (PR 87488)
This patch uses the support for pretty-printing escaped URLs added in the previous patch (PR 87488) so that in a sufficiently capable terminal the [-Wname-of-option] emitted at the end of each diagnostic becomes a hyperlink to the documentation for that option on the GCC website. I've tested it with Fedora 30's GNOME Terminal (3.32.2 with VTE 0.56.3); the option text is printed with a dotted underline, hovering shows the URL, and on right-clicking it offers menu items to visit/copy the URL. Successfully bootstrapped on x86_64-pc-linux-gnu. Committed to trunk as r276843. gcc/ChangeLog: PR 87488 * Makefile.in (CFLAGS-opts.o): Pass in DOCUMENTATION_ROOT_URL via -D. * configure.ac (--with-documentation-root-url): New option. * configure: Regenerate. * diagnostic-format-json.cc (json_end_diagnostic): If there is an option URL, add it as a new string field of the diagnostic option. * diagnostic.c (diagnostic_initialize): Initialize get_option_url. (print_option_information): If get_option_url is non-NULL, call it, and if the result is non-NULL, potentially emit an escape sequence to markup the option text with the resulting URL. * diagnostic.h (diagnostic_context::get_option_url): New callback. * doc/invoke.texi (-fdiagnostics-format=): Add "option_url" to example of JSON output. * opts-diagnostic.h (get_option_url): New decl. * opts.c (get_option_url): New function. * toplev.c (general_init): Initialize the get_option_url callback. gcc/testsuite/ChangeLog: PR 87488 * c-c++-common/diagnostic-format-json-2.c: Expect an "option_url" field. * c-c++-common/diagnostic-format-json-3.c: Likewise. * gfortran.dg/diagnostic-format-json-2.F90: Likewise. * gfortran.dg/diagnostic-format-json-3.F90: Likewise. * jit.dg/test-error-array-bounds.c (create_code): Ensure that error messages don't contain escaped URLs. --- gcc/Makefile.in | 2 ++ gcc/configure.ac| 14 ++ gcc/diagnostic-format-json.cc | 11 +++ gcc/diagnostic.c| 12 gcc/diagnostic.h| 6 ++ gcc/doc/invoke.texi | 1 + gcc/opts-diagnostic.h | 3 +++ gcc/opts.c | 21 + .../c-c++-common/diagnostic-format-json-2.c | 1 + .../c-c++-common/diagnostic-format-json-3.c | 1 + .../c-c++-common/diagnostic-format-json-4.c | 10 -- .../gfortran.dg/diagnostic-format-json-2.F90| 1 + .../gfortran.dg/diagnostic-format-json-3.F90| 1 + gcc/testsuite/jit.dg/test-error-array-bounds.c | 5 +++-- gcc/toplev.c| 1 + 15 files changed, 86 insertions(+), 4 deletions(-) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 59adfaa..c82858f 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2142,6 +2142,8 @@ lto-wrapper$(exeext): $(LTO_WRAPPER_OBJS) libcommon-target.a $(LIBDEPS) $(LTO_WRAPPER_OBJS) libcommon-target.a $(LIBS) mv -f T$@ $@ +CFLAGS-opts.o += -DDOCUMENTATION_ROOT_URL=\"@DOCUMENTATION_ROOT_URL@\" + # Files used by all variants of C or by the stand-alone pre-processor. CFLAGS-c-family/c-opts.o += @TARGET_SYSTEM_ROOT_DEFINE@ diff --git a/gcc/configure.ac b/gcc/configure.ac index 54a6715..62f4b26 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -960,6 +960,20 @@ AC_SUBST(CONFIGURE_SPECS) ACX_PKGVERSION([GCC]) ACX_BUGURL([https://gcc.gnu.org/bugs/]) +# Allow overriding the default URL for documentation +AC_ARG_WITH(documentation-root-url, +AS_HELP_STRING([--with-documentation-root-url=URL], + [Root for documentation URLs]), +[case "$withval" in + yes) AC_MSG_ERROR([documentation root URL not specified]) ;; + no) AC_MSG_ERROR([documentation root URL not specified]) ;; + *) DOCUMENTATION_ROOT_URL="$withval" + ;; + esac], + DOCUMENTATION_ROOT_URL="https://gcc.gnu.org/onlinedocs/gcc/; +) +AC_SUBST(DOCUMENTATION_ROOT_URL) + # Sanity check enable_languages in case someone does not run the toplevel # configure # script. AC_ARG_ENABLE(languages, diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc index 53c3b63..eb99952 100644 --- a/gcc/diagnostic-format-json.cc +++ b/gcc/diagnostic-format-json.cc @@ -154,6 +154,17 @@ json_end_diagnostic (diagnostic_context *context, diagnostic_info *diagnostic, free (option_text); } + if (context->get_option_url) +{ + char *option_url = context->get_option_url (context, + diagnostic->option_index); + if (option_url) + { +