From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94659 invoked by alias); 9 Aug 2019 12:38:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 94650 invoked by uid 89); 9 Aug 2019 12:38:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy=slim, br X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Aug 2019 12:38:42 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 781EAAEBB; Fri, 9 Aug 2019 12:38:40 +0000 (UTC) Subject: Re: [PATCH] Properly detect working jobserver in gcc driver. To: Richard Biener Cc: Jan Hubicka , Jakub Jelinek , Jeff Law , GCC Patches , Michael Matz References: <20190801131932.GA2726@tucnak> <089f4b9d-a29a-5031-a272-e005cb5ce78c@suse.cz> <20190801144126.GC2726@tucnak> <20190802074450.GG2726@tucnak> <20190802085001.GK2726@tucnak> <20190802091543.spbiwrpkfgmc3wil@kam.mff.cuni.cz> <0221cd30-5ce4-624f-afe5-15525092821a@suse.cz> <4f1d75bf-7c75-6463-b8f1-9e37aab3f69a@suse.cz> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <142656c6-3e7d-0e45-f014-3cb4b1fda4f1@suse.cz> Date: Fri, 09 Aug 2019 12:51:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------8598875FFC4ECE70678C0F9C" X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00629.txt.bz2 This is a multi-part message in MIME format. --------------8598875FFC4ECE70678C0F9C Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 302 On 8/9/19 10:19 AM, Richard Biener wrote: > OK with that. I still think that making -flto use a jobserver if detected > (but _not_ use the number of CPU cores by default) makes > sense as an independent change. In order to address that, I'm suggesting following patch that I've been testing. Martin --------------8598875FFC4ECE70678C0F9C Content-Type: text/x-patch; name="0001-Automatically-detect-GNU-jobserver-with-flto.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Automatically-detect-GNU-jobserver-with-flto.patch" Content-length: 4574 >From 0f159f703fa2c918cfa75d5636f9b118b6ca1871 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 9 Aug 2019 14:03:11 +0200 Subject: [PATCH] Automatically detect GNU jobserver with -flto. config/ChangeLog: 2019-08-09 Martin Liska * bootstrap-lto-lean.mk: Remove -flto=jobserver and use only -flto. * bootstrap-lto-noplugin.mk: Likewise. * bootstrap-lto.mk: Likewise. gcc/ChangeLog: 2019-08-09 Martin Liska * doc/invoke.texi: Document automatic detection of jobserver. * lto-wrapper.c (run_gcc): Detect jobserver always. --- config/bootstrap-lto-lean.mk | 8 ++++---- config/bootstrap-lto-noplugin.mk | 10 +++++----- config/bootstrap-lto.mk | 10 +++++----- gcc/doc/invoke.texi | 3 ++- gcc/lto-wrapper.c | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/config/bootstrap-lto-lean.mk b/config/bootstrap-lto-lean.mk index 79cea50a4c6..9fbaef3f811 100644 --- a/config/bootstrap-lto-lean.mk +++ b/config/bootstrap-lto-lean.mk @@ -1,10 +1,10 @@ # This option enables LTO for stage4 and LTO for generators in stage3 with profiledbootstrap. # Otherwise, LTO is used in only stage3. -STAGE3_CFLAGS += -flto=jobserver -override STAGEtrain_CFLAGS := $(filter-out -flto=jobserver,$(STAGEtrain_CFLAGS)) -STAGEtrain_GENERATOR_CFLAGS += -flto=jobserver -STAGEfeedback_CFLAGS += -flto=jobserver +STAGE3_CFLAGS += -flto +override STAGEtrain_CFLAGS := $(filter-out -flto,$(STAGEtrain_CFLAGS)) +STAGEtrain_GENERATOR_CFLAGS += -flto +STAGEfeedback_CFLAGS += -flto # assumes the host supports the linker plugin LTO_AR = $$r/$(HOST_SUBDIR)/prev-gcc/gcc-ar$(exeext) -B$$r/$(HOST_SUBDIR)/prev-gcc/ diff --git a/config/bootstrap-lto-noplugin.mk b/config/bootstrap-lto-noplugin.mk index 0f50708e49d..592a75fba99 100644 --- a/config/bootstrap-lto-noplugin.mk +++ b/config/bootstrap-lto-noplugin.mk @@ -1,9 +1,9 @@ # This option enables LTO for stage2 and stage3 on # hosts without linker plugin support. -STAGE2_CFLAGS += -flto=jobserver -frandom-seed=1 -ffat-lto-objects -STAGE3_CFLAGS += -flto=jobserver -frandom-seed=1 -ffat-lto-objects -STAGEprofile_CFLAGS += -flto=jobserver -frandom-seed=1 -STAGEtrain_CFLAGS += -flto=jobserver -frandom-seed=1 -STAGEfeedback_CFLAGS += -flto=jobserver -frandom-seed=1 +STAGE2_CFLAGS += -flto -frandom-seed=1 -ffat-lto-objects +STAGE3_CFLAGS += -flto -frandom-seed=1 -ffat-lto-objects +STAGEprofile_CFLAGS += -flto -frandom-seed=1 +STAGEtrain_CFLAGS += -flto -frandom-seed=1 +STAGEfeedback_CFLAGS += -flto -frandom-seed=1 do-compare = /bin/true diff --git a/config/bootstrap-lto.mk b/config/bootstrap-lto.mk index 4de07e5b226..09084bd0b8e 100644 --- a/config/bootstrap-lto.mk +++ b/config/bootstrap-lto.mk @@ -1,10 +1,10 @@ # This option enables LTO for stage2 and stage3 in slim mode -STAGE2_CFLAGS += -flto=jobserver -frandom-seed=1 -STAGE3_CFLAGS += -flto=jobserver -frandom-seed=1 -STAGEprofile_CFLAGS += -flto=jobserver -frandom-seed=1 -STAGEtrain_CFLAGS += -flto=jobserver -frandom-seed=1 -STAGEfeedback_CFLAGS += -flto=jobserver -frandom-seed=1 +STAGE2_CFLAGS += -flto -frandom-seed=1 +STAGE3_CFLAGS += -flto -frandom-seed=1 +STAGEprofile_CFLAGS += -flto -frandom-seed=1 +STAGEtrain_CFLAGS += -flto -frandom-seed=1 +STAGEfeedback_CFLAGS += -flto -frandom-seed=1 # assumes the host supports the linker plugin LTO_AR = $$r/$(HOST_SUBDIR)/prev-gcc/gcc-ar$(exeext) -B$$r/$(HOST_SUBDIR)/prev-gcc/ diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 5b6b824bdd3..0000d358e48 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -10422,7 +10422,8 @@ job server mode to determine the number of parallel jobs. This is useful when the Makefile calling GCC is already executing in parallel. You must prepend a @samp{+} to the command recipe in the parent Makefile for this to work. This option likely only works if @env{MAKE} is -GNU make. +GNU make. Even without the option value, GCC tries to automatically +detect a running GNU make's job server. Use @option{-flto=auto} to use GNU make's job server, if available, or otherwise fall back to autodetection of the number of CPU threads diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c index 84f59cf1a1f..339c379d972 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -1427,7 +1427,7 @@ run_gcc (unsigned argc, char *argv[]) auto_parallel = 0; parallel = 0; } - else if (!jobserver && auto_parallel) + else if (!jobserver) jobserver = jobserver_active_p (); if (linker_output) -- 2.22.0 --------------8598875FFC4ECE70678C0F9C--