From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by sourceware.org (Postfix) with ESMTPS id 69E663834682 for ; Thu, 18 Apr 2024 06:26:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69E663834682 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 69E663834682 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::22c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713421589; cv=none; b=Sa0IocHwBXAJFRB3SLVgNtJqcpn7pZ+QcMlJyGvIPYQymD4jXpJLJOYv+EDAo+XcI+VTBgIUHoNtJyRNcex8h96JbHWrRznvNz4I8s3950M0B8h6JOselHfI+0n5IxrAfTr91wROI1G7UHZ0CaYXLBw/xS1NhKkvsKBG9bf9T0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713421589; c=relaxed/simple; bh=KSNrQrq4yFDaU1hTC9sSVmLVwlnln5e5nSwTxhIbEgE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=xRQ/lUFfgDm8xLY6aoGKqGZCwh+8l99nHX0jdpMsTvMlF8bSbo7NyNlekPBZjngqsSAHNF8eaT6ltQGz7kcUihA4RSLhbBU6FTp3Mh159Mv5VkW3o7V4uSPx+Ursh2fyyWUJt0bFbOn23xnKzvJbIsudAPBfdoKJub0KSWcOlA4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2d895e2c6efso5989811fa.0 for ; Wed, 17 Apr 2024 23:26:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713421586; x=1714026386; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Q2ncGi+9VY/aMx2OzmA94Zmyg0msWW9HYdjm3oTNStA=; b=KTBIaVJoF00jBmWVuAYc9S8gLG/Ktl2gt3C/a1oAHN3AMSryF7E66wGB1ay8xD5equ bFP8bAoAWpErSiMamLwT/OYF4TOSR8DnbkJ1vvM+eMJ65PmD/dw4dhYIuI7UR5SO1jYc hLbd6jNo6GqosUjgTAHbDTOJjfXwnyMdsW6gxUO4wufExItztflgxisOaFI/nQNHdvng sX0MRjPAjxVwF+JsftI7cIPdLQVsal/F5gaarODRIBeiChPMGosyTCRN8Ufmsh2UG4VJ D5qHN6Nt3QCzOttkyGRviKUuebtBRHMwvngNZJrtVlR90Mh3SIiD+XYaPm0vpwBGEiE5 h1sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713421586; x=1714026386; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q2ncGi+9VY/aMx2OzmA94Zmyg0msWW9HYdjm3oTNStA=; b=ikKhV7Lekc3ZLW8Vb3NUxxDAmJzCKF1bydsZIdhBX9csQIfGAYJV9bJ3oRFHOriIOs IjUXMva/sof7xWm3HQxWQDAUEhcxQ0IlEBCefUvdlQ1OS+HKsvVbwHHnrqZb8hh1Y10+ 2wgSCpppIzLB0PRwuxT+sXNqrZABM3RTKdRA5Htumy3aThFs///ODilAd0j4Q9ISbBCP qQdqYtH2wsvIhmP264UEFG2Clz0WrNuTrY1YRD1UU01l+DjXxNzhEOFxHzF3maGRtOxE 8yvKI3FOlike4R4DOGYwuGSWitvJhHvHavge8406wXK9FZaVBd5bHGsxmtNv5cuEnuwa 15ZA== X-Gm-Message-State: AOJu0YwFRF09QLiRKjmk6TmXY2KphESX981YRxictlylFXNWZ5cgXTg0 D/nkWjoHkZVoewnd2UbqFdtPNE7SoBMNIlZQ6wAYcC5xLZAouJIMwrAR7Ftj1Xh8lOhWyokI40o WHmQFQ5cb78WWY4kiy9c7dzfRnpI= X-Google-Smtp-Source: AGHT+IFj6AYtaq6V4xF8/14PzoOcn9D8YMx/x9UssjseXEipM0cwJvACWHsdzjdgnHCyIrkE3cihgb8jtUfXSpISPpY= X-Received: by 2002:a2e:7c09:0:b0:2d2:6193:6d53 with SMTP id x9-20020a2e7c09000000b002d261936d53mr720822ljc.13.1713421585545; Wed, 17 Apr 2024 23:26:25 -0700 (PDT) MIME-Version: 1.0 References: <20240418040912.6236-1-peter0x44@disroot.org> In-Reply-To: <20240418040912.6236-1-peter0x44@disroot.org> From: Richard Biener Date: Thu, 18 Apr 2024 08:26:14 +0200 Message-ID: Subject: Re: [PATCH v2 1/2] Driver: Add new -truncate option To: Peter Damianov Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.7 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Apr 18, 2024 at 6:12=E2=80=AFAM Peter Damianov wrote: > > This commit adds a new option to the driver that truncates one file after > linking. > > Tested likeso: > > $ gcc hello.c -c > $ du -h hello.o > 4.0K hello.o > $ gcc hello.o -truncate hello > $ ./a.out > Hello world > $ du -h hello.o > $ 0 hello.o I suppose it should have been $ gcc hello.o -truncate hello.o in the example. > $ gcc hello.o -truncate > gcc: error: missing filename after '-truncate' > > The motivation for adding this is PR110710. It is used by lto-wrapper to > truncate files in a shell-independent manner. This looks good to me. Thanks, Richard. > Signed-off-by: Peter Damianov > --- > v2: moved truncation to driver::final_actions > v2: moved handling of OPT_truncate to be in alphabetic order > > gcc/common.opt | 6 ++++++ > gcc/gcc.cc | 13 +++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/gcc/common.opt b/gcc/common.opt > index ad348844775..40cab3cb36a 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -422,6 +422,12 @@ Display target specific command line options (includ= ing assembler and linker opt > -time > Driver Alias(time) > > +;; Truncate the file specified after linking. > +;; This option is used by lto-wrapper to reduce the peak disk-usage when > +;; linking with many .LTRANS units. > +truncate > +Driver Separate Undocumented MissingArgError(missing filename after %qs) > + > -verbose > Driver Alias(v) > > diff --git a/gcc/gcc.cc b/gcc/gcc.cc > index 728332b8153..b4169bbd3be 100644 > --- a/gcc/gcc.cc > +++ b/gcc/gcc.cc > @@ -2138,6 +2138,10 @@ static int have_E =3D 0; > /* Pointer to output file name passed in with -o. */ > static const char *output_file =3D 0; > > +/* Pointer to input file name passed in with -truncate. > + This file should be truncated after linking. */ > +static const char *totruncate_file =3D 0; > + > /* This is the list of suffixes and codes (%g/%u/%U/%j) and the associat= ed > temp file. If the HOST_BIT_BUCKET is used for %j, no entry is made f= or > it here. */ > @@ -4538,6 +4542,10 @@ driver_handle_option (struct gcc_options *opts, > do_save =3D false; > break; > > + case OPT_truncate: > + totruncate_file =3D arg; > + break; > + > case OPT____: > /* "-###" > This is similar to -v except that there is no execution > @@ -9286,6 +9294,11 @@ driver::final_actions () const > delete_failure_queue (); > delete_temp_files (); > > + if (totruncate_file !=3D NULL && !seen_error ()) > + /* Truncate file specified by -truncate. > + Used by lto-wrapper to reduce temporary disk-space usage. */ > + truncate(totruncate_file, 0); > + > if (print_help_list) > { > printf (("\nFor bug reporting instructions, please see:\n")); > -- > 2.39.2 >