]> git.ipfire.org Git - thirdparty/gcc.git/commit
Driver: Add new -truncate option
authorPeter Damianov <peter0x44@disroot.org>
Sun, 28 Apr 2024 23:16:11 +0000 (16:16 -0700)
committerRichard Biener <rguenther@suse.de>
Thu, 2 May 2024 10:42:33 +0000 (12:42 +0200)
commit985b5a90f70c7376c771317c6c8c3bc5ef05e227
treeff83cb4fcf3dad9e3cf663ee1977aec3fa4c9047
parent5eb25d1561dd22316331feee92164f97ca79d1c3
Driver: Add new -truncate option

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.o
$ ./a.out
Hello world
$ du -h hello.o
$ 0   hello.o

$ 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.

Signed-off-by: Peter Damianov <peter0x44@disroot.org>
PR lto/110710
* common.opt (truncate): New internal option.
* gcc.cc (totruncate_file): New global.
(driver_handle_option): Handle -truncate <file>.
(driver::final_actions): Truncate the file indicated.
gcc/common.opt
gcc/gcc.cc