Thank you for your answer, Richard! On 06/10/2015 08:58 AM, Richard Biener wrote: > Hmm, so the underlying issue is that we don't associate comp_unit_die () > with any TRANSLATION_UNIT_DECL. Indeed. > For the LTO early debug work I did the following at the very > beginning of dwarf2out_early_finish: > > /* Pick the first TRANSLATION_UNIT_DECL we didn't create a DIE for > and equate it with our default CU DIE. LTO output needs to be > able to lookup DIEs for translation unit decls. */ > unsigned i; > tree decl; > FOR_EACH_VEC_SAFE_ELT (all_translation_units, i, decl) > if (!lookup_decl_die (decl)) > equate_decl_number_to_die (decl, comp_unit_die ()); If I understand correctly, this does not only "pick the first" (as the comment says) but do equate for all DIE-less units, right? Why isn't this hunk in mainline yet by the way? > We create some DIEs for builtin types too early before frontends > got a chance to build their TRANSLATION_UNIT_DECL, so comp_unit_die > gets created before there is any TRANSLATION_UNIT_DECL. Another > approach would of course be that the Frontends register their main > TRANSLATION_UNIT_DECL with dwarf2out via a debug hook. > > But - does the above work for you and fix the regression? If so > adding a debug hook would probably be the cleaner solution still. Yes it does, thanks! However we need to fix this on the 4.9 branch as well and this patch would need reworking to be applied there (no debug early). So here's a patch that introduce a register_main_translation_unit debug hook: is this what you had in mind? This works for me on the 4.9 branch and on mainline as well, regtested on x86_64-linux. -- Pierre-Marie de Rodat