From: "Martin Liška" <mliska@suse.cz>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jan Hubicka <hubicka@ucw.cz>, Jeff Law <law@redhat.com>,
gcc-patches@gcc.gnu.org, Michael Matz <matz@suse.de>,
Richard Biener <richard.guenther@gmail.com>
Subject: [PATCH] Properly detect working jobserver in gcc driver.
Date: Thu, 01 Aug 2019 14:34:00 -0000 [thread overview]
Message-ID: <089f4b9d-a29a-5031-a272-e005cb5ce78c@suse.cz> (raw)
In-Reply-To: <20190801131932.GA2726@tucnak>
[-- Attachment #1: Type: text/plain, Size: 796 bytes --]
On 8/1/19 3:19 PM, Jakub Jelinek wrote:
> On Wed, Jul 31, 2019 at 05:00:37PM +0200, Martin Liška wrote:
>> On 7/31/19 12:01 PM, Martin Liška wrote:
>>> Anyway, the auto-detection of jobserver seems very ugly to me :/
>>> I tend to remove the support and start working on a proper implementation
>>> that can be used not only by make build system.
>>
>> Can you Jakub test the attached patch please?
>
> That works. I guess it didn't actually act as a fork-bomb because most of
> our lto tests are small and there aren't enough functions to create so many
> partitions.
>
> Jakub
>
Ok, after deeper discussion with Honza, I would like to suggest the original
patch that was about proper detection of jobserver.
Can you please Jakub test the patch in your environment?
Thanks,
Martin
[-- Attachment #2: 0001-Properly-detect-working-jobserver-in-gcc-driver.patch --]
[-- Type: text/x-patch, Size: 1804 bytes --]
From 0a7f15566dda99146784eb3f85e8b4547f2ab71c Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Thu, 1 Aug 2019 16:30:01 +0200
Subject: [PATCH] Properly detect working jobserver in gcc driver.
gcc/ChangeLog:
2019-08-01 Martin Liska <mliska@suse.cz>
PR lto/91313
* gcc.c (driver::maybe_run_linker): Test whether jobserver
is active from GCC driver. That will prevent situation where
GCC is invoked from a LD plugin and the linker already uses
file descriptors suggested by make. That leads to a wrong
detection.
---
gcc/gcc.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/gcc/gcc.c b/gcc/gcc.c
index a4323eb146e..fc11abf1f88 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -8268,6 +8268,39 @@ driver::maybe_run_linker (const char *argv0) const
{
int tmp = execution_count;
+ /* Detect jobserver and drop it if it's not working. */
+ const char *makeflags = env.get ("MAKEFLAGS");
+ if (makeflags != NULL)
+ {
+ const char *needle = "--jobserver-auth=";
+ const char *n = strstr (makeflags, needle);
+ if (n != NULL)
+ {
+ int rfd = -1;
+ int wfd = -1;
+
+ bool jobserver
+ = ((sscanf (n, "--jobserver-auth=%d,%d", &rfd, &wfd) == 2)
+ && rfd > 0
+ && wfd > 0
+ && fcntl (rfd, F_GETFD) >= 0
+ && fcntl (wfd, F_GETFD) >= 0);
+
+ /* Drop the jobserver if it's not working now. */
+ if (!jobserver)
+ {
+ unsigned offset = n - makeflags;
+ char *dup = xstrdup (makeflags);
+ dup[offset] = '\0';
+
+ const char *space = strchr (makeflags + offset, ' ');
+ if (space != NULL)
+ strcpy (dup + offset, space);
+ xputenv (concat ("MAKEFLAGS=", dup, NULL));
+ }
+ }
+ }
+
if (! have_c)
{
#if HAVE_LTO_PLUGIN > 0
--
2.22.0
next prev parent reply other threads:[~2019-08-01 14:34 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 8:55 [PATCH] Come up with -flto=auto option Martin Liška
2019-07-23 9:29 ` Jan Hubicka
2019-07-23 10:34 ` [PATCH] Deduce automatically number of cores for -flto option Martin Liška
2019-07-24 15:47 ` Jeff Law
2019-07-29 13:37 ` Martin Liška
2019-07-30 13:47 ` Martin Liška
2019-07-31 1:23 ` Jakub Jelinek
2019-07-31 7:24 ` Martin Liška
2019-07-31 7:40 ` Jakub Jelinek
2019-07-31 7:49 ` Jan Hubicka
2019-07-31 7:50 ` Martin Liška
2019-07-31 7:54 ` Martin Liška
2019-07-31 8:08 ` Jakub Jelinek
2019-07-31 8:21 ` Jan Hubicka
2019-07-31 8:37 ` Martin Liška
2019-07-31 9:12 ` Jakub Jelinek
2019-07-31 9:15 ` Jan Hubicka
2019-07-31 9:17 ` Jakub Jelinek
2019-07-31 9:22 ` Jan Hubicka
2019-07-31 10:02 ` Martin Liška
2019-07-31 12:02 ` Jan Hubicka
2019-07-31 15:42 ` Martin Liška
2019-08-01 13:19 ` Jakub Jelinek
2019-08-01 14:34 ` Martin Liška [this message]
2019-08-01 14:41 ` [PATCH] Properly detect working jobserver in gcc driver Jakub Jelinek
2019-08-02 6:30 ` Martin Liška
2019-08-02 7:45 ` Jakub Jelinek
2019-08-02 8:47 ` Martin Liška
2019-08-02 8:50 ` Jakub Jelinek
2019-08-02 9:04 ` Richard Biener
2019-08-02 9:08 ` Jan Hubicka
2019-08-02 9:15 ` Jan Hubicka
2019-08-02 9:19 ` Martin Liška
2019-08-02 9:55 ` Richard Biener
2019-08-05 6:41 ` Martin Liška
2019-08-09 8:14 ` Martin Liška
2019-08-09 8:22 ` Richard Biener
2019-08-09 12:51 ` Martin Liška
2019-08-09 13:56 ` Martin Liška
2019-08-12 15:18 ` Jeff Law
2019-07-23 13:13 ` [PATCH] Come up with -flto=auto option Jeff Law
2019-07-23 13:22 ` Richard Biener
2019-07-23 13:57 ` Michael Matz
2019-07-23 14:00 ` Jeff Law
2019-07-23 14:27 ` Martin Liška
2019-07-23 22:56 ` Jeff Law
2019-07-24 6:59 ` Martin Liška
2019-07-24 15:16 ` Jeff Law
2019-07-23 22:32 ` Allan Sandfeld Jensen
2019-07-24 6:47 ` Martin Liška
2019-07-24 7:12 ` Allan Sandfeld Jensen
2019-07-24 7:15 ` Martin Liška
2019-07-24 11:09 ` Nathan Sidwell
2019-07-24 15:46 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=089f4b9d-a29a-5031-a272-e005cb5ce78c@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=jakub@redhat.com \
--cc=law@redhat.com \
--cc=matz@suse.de \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).