https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87187
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- OK, so we end up here via force_decl_die which forces declaration == 1. But then /* A concrete instance, tag a new DIE with DW_AT_abstract_origin. */ if (origin != NULL) { gcc_assert (!declaration || local_scope_p (context_die)); where origin == decl because decl_ultimate_origin returns decl itself since its DECL_ABSTRACT_ORIGIN points to itself but it is not DECL_ABSTRACT_P. In the end we force the decl as context for a limbo DIE for a local static in the function ('i'). We're still doing that set_decl_origin_self on stuff via dwarf2out_abstract_function (tried to get rid of that repeatedly...). We're fooling dwarf2out here that an abstract origin DIE exists but with the LTO workaround it doesn't. On Linux if we compile with -g0 the DECL_ABSTRACT_ORIGIN will not be set while on Darwin compiling with -g will just elide the LTO part but still set DECL_ABSTRACT_ORIGIN. We cannot simply not stream DECL_ABSTRACT_ORIGIN if debug_info_level == DINFO_LEVEL_NONE because IIRC it is used for other stuff as well(?). Maybe just eliding the self-origin case works. So I am testing Index: gcc/tree-streamer-out.c =================================================================== --- gcc/tree-streamer-out.c (revision 268233) +++ gcc/tree-streamer-out.c (working copy) @@ -603,7 +603,16 @@ write_ts_decl_common_tree_pointers (stru special handling in LTO, it must be handled by streamer hooks. */ stream_write_tree (ob, DECL_ATTRIBUTES (expr), ref_p); - stream_write_tree (ob, DECL_ABSTRACT_ORIGIN (expr), ref_p); + + /* On non-early-LTO enabled targets we claim we compiled with -g0 + but dwarf2out still did its set_decl_origin_self game fooling + itself late. Und that here since we won't have access to the + early generated abstract DIEs. */ + tree ao = DECL_ABSTRACT_ORIGIN (expr); + if (debug_info_level == DINFO_LEVEL_NONE + && ao == expr) + ao = NULL_TREE; + stream_write_tree (ob, ao, ref_p); if ((VAR_P (expr) || TREE_CODE (expr) == PARM_DECL) && DECL_HAS_VALUE_EXPR_P (expr)) which fixes the testcase at least.