This avoids unlinking the assembler output file at the end of WPA stage (we don't produce anything useful there) which eventually clobbers an assembler output from a previous stage. Instead simply don't open the file. That requires not performing debug init which we shouldn't need either here (maybe we can also drop lang_dependent_init_target which for example inits IRA, but I'm not sure).
Bootstrapped and tested on x86_64-unknown-linux-gnu, SPEC 2k6 built with LTO and -g. Ok? Thanks, Richard. 2011-04-06 Richard Guenther <rguent...@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. Index: gcc/toplev.c =================================================================== *** gcc/toplev.c (revision 172023) --- gcc/toplev.c (working copy) *************** lang_dependent_init (const char *name) *** 1743,1753 **** return 0; input_location = save_loc; ! init_asm_output (name); ! /* If stack usage information is desired, open the output file. */ ! if (flag_stack_usage) ! stack_usage_file = open_auxiliary_file ("su"); /* This creates various _DECL nodes, so needs to be called after the front end is initialized. */ --- 1743,1756 ---- return 0; input_location = save_loc; ! if (!flag_wpa) ! { ! init_asm_output (name); ! /* If stack usage information is desired, open the output file. */ ! if (flag_stack_usage) ! stack_usage_file = open_auxiliary_file ("su"); ! } /* This creates various _DECL nodes, so needs to be called after the front end is initialized. */ *************** lang_dependent_init (const char *name) *** 1756,1775 **** /* Do the target-specific parts of the initialization. */ lang_dependent_init_target (); ! /* If dbx symbol table desired, initialize writing it and output the ! predefined types. */ ! timevar_push (TV_SYMOUT); #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO ! if (dwarf2out_do_frame ()) ! dwarf2out_frame_init (); #endif ! /* Now we have the correct original filename, we can initialize ! debug output. */ ! (*debug_hooks->init) (name); ! timevar_pop (TV_SYMOUT); return 1; } --- 1759,1781 ---- /* Do the target-specific parts of the initialization. */ lang_dependent_init_target (); ! if (!flag_wpa) ! { ! /* If dbx symbol table desired, initialize writing it and output the ! predefined types. */ ! timevar_push (TV_SYMOUT); #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO ! if (dwarf2out_do_frame ()) ! dwarf2out_frame_init (); #endif ! /* Now we have the correct original filename, we can initialize ! debug output. */ ! (*debug_hooks->init) (name); ! timevar_pop (TV_SYMOUT); ! } return 1; } *************** finalize (bool no_backend) *** 1848,1855 **** 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) --- 1854,1859 ----