public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-742] Print warning diagnostics for -flto issues.
@ 2021-05-12  9:50 Martin Liska
  0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2021-05-12  9:50 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7d7d925d0d799eb9dda4a6bd6162af0a7db9c98b

commit r12-742-g7d7d925d0d799eb9dda4a6bd6162af0a7db9c98b
Author: Martin Liska <mliska@suse.cz>
Date:   Thu Apr 22 16:27:19 2021 +0200

    Print warning diagnostics for -flto issues.
    
    gcc/ChangeLog:
    
            * lto-wrapper.c (print_lto_docs_link): New function.
            (run_gcc): Print warning about missing job server detection
            after we know NR of partitions. Do the same for -flto{,=1}.
            * opts.c (get_option_html_page): Support -flto option.

Diff:
---
 gcc/lto-wrapper.c | 39 +++++++++++++++++++++++++++++++++++++--
 gcc/opts.c        |  6 +++++-
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 11d4d20c494..7931ae3fada 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "simple-object.h"
 #include "lto-section-names.h"
 #include "collect-utils.h"
+#include "opts-diagnostic.h"
 
 /* Environment variable, used for passing the names of offload targets from GCC
    driver to lto-wrapper.  */
@@ -1322,6 +1323,23 @@ jobserver_active_p (void)
     return JS_PREFIX "cannot access %<" JS_NEEDLE "%> file descriptors";
 }
 
+/* Print link to -flto documentation with a hint message.  */
+
+void
+print_lto_docs_link ()
+{
+  const char *url = get_option_url (NULL, OPT_flto);
+
+  pretty_printer pp;
+  pp.url_format = URL_FORMAT_DEFAULT;
+  pp_string (&pp, "see the ");
+  pp_begin_url (&pp, url);
+  pp_string (&pp, "%<-flto%> option documentation");
+  pp_end_url (&pp);
+  pp_string (&pp, " for more information");
+  inform (UNKNOWN_LOCATION, pp_formatted_text (&pp));
+}
+
 /* Test that a make command is present and working, return true if so.  */
 
 static bool
@@ -1356,8 +1374,10 @@ run_gcc (unsigned argc, char *argv[])
   char *collect_gcc_options;
   int parallel = 0;
   int jobserver = 0;
+  bool jobserver_requested = false;
   int auto_parallel = 0;
   bool no_partition = false;
+  const char *jobserver_error = NULL;
   vec<cl_decoded_option> fdecoded_options;
   fdecoded_options.create (16);
   vec<cl_decoded_option> offload_fdecoded_options = vNULL;
@@ -1502,6 +1522,7 @@ run_gcc (unsigned argc, char *argv[])
 	    {
 	      parallel = 1;
 	      jobserver = 1;
+	      jobserver_requested = true;
 	    }
 	  else if (strcmp (option->arg, "auto") == 0)
 	    {
@@ -1556,15 +1577,15 @@ run_gcc (unsigned argc, char *argv[])
     {
       lto_mode = LTO_MODE_LTO;
       jobserver = 0;
+      jobserver_requested = false;
       auto_parallel = 0;
       parallel = 0;
     }
   else
     {
-      const char *jobserver_error = jobserver_active_p ();
+      jobserver_error = jobserver_active_p ();
       if (jobserver && jobserver_error != NULL)
 	{
-	  warning (0, jobserver_error);
 	  /* Fall back to auto parallelism.  */
 	  jobserver = 0;
 	  auto_parallel = 1;
@@ -1879,6 +1900,20 @@ cont:
       maybe_unlink (ltrans_output_file);
       ltrans_output_file = NULL;
 
+      if (nr > 1)
+	{
+	  if (jobserver_requested && jobserver_error != NULL)
+	    {
+	      warning (0, jobserver_error);
+	      print_lto_docs_link ();
+	    }
+	  else if (parallel == 0)
+	    {
+	      warning (0, "using serial compilation of %d LTRANS jobs", nr);
+	      print_lto_docs_link ();
+	    }
+	}
+
       if (parallel)
 	{
 	  makefile = make_temp_file (".mk");
diff --git a/gcc/opts.c b/gcc/opts.c
index 24bb64198c8..fe6fddbf095 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -3243,9 +3243,13 @@ get_option_html_page (int option_index)
   const cl_option *cl_opt = &cl_options[option_index];
 
   /* Analyzer options are on their own page.  */
-  if (strstr(cl_opt->opt_text, "analyzer-"))
+  if (strstr (cl_opt->opt_text, "analyzer-"))
     return "gcc/Static-Analyzer-Options.html";
 
+  /* Handle -flto= option.  */
+  if (strstr (cl_opt->opt_text, "flto"))
+    return "gcc/Optimize-Options.html";
+
 #ifdef CL_Fortran
   if ((cl_opt->flags & CL_Fortran) != 0
       /* If it is option common to both C/C++ and Fortran, it is documented


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-12  9:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-12  9:50 [gcc r12-742] Print warning diagnostics for -flto issues Martin Liska

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).