From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from layka.disroot.org (layka.disroot.org [178.21.23.139]) by sourceware.org (Postfix) with ESMTPS id BFE703858D39 for ; Thu, 18 Apr 2024 08:26:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFE703858D39 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=disroot.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=disroot.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BFE703858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=178.21.23.139 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713428806; cv=none; b=HJVxj0uQP1orqV4GqIOTYAKJ4HEjDv4n1MDVQrXyLzKlfrcqAqEVHNPCPRrZt4THK1y5oT69nfNCd48tlbHQs34zDZDD6O9PT0HGmbwOyV9UhluH5NdStj30RjHVNIDbfEfsOk13n7dqU+mNbvDAw+4esQ4GNncJ3IZILUjPZp0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713428806; c=relaxed/simple; bh=eu+cPS0PNTRNyXU7V7tzVWl6QiQlLRZxD97wFAV5xrk=; h=Date:DKIM-Signature:From:To:Message-ID:Subject:MIME-Version; b=fsrrpqr+PbK6eeK4JlOpOvgsPyr/6b7GV19xE1dQXhKNHtaRlNFo7uL5AIE8hyZzZ8CG2eDDBAvutW1sSY+xj9oOp+eZUVDjx89GixYrJfEjVRPQ9aILhlGnp4A+D17DWSJQUG09VpTmGsdbOz1uYMY/zUNxqfL/X/KYdO0SdwY= ARC-Authentication-Results: i=1; server2.sourceware.org X-Virus-Scanned: SPAM Filter at disroot.org Date: Thu, 18 Apr 2024 09:26:38 +0100 (GMT+01:00) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1713428798; bh=eu+cPS0PNTRNyXU7V7tzVWl6QiQlLRZxD97wFAV5xrk=; h=Date:From:To:In-Reply-To:References:Subject; b=MkQPveM/70deXZVD2S/EGFfQqR9hRHMWq5ovtGaKWKTjKAM/NuhL5KyzUeXf+jf1W 1Bm7ONkR8JXM+ZAXUfPtNOpEqZOLL5C4vARif2D2HnyAWueJjcp5hxV6u6IdBs9mIF x3s9ZPeWuA6gfnPNB3pgd4YCxiy3cuDLOaJF9bpglw0bmise6xwTUDJtMDgXy7zDs2 D+KZfJjbTEAtx5tGhBV6GzY6pa2glx/uZ2kDgkeQ5h7Nvih1i+lzNH52ZvsNAajy93 28anzYh0842Zy/laDJ/ChI4vkAiYIQhc3gA76nlogimLV9lv0SqdQVUdSl51FF+5Ie ilmiYBnkm2P3g== From: Peter0x44 To: Richard Biener , gcc-patches@gcc.gnu.org Message-ID: <5858176e-a8bb-4a04-acfd-41732c682f89@disroot.org> In-Reply-To: References: <20240418040912.6236-1-peter0x44@disroot.org> Subject: Re: [PATCH v2 1/2] Driver: Add new -truncate option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Correlation-ID: <5858176e-a8bb-4a04-acfd-41732c682f89@disroot.org> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: 18 Apr 2024 7:26:27 am Richard Biener : > On Thu, Apr 18, 2024 at 6:12=E2=80=AFAM Peter Damianov =20 > wrote: >> >> This commit adds a new option to the driver that truncates one file=20 >> after >> linking. >> >> Tested likeso: >> >> $ gcc hello.c -c >> $ du -h hello.o >> 4.0K=C2=A0 hello.o >> $ gcc hello.o -truncate hello >> $ ./a.out >> Hello world >> $ du -h hello.o >> $ 0=C2=A0=C2=A0 hello.o > > I suppose it should have been > > $ gcc hello.o -truncate hello.o > > in the example. Correct. Sorry about that. > >> $ gcc hello.o -truncate >> gcc: error: missing filename after '-truncate' >> >> The motivation for adding this is PR110710. It is used by lto-wrapper=20 >> 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 |=C2=A0 6 ++++++ >> gcc/gcc.cc=C2=A0=C2=A0=C2=A0=C2=A0 | 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=20 >> (including 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=20 >> when >> +;; linking with many .LTRANS units. >> +truncate >> +Driver Separate Undocumented MissingArgError(missing filename after=20 >> %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. >> +=C2=A0=C2=A0 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=20 >> associated >> =C2=A0=C2=A0=C2=A0 temp file.=C2=A0 If the HOST_BIT_BUCKET is used for %= j, no entry is=20 >> made for >> =C2=A0=C2=A0=C2=A0 it here.=C2=A0 */ >> @@ -4538,6 +4542,10 @@ driver_handle_option (struct gcc_options *opts, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 do_save =3D false; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >> >> +=C2=A0=C2=A0=C2=A0 case OPT_truncate: >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 totruncate_file =3D arg; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >> + >> =C2=A0=C2=A0=C2=A0=C2=A0 case OPT____: >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* "-###" >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 This is similar to -v e= xcept that there is no execution >> @@ -9286,6 +9294,11 @@ driver::final_actions () const >> =C2=A0=C2=A0=C2=A0=C2=A0 delete_failure_queue (); >> =C2=A0=C2=A0 delete_temp_files (); >> >> +=C2=A0 if (totruncate_file !=3D NULL && !seen_error ()) >> +=C2=A0=C2=A0=C2=A0 /* Truncate file specified by -truncate. >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Used by lto-wrapper to reduce temp= orary disk-space usage. */ >> +=C2=A0=C2=A0=C2=A0 truncate(totruncate_file, 0); >> + >> =C2=A0=C2=A0 if (print_help_list) >> =C2=A0=C2=A0=C2=A0=C2=A0 { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 printf (("\nFor bug reporting instr= uctions, please see:\n")); >> -- >> 2.39.2 >>