From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 66DE63894432 for ; Thu, 22 Apr 2021 12:47:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 66DE63894432 Received: by mail-ed1-x52a.google.com with SMTP id z5so16786141edr.11 for ; Thu, 22 Apr 2021 05:47:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=rLj82gFaLLpmHIz6ehRjfNHx+kw/qtL7kfXP0r9jLmU=; b=Ye9t9ToDQSf33dGg9/O/pBVt4Rcn1Po8aJRZ2NIZdRvlo0nKQdEEuGHiQIC1xXQJC3 pHoAaD6rxjClTtrn6P0XLb5NsgIF6ZBS1aqfdcB15H0zdXwgcFOUEGIwgqxapMGkKOXE jRF0uVh8cJaw7sBCjYQ/y+aWGSTiEnnPuCnBLUPZSL9sDTJbnVp+1suo2fhDkzLVrugF 7/pdGG+GfALp0151kKPMRLSc0/3OO8mshCNVTHFUXxd8Pbin+9z+Md7B6vitAalfeRIw 1gScBDqGoUXf9qJcr2bWvZ0OBU46QngCNTMe4SToRZR++VXsPWr2d+oHWfi0HegC2ada 9jlg== X-Gm-Message-State: AOAM53262hYaspmHmaj/mCGTXiJzm0qfCmCyi8I9vmuQtE4cF72vs51m nf5DFwheRQ8xj5PFKwqn0zDBXa+X5fs48mtDEzMiX5GPPJA= X-Google-Smtp-Source: ABdhPJxgNSbdPbQ4PlK9WpPMt/G5p4ipzKuTC0xMoCwkvsg5SIiFNXIJ2JTMivUQoU85bSu+zCmRjalDC0rkoWDzwUM= X-Received: by 2002:aa7:db04:: with SMTP id t4mr3700657eds.274.1619095661456; Thu, 22 Apr 2021 05:47:41 -0700 (PDT) MIME-Version: 1.0 References: <11a45856-44b3-754d-5a42-19a348d0d59d@suse.cz> <8cc12cd9-fe88-f97b-eec2-d47f5342496d@suse.cz> In-Reply-To: From: Richard Biener Date: Thu, 22 Apr 2021 14:47:30 +0200 Message-ID: Subject: Re: [PATCH] LTO: fallback to -flto=N if -flto=jobserver does not work. To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Apr 2021 12:47:44 -0000 On Thu, Apr 22, 2021 at 2:21 PM Martin Li=C5=A1ka wrote: > > On 4/22/21 1:19 PM, Richard Biener wrote: > > On Thu, Apr 22, 2021 at 11:02 AM Martin Li=C5=A1ka wro= te: > >> > >> On 4/22/21 10:04 AM, Richard Biener wrote: > >>> On Wed, Apr 21, 2021 at 3:08 PM Martin Li=C5=A1ka wr= ote: > >>>> > >>>> When -flto=3Djobserver is used and we cannot detect job server, then= we can > >>>> still fallbackto -flto=3DN mode. > >>>> > >>>> Patch can bootstrap on x86_64-linux-gnu and survives regression test= s. > >>>> > >>>> Ready to be installed? > >>> > >>> I think this behavior needs to be documented - it falls back to a les= s > >>> conservative (possibly system overloading) mode - which IMHO is > >>> non-obvious and IMHO we shouldn't do. > >> > >> Sure, I'm sending corresponding patch. Note that it's quite common mis= take > >> that '+' is missing in Makefile rule. That was motivation for my chang= e. > > > > Sure, but that change won't get this fixed. > > It will as linker command line will contain (-flto=3Djobserver) and LTO w= ill fallback to -flto=3DN. > > > IMHO we should eventually > > emit diagnostic like > > > > warning: could not find jobserver, compiling N jobs serially > > > > once N > 1 (or 2?). > > We do that now (for all N): > lto-wrapper: warning: jobserver is not available: =E2=80=98MAKEFLAGS=E2= =80=99 environment variable is unset > > > > Likewise if people just use -flto and auto-detection > > finds nothing: > > -flto !=3D -flto=3Dauto > > Yes, -flto is a serial linking and we can emit a warning. I'd avoid warning if there's just a single ltrans unit. > > warning: using serial compilation of N LTRANS jobs > > note: refer to http://.... for how to use parallel compile > > > > using the URL diagnostics to point to -flto=3D... documentation. > > What about making that a proper warning (-Wlto)? We have diagnostics infr= astructure > that prints URL links. Note that drivers like lto-wrapper do not have fully initialized diagnostic machinery and use a "different" set of overloads (likewise gen* programs). > > > > That is, teach users rather than second-guessing and eventually > > blowing things up. IMHO only the jobserver mode is safe to > > automatically use. > > Well, -flto=3Dauto is also fine and document. I think there is no possibi= lity > auto CPU deduction can fail. So -flto=3Djobserver (with missing make job = server) > and -flto (equal to -flto=3D1) worth emitting a warning. > > What do you think? Yes, that sounds reasonable. I suspect that people might want to see -flto default to -flto=3Dauto but then I don't think that's good because th= ere's no system wide job scheduler limiting things (systemd-jobserver anyone?) Richard. > Martin > > > > > Richard. > > > >> Martin > >> > >>> > >>> Richard. > >>> > >>>> Thanks, > >>>> Martin > >>>> > >>>> gcc/ChangeLog: > >>>> > >>>> * lto-wrapper.c (run_gcc): When -flto=3Djobserver is used, b= ut the > >>>> makeserver cannot be detected, then use -flto=3DN fallback. > >>>> --- > >>>> gcc/lto-wrapper.c | 3 ++- > >>>> 1 file changed, 2 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c > >>>> index 03a5922f8ea..0b626d7c811 100644 > >>>> --- a/gcc/lto-wrapper.c > >>>> +++ b/gcc/lto-wrapper.c > >>>> @@ -1585,8 +1585,9 @@ run_gcc (unsigned argc, char *argv[]) > >>>> if (jobserver && jobserver_error !=3D NULL) > >>>> { > >>>> warning (0, jobserver_error); > >>>> - parallel =3D 0; > >>>> + /* Fall back to auto parallelism. */ > >>>> jobserver =3D 0; > >>>> + auto_parallel =3D 1; > >>>> } > >>>> else if (!jobserver && jobserver_error =3D=3D NULL) > >>>> { > >>>> -- > >>>> 2.31.1 > >>>> > >> >