From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1851) id 15C95385740E; Wed, 10 Aug 2022 11:09:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15C95385740E Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Liska To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/marxin/heads/jobserver-refactoring)] lto: support --jobserver-style=fifo for recent GNU make X-Act-Checkin: gcc X-Git-Author: Martin Liska X-Git-Refname: refs/users/marxin/heads/jobserver-refactoring X-Git-Oldrev: 6f3abcb3fa26f6ed719450f6bc70b2b37179973a X-Git-Newrev: 4a678594435e2133166fad7cdc7ed144205455ff Message-Id: <20220810110915.15C95385740E@sourceware.org> Date: Wed, 10 Aug 2022 11:09:15 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2022 11:09:15 -0000 https://gcc.gnu.org/g:4a678594435e2133166fad7cdc7ed144205455ff commit 4a678594435e2133166fad7cdc7ed144205455ff Author: Martin Liska 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; };