]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Print warning diagnostics for -flto issues.
authorMartin Liska <mliska@suse.cz>
Thu, 22 Apr 2021 14:27:19 +0000 (16:27 +0200)
committerMartin Liska <mliska@suse.cz>
Wed, 12 May 2021 09:48:35 +0000 (11:48 +0200)
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.

gcc/lto-wrapper.c
gcc/opts.c

index 11d4d20c494299c730cb9bad93df42a257a5ba73..7931ae3fadab4e912790a443c8af4e03539ba8f5 100644 (file)
@@ -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");
index 24bb64198c890ac11727be69af685949e10c781b..fe6fddbf095d27e340b96195692c4dbd3360525a 100644 (file)
@@ -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