Created attachment 23884 [details] DIFF file with 4 tests 1. After running the 1st test, notice the absence of one generated assembler file (1.s), which is deleted by lto1. In toplev.c, 1851 if (flag_wpa) 1852 unlink_if_ordinary (asm_file_name); 2. As the 2nd and 3rd tests show, it can also be misused as an output file for lto1, so its original, written by cc1, content gets lost. 3. The 4th test gives good, expected results.
Confirmed. What we could do is try to arrange for the WPA lto1 stage to receive -o /dev/null, as it will not produce regular output. Or to simply avoid calling init_asm_output () for -fwpa. So, sth like Index: toplev.c =================================================================== --- toplev.c (revision 172023) +++ toplev.c (working copy) @@ -1743,7 +1743,8 @@ lang_dependent_init (const char *name) return 0; input_location = save_loc; - init_asm_output (name); + if (!flag_wpa) + init_asm_output (name); /* If stack usage information is desired, open the output file. */ if (flag_stack_usage) @@ -1848,8 +1849,6 @@ finalize (bool no_backend) fatal_error ("error writing to %s: %m", asm_file_name); if (fclose (asm_out_file) != 0) fatal_error ("error closing %s: %m", asm_file_name); - if (flag_wpa) - unlink_if_ordinary (asm_file_name); } if (stack_usage_file) which likely needs fixups throughout the compiler in case of missing asm_out_file checks.
Author: rguenth Date: Fri Apr 8 13:10:27 2011 New Revision: 172181 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172181 Log: 2011-04-08 Richard Guenther <rguenther@suse.de> PR lto/48467 * toplev.c (lang_dependent_init): Do not open asm_out_file in WPA mode, nor perform debug machinery initialization. (finalize): Do not unlink asm_out_file in WPA mode. Modified: trunk/gcc/ChangeLog trunk/gcc/toplev.c
Fixed for 4.7.
Second bug is now bug 48691.