From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5029 invoked by alias); 26 Jul 2018 13:53:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 5013 invoked by uid 89); 26 Jul 2018 13:53:45 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Jul 2018 13:53:43 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C85B8AEC9; Thu, 26 Jul 2018 13:53:40 +0000 (UTC) Subject: Re: [PATCH] Add linker_output as prefix for LTO temps (PR lto/86548). To: Richard Biener Cc: GCC Patches , Jan Hubicka References: <22a64f03-f71a-fdc4-3c0a-65dbf584923f@suse.cz> From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Message-ID: <92dc5d5d-b58c-e8e0-34be-bb00653eb84c@suse.cz> Date: Thu, 26 Jul 2018 13:53:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg01642.txt.bz2 On 07/26/2018 02:26 PM, Richard Biener wrote: > On Thu, Jul 26, 2018 at 2:12 PM Martin Liška wrote: >> >> On 07/26/2018 01:34 PM, Richard Biener wrote: >>> On Thu, Jul 26, 2018 at 12:55 PM Martin Liška 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 */ >> [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 */ >> [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 */ >> >> 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 */ >> [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 */ >> [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 */ >> >> >>> >>> 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... If I see correctly they are: $ strace -f -s512 gcc -flto a.o main.o -o mybinary --save-temps 2>&1 | grep execv | grep ltrans [pid 11343] 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=mybinary.ltrans.out", "-fwpa", "-fresolution=main.res", "-flinker-output=exec", "@/tmp/ccofC8gO"], 0x7fffffffd940 /* 105 vars */ [pid 11345] 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", "mybinary.ltrans0.ltrans.o", "-fno-openmp", "-fno-openacc", "-fltrans", "@/tmp/cc8GLrIR", "-o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */ [pid 11346] execve("/home/marxin/bin/gcc/bin//as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */) = -1 ENOENT (No such file or directory) [pid 11346] execve("/home/marxin/bin/as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */) = -1 ENOENT (No such file or directory) [pid 11346] execve("/usr/local/bin/as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */) = -1 ENOENT (No such file or directory) [pid 11346] execve("/usr/bin/as", ["as", "--64", "-o", "mybinary.ltrans0.ltrans.o", "mybinary.ltrans0.s"], 0x7fffffffd940 /* 105 vars */ Martin > > 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 >>>> >>>> PR lto/86548 >>>> * lto-wrapper.c: Add linker_output as prefix >>>> for ltrans_output_file. >>>> >>>> include/ChangeLog: >>>> >>>> 2018-07-26 Martin Liska >>>> >>>> PR lto/86548 >>>> * libiberty.h (make_temp_file_with_prefix): New function. >>>> >>>> libiberty/ChangeLog: >>>> >>>> 2018-07-26 Martin Liska >>>> >>>> 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(-) >>>> >>>> >>