On Thu, Jul 26, 2018 at 2:12 PM Martin Liška <mli...@suse.cz> wrote: > > On 07/26/2018 01:34 PM, Richard Biener wrote: > > On Thu, Jul 26, 2018 at 12:55 PM Martin Liška <mli...@suse.cz> wrote: > >> > >> Hi. > >> > >> As requested in the PR, now we produce prefixes for temp files in LTO: > >> > >> Example: > >> $ gcc -flto main.o a.o --save-temps -o mybinary > >> > >> generates: > >> $ ls /tmp/mybinary* > >> /tmp/mybinary /tmp/mybinary.ltrans0.o /tmp/mybinary.ltrans0.s > >> /tmp/mybinary.ltrans.out > > > > It will be /tmp/mybinary.abc421.ltrans0.o > > /tmp/mybinary.abc421.ltrans1.o, etc., correct? > > Yes, --save-temps changes which file names are used. Before patch: > > $ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep > ltrans > [pid 23926] > execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", > ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", > "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", > "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", > "-fno-openmp", "-fno-openacc", > "-fltrans-output-list=/tmp/ccPVzNR6.ltrans.out", "-fwpa", > "-fresolution=/tmp/ccuocrhY.res", "-flinker-output=exec", "@/tmp/ccHQA575"], > 0x7fffffffd960 /* 105 vars */ <unfinished ...> > [pid 23928] > execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", > ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", > "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", > "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", > "/tmp/ccPVzNR6.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", > "@/tmp/ccssDdS8", "-o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 vars */ > <unfinished ...> > [pid 23929] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", > "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 > vars */) = -1 ENOENT (No such file or directory) > [pid 23929] execve("/home/marxin/bin/as", ["as", "--64", "-o", > "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 > vars */) = -1 ENOENT (No such file or directory) > [pid 23929] execve("/usr/local/bin/as", ["as", "--64", "-o", > "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 > vars */) = -1 ENOENT (No such file or directory) > [pid 23929] execve("/usr/bin/as", ["as", "--64", "-o", > "/tmp/ccPVzNR6.ltrans0.ltrans.o", "/tmp/cclsKY4G.s"], 0x7fffffffd960 /* 105 > vars */ <unfinished ...> > > after: > > $ strace -f -s512 gcc -flto a.o main.o -o mybinary 2>&1 | grep execv | grep > ltrans > [pid 16379] > execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", > ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", > "-dumpdir", "./", "-dumpbase", "mybinary.wpa", "-mtune=generic", > "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase", "a", > "-fno-openmp", "-fno-openacc", > "-fltrans-output-list=/tmp/mybinary.VkVmXd.ltrans.out", "-fwpa", > "-fresolution=/tmp/ccnQ6e55.res", "-flinker-output=exec", "@/tmp/cc0Sv5Fe"], > 0x7fffffffd960 /* 105 vars */ <unfinished ...> > [pid 16381] > execve("/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", > ["/home/marxin/bin/gcc/lib/gcc/x86_64-pc-linux-gnu/9.0.0/lto1", "-quiet", > "-dumpdir", "./", "-dumpbase", "mybinary.ltrans0", "-mtune=generic", > "-march=x86-64", "-mtune=generic", "-march=x86-64", "-auxbase-strip", > "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", > "-fltrans", "@/tmp/ccDY6Ojf", "-o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 /* 105 > vars */ <unfinished ...> > [pid 16382] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", > "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 > /* 105 vars */) = -1 ENOENT (No such file or directory) > [pid 16382] execve("/home/marxin/bin/as", ["as", "--64", "-o", > "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 > /* 105 vars */) = -1 ENOENT (No such file or directory) > [pid 16382] execve("/usr/local/bin/as", ["as", "--64", "-o", > "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 > /* 105 vars */) = -1 ENOENT (No such file or directory) > [pid 16382] execve("/usr/bin/as", ["as", "--64", "-o", > "/tmp/mybinary.VkVmXd.ltrans0.ltrans.o", "/tmp/ccrmLPAG.s"], 0x7fffffffd960 > /* 105 vars */ <unfinished ...> > > > > > > Otherwise there's the chance to trash user files which isn't good. > > Sure, the patch behaves fine. I'll install it.
Btw, it would be more natural if with -save-temps those files were in the same directory as the output (see how we handle -fresolution= for example) and be named without abcd1234 stuff. That also avoids $tmp creep if you use -save-temps multiple times... Richard. > Martin > > > > >> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. > >> > >> Ready to be installed? > > > > OK if the above is correct. > > > > Thanks, > > Richard. > > > >> Martin > >> > >> gcc/ChangeLog: > >> > >> 2018-07-26 Martin Liska <mli...@suse.cz> > >> > >> PR lto/86548 > >> * lto-wrapper.c: Add linker_output as prefix > >> for ltrans_output_file. > >> > >> include/ChangeLog: > >> > >> 2018-07-26 Martin Liska <mli...@suse.cz> > >> > >> PR lto/86548 > >> * libiberty.h (make_temp_file_with_prefix): New function. > >> > >> libiberty/ChangeLog: > >> > >> 2018-07-26 Martin Liska <mli...@suse.cz> > >> > >> PR lto/86548 > >> * make-temp-file.c (TEMP_FILE): Remove leading 'cc'. > >> (make_temp_file): Call make_temp_file_with_prefix with > >> first argument set to NULL. > >> (make_temp_file_with_prefix): Support also prefix. > >> --- > >> gcc/lto-wrapper.c | 14 +++++++++++++- > >> include/libiberty.h | 5 +++++ > >> libiberty/make-temp-file.c | 24 ++++++++++++++++++------ > >> 3 files changed, 36 insertions(+), 7 deletions(-) > >> > >> >