]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lto: support --jobserver-style=fifo for recent GNU make
authorMartin Liska <mliska@suse.cz>
Tue, 9 Aug 2022 11:59:36 +0000 (13:59 +0200)
committerMartin Liska <mliska@suse.cz>
Wed, 10 Aug 2022 11:12:23 +0000 (13:12 +0200)
gcc/ChangeLog:

* opts-jobserver.h: Add one member.
* opts-common.cc (jobserver_info::jobserver_info): Parse FIFO
format of --jobserver-auth.

gcc/opts-common.cc
gcc/opts-jobserver.h

index 4d4f424df13f386daacbec3efd42f6b8fd3de1b9..c2993f9140a8808cb271fe6900637841f3445b0a 100644 (file)
@@ -2010,8 +2010,14 @@ void prepend_xassembler_to_collect_as_options (const char *collect_as_options,
 
 jobserver_info::jobserver_info ()
 {
+  /* Traditionally, GNU make uses opened pipes for jobserver-auth,
+    e.g. --jobserver-auth=3,4.
+    Starting with GNU make 4.4, one can use --jobserver-style=fifo
+    and then named pipe is used: --jobserver-auth=fifo:/tmp/hcsparta.  */
+
   /* Detect jobserver and drop it if it's not working.  */
   string js_needle = "--jobserver-auth=";
+  string fifo_prefix = "fifo:";
 
   const char *envval = getenv ("MAKEFLAGS");
   if (envval != NULL)
@@ -2020,8 +2026,15 @@ jobserver_info::jobserver_info ()
       size_t n = makeflags.rfind (js_needle);
       if (n != string::npos)
        {
-         if (sscanf (makeflags.c_str () + n + js_needle.size (),
-                     "%d,%d", &rfd, &wfd) == 2
+         string ending = makeflags.substr (n + js_needle.size ());
+         if (ending.find (fifo_prefix) == 0)
+           {
+             ending = ending.substr (fifo_prefix.size ());
+             pipe_path = ending.substr (0, ending.find (' '));
+             is_active = true;
+           }
+         else if (sscanf (makeflags.c_str () + n + js_needle.size (),
+                          "%d,%d", &rfd, &wfd) == 2
              && rfd > 0
              && wfd > 0
              && is_valid_fd (rfd)
index 68ce188b84a5ca3e1c4ba8088ad3ea718fe9228f..98ea2579962643aee512b410fc9161ff201a45e0 100644 (file)
@@ -37,6 +37,8 @@ struct jobserver_info
   int rfd = -1;
   /* File descriptor for writing used for jobserver communication.  */
   int wfd = -1;
+  /* Named pipe path.  */
+  string pipe_path = "";
   /* Return true if jobserver is active.  */
   bool is_active = false;
 };