public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/jobserver-refactoring)] lto: support --jobserver-style=fifo for recent GNU make
@ 2022-08-10  7:18 Martin Liska
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Liska @ 2022-08-10  7:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:83dd262301ec0b5df156e73990bf5854f5db358e

commit 83dd262301ec0b5df156e73990bf5854f5db358e
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Aug 9 13:59:36 2022 +0200

    lto: support --jobserver-style=fifo for recent GNU make
    
    gcc/ChangeLog:
    
            * jobserver.h (jobserver_info::jobserver_info): Parse FIFO
            format of --jobserver-auth.

Diff:
---
 gcc/jobserver.h | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/jobserver.h b/gcc/jobserver.h
index d57930ff7af..d073e5161a1 100644
--- a/gcc/jobserver.h
+++ b/gcc/jobserver.h
@@ -37,14 +37,22 @@ 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;
 };
 
 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)
@@ -53,8 +61,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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/marxin/heads/jobserver-refactoring)] lto: support --jobserver-style=fifo for recent GNU make
@ 2022-08-10 11:09 Martin Liska
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Liska @ 2022-08-10 11:09 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4a678594435e2133166fad7cdc7ed144205455ff

commit 4a678594435e2133166fad7cdc7ed144205455ff
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Aug 9 13:59:36 2022 +0200

    lto: support --jobserver-style=fifo for recent GNU make
    
    gcc/ChangeLog:
    
            * opts-jobserver.h: Add one member.
            * opts-common.cc (jobserver_info::jobserver_info): Parse FIFO
            format of --jobserver-auth.

Diff:
---
 gcc/opts-common.cc   | 17 +++++++++++++++--
 gcc/opts-jobserver.h |  2 ++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index 4d4f424df13..c2993f9140a 100644
--- a/gcc/opts-common.cc
+++ b/gcc/opts-common.cc
@@ -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)
diff --git a/gcc/opts-jobserver.h b/gcc/opts-jobserver.h
index 68ce188b84a..98ea2579962 100644
--- a/gcc/opts-jobserver.h
+++ b/gcc/opts-jobserver.h
@@ -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;
 };


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/marxin/heads/jobserver-refactoring)] lto: support --jobserver-style=fifo for recent GNU make
@ 2022-08-10  7:15 Martin Liska
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Liska @ 2022-08-10  7:15 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a6e24f7bf61a3b52b4d5f35255cec4db82b69173

commit a6e24f7bf61a3b52b4d5f35255cec4db82b69173
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Aug 9 13:59:36 2022 +0200

    lto: support --jobserver-style=fifo for recent GNU make
    
    gcc/ChangeLog:
    
            * jobserver.h (jobserver_info::jobserver_info): Parse FIFO
            format of --jobserver-auth.

Diff:
---
 gcc/jobserver.h | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/jobserver.h b/gcc/jobserver.h
index d57930ff7af..d073e5161a1 100644
--- a/gcc/jobserver.h
+++ b/gcc/jobserver.h
@@ -37,14 +37,22 @@ 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;
 };
 
 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)
@@ -53,8 +61,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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/marxin/heads/jobserver-refactoring)] lto: support --jobserver-style=fifo for recent GNU make
@ 2022-08-09 11:03 Martin Liska
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Liska @ 2022-08-09 11:03 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:34af8dad1c496dc03d8c5376aee209b2fcadc7b5

commit 34af8dad1c496dc03d8c5376aee209b2fcadc7b5
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Aug 8 15:22:44 2022 +0200

    lto: support --jobserver-style=fifo for recent GNU make
    
    gcc/ChangeLog:
    
            * jobserver.h (jobserver_info::jobserver_info): Parse FIFO
            format of --jobserver-auth.

Diff:
---
 gcc/jobserver.h | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/jobserver.h b/gcc/jobserver.h
index 85453dd3c79..856e326ddfc 100644
--- a/gcc/jobserver.h
+++ b/gcc/jobserver.h
@@ -39,14 +39,22 @@ 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;
 };
 
 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)
@@ -55,8 +63,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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gcc(refs/users/marxin/heads/jobserver-refactoring)] lto: support --jobserver-style=fifo for recent GNU make
@ 2022-08-09 10:59 Martin Liska
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Liska @ 2022-08-09 10:59 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:728d3c98868f798b0280b3b7fd5fb51638ca7718

commit 728d3c98868f798b0280b3b7fd5fb51638ca7718
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Aug 8 15:22:44 2022 +0200

    lto: support --jobserver-style=fifo for recent GNU make

Diff:
---
 gcc/jobserver.h | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/jobserver.h b/gcc/jobserver.h
index 85453dd3c79..856e326ddfc 100644
--- a/gcc/jobserver.h
+++ b/gcc/jobserver.h
@@ -39,14 +39,22 @@ 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;
 };
 
 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)
@@ -55,8 +63,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)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-10 11:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10  7:18 [gcc(refs/users/marxin/heads/jobserver-refactoring)] lto: support --jobserver-style=fifo for recent GNU make Martin Liska
  -- strict thread matches above, loose matches on Subject: below --
2022-08-10 11:09 Martin Liska
2022-08-10  7:15 Martin Liska
2022-08-09 11:03 Martin Liska
2022-08-09 10:59 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).