From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id C0896385840B for ; Fri, 5 Aug 2022 10:58:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C0896385840B Received: by mail-ed1-x52c.google.com with SMTP id z2so2951976edc.1 for ; Fri, 05 Aug 2022 03:58:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=aKkG5zzibQTZcnCzQU5Gn0yyvHu48PPpN3oCwDsczEE=; b=MtNFNj0s0GpUOB3CfxZ+IUZ75CnXFDFZVfq2KexjfTClEuitJWCvgal89rqsm6/Pfp rO67qurLCmOVbXHedZ+WSvhx/x8rjRK4GbI48hQ5RRq7RhweniCLAJ5qEm4qHaNEOdG4 aqZBPOln/8BvuTpw1VVpfolmuefRc/KzLWBZURu2ZPGMV7gyy+aBI/6ZsqQK1kLh1UKe QFbvlR5l0PTyoprSm4M5qD/WMcHoevAFSW5ZBllVHC+AbuOi0/NLv5Irm/PKd+/h3DM/ tw1zSGfST60Q+7c36uumw7jzEAtgdJWZr1h5fReIBR4BVn20Q0uEYoIV+AqTtBKAiWxC jj4A== X-Gm-Message-State: ACgBeo1u3vTiLCOJiubICkG9D5LPSj+aCMXgMZ0kmDvoy2wNFbWlsYCQ yX3Q96LvkffIfWUjaoaQD4hDrhBZ83pVtiTL7ic= X-Google-Smtp-Source: AA6agR4CYlZRrvzsIrpLnOd/TimxrjZfo85RE10JsaDpiZTQ+o2LfZQiGjCK0dHaAXkgKr0iLBZ3GqKR341U0u1vkhc= X-Received: by 2002:a05:6402:2b98:b0:43e:107:183d with SMTP id fj24-20020a0564022b9800b0043e0107183dmr6173468edb.366.1659697123275; Fri, 05 Aug 2022 03:58:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Richard Biener Date: Fri, 5 Aug 2022 12:58:31 +0200 Message-ID: Subject: Re: [PATCH] lto: support --jobserver-style=fifo for recent GNU make To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: GCC Patches , Jan Hubicka Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.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, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Fri, 05 Aug 2022 10:58:46 -0000 On Thu, Aug 4, 2022 at 10:57 AM Martin Li=C5=A1ka wrote: > > After a long time, GNU make has finally implemented named pipes when > it comes to --jobserver-auth. The traditional approach are > provided opened file descriptors that causes troubles: > https://savannah.gnu.org/bugs/index.php?57242 > > GNU make commit: > https://git.savannah.gnu.org/cgit/make.git/commit/?id=3D7ad2593b2d2bb5b93= 32f4444d8bf93ac6f958bc6 > > I tested that locally with TOT GNU make and it works: > > $ cat Makefile > all: > g++ tramp3d-v4.ii -c -flto -O2 > g++ tramp3d-v4.o -flto=3Djobserver > > $ MAKE=3D/tmp/bin/bin/make /tmp/bin/bin/make -j16 --jobserver-style=3Dfif= o > g++ tramp3d-v4.ii -c -flto -O2 > g++ tramp3d-v4.o -flto=3Djobserver > (ltrans run in parallel) > > Ready to be installed after tests? LGTM. Thanks, Richard. > Martin > > gcc/ChangeLog: > > * gcc.cc (driver::detect_jobserver): Support --jobserver-style=3D= fifo. > * lto-wrapper.cc (jobserver_active_p): Likewise. > --- > gcc/gcc.cc | 15 ++++++++++++--- > gcc/lto-wrapper.cc | 20 +++++++++++++++----- > 2 files changed, 27 insertions(+), 8 deletions(-) > > diff --git a/gcc/gcc.cc b/gcc/gcc.cc > index 5cbb38560b2..c98407fe03d 100644 > --- a/gcc/gcc.cc > +++ b/gcc/gcc.cc > @@ -9182,15 +9182,24 @@ driver::detect_jobserver () const > const char *makeflags =3D env.get ("MAKEFLAGS"); > if (makeflags !=3D NULL) > { > - const char *needle =3D "--jobserver-auth=3D"; > - const char *n =3D strstr (makeflags, needle); > + /* Traditionally, GNU make uses opened pieps for jobserver-auth, > + e.g. --jobserver-auth=3D3,4. */ > + const char *pipe_needle =3D "--jobserver-auth=3D"; > + > + /* Starting with GNU make 4.4, one can use --jobserver-style=3Dfif= o > + and then named pipe is used: --jobserver-auth=3Dfifo:/tmp/hcspar= ta. */ > + const char *fifo_needle =3D "--jobserver-auth=3Dfifo:"; > + if (strstr (makeflags, fifo_needle) !=3D NULL) > + return; > + > + const char *n =3D strstr (makeflags, pipe_needle); > if (n !=3D NULL) > { > int rfd =3D -1; > int wfd =3D -1; > > bool jobserver > - =3D (sscanf (n + strlen (needle), "%d,%d", &rfd, &wfd) =3D=3D= 2 > + =3D (sscanf (n + strlen (pipe_needle), "%d,%d", &rfd, &wfd) = =3D=3D 2 > && rfd > 0 > && wfd > 0 > && is_valid_fd (rfd) > diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc > index 795ab74555c..756350d5ace 100644 > --- a/gcc/lto-wrapper.cc > +++ b/gcc/lto-wrapper.cc > @@ -1342,27 +1342,37 @@ static const char * > jobserver_active_p (void) > { > #define JS_PREFIX "jobserver is not available: " > - #define JS_NEEDLE "--jobserver-auth=3D" > + > + /* Traditionally, GNU make uses opened pieps for jobserver-auth, > + e.g. --jobserver-auth=3D3,4. */ > + #define JS_PIPE_NEEDLE "--jobserver-auth=3D" > + > + /* Starting with GNU make 4.4, one can use --jobserver-style=3Dfifo > + and then named pipe is used: --jobserver-auth=3Dfifo:/tmp/hcsparta.= */ > + #define JS_FIFO_NEEDLE "--jobserver-auth=3Dfifo:" > > const char *makeflags =3D getenv ("MAKEFLAGS"); > if (makeflags =3D=3D NULL) > return JS_PREFIX "% environment variable is unset"; > > - const char *n =3D strstr (makeflags, JS_NEEDLE); > + if (strstr (makeflags, JS_FIFO_NEEDLE) !=3D NULL) > + return NULL; > + > + const char *n =3D strstr (makeflags, JS_PIPE_NEEDLE); > if (n =3D=3D NULL) > - return JS_PREFIX "%<" JS_NEEDLE "%> is not present in %"= ; > + return JS_PREFIX "%<" JS_PIPE_NEEDLE "%> is not present in %"; > > int rfd =3D -1; > int wfd =3D -1; > > - if (sscanf (n + strlen (JS_NEEDLE), "%d,%d", &rfd, &wfd) =3D=3D 2 > + if (sscanf (n + strlen (JS_PIPE_NEEDLE), "%d,%d", &rfd, &wfd) =3D=3D 2 > && rfd > 0 > && wfd > 0 > && is_valid_fd (rfd) > && is_valid_fd (wfd)) > return NULL; > else > - return JS_PREFIX "cannot access %<" JS_NEEDLE "%> file descriptors"; > + return JS_PREFIX "cannot access %<" JS_PIPE_NEEDLE "%> file descript= ors"; > } > > /* Print link to -flto documentation with a hint message. */ > -- > 2.37.1 >