https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65015
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to conchur from comment #2) > Created attachment 34724 [details] > Mini Testcases > > Current results (the -COMPILE things are just out of curiosity): > > SIMPLE-COMPILE: OK > SIMPLE-LINK: OK > LTO-COMPILE: FAIL that's expected to fail > LTO-LINK: FAIL > LTO-OBJDUMP: OK > LTO-EXTERNAL-DEBUG: FAIL > LTO-STRIP-LINK: FAIL > LTO-STRIP-EXTERNAL-DEBUG: FAIL > LTO-BUILDID-LINK: FAIL > LTO-SAVETEMPS-LINK: OK > LTO-SAVETEMPS-EXTERNAL-DEBUG: OK > > The -save-temps was a suggestion by Jérémy Bobbio and shows that there is > still a problem with the random file names when trying to use LTO to create > reproducible builds. At least for the simple one file case -save-temps makes some of the names non-random. I still expect that the patch I just committed plus Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 220613) +++ gcc/dwarf2out.c (working copy) @@ -24521,8 +24521,11 @@ dwarf2out_finish (const char *filename) gen_remaining_tmpl_value_param_die_attribute (); /* Add the name for the main input file now. We delayed this from - dwarf2out_init to avoid complications with PCH. */ - add_name_attribute (comp_unit_die (), remap_debug_filename (filename)); + dwarf2out_init to avoid complications with PCH. + Avoid doing this for LTO produced units as it adds random + tempfile names. */ + if (!in_lto_p) + add_name_attribute (comp_unit_die (), remap_debug_filename (filename)); if (!IS_ABSOLUTE_PATH (filename) || targetm.force_at_comp_dir) add_comp_dir_attribute (comp_unit_die ()); else if (get_AT (comp_unit_die (), DW_AT_comp_dir) == NULL) will fix all cases. Indeed: > ./t.sh SIMPLE-COMPILE: OK SIMPLE-LINK: OK LTO-COMPILE: FAIL LTO-LINK: OK LTO-OBJDUMP: OK LTO-EXTERNAL-DEBUG: OK LTO-STRIP-LINK: OK LTO-STRIP-EXTERNAL-DEBUG: OK LTO-BUILDID-LINK: OK LTO-SAVETEMPS-LINK: OK LTO-SAVETEMPS-EXTERNAL-DEBUG: OK as expected.