https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81936
--- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> --- On Wed, 23 Aug 2017, vries at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81936 > > --- Comment #8 from Tom de Vries <vries at gcc dot gnu.org> --- > (In reply to rguent...@suse.de from comment #7) > > Ah, yeah. And we can have both, right? > > I'd say so. There's f.i. libgomp.c/target-9.c, which contains '#pragma omp > target' and uses -flto. > > > So we'd either need a separate > > set of early debug sections or use a combined for both (this is what > > will happen if you add && !flag_generate_offload I guess). > > I tried this patch: > ... > diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c > index 0c339bd46f0..92b43db1bae 100644 > --- a/gcc/dwarf2out.c > +++ b/gcc/dwarf2out.c > @@ -30526,7 +30526,7 @@ dwarf2out_early_finish (const char *filename) > early_dwarf_finished = true; > > /* Do not generate DWARF assembler now when not producing LTO bytecode. */ > - if (!flag_generate_lto) > + if (!flag_generate_lto && !flag_generate_offload) > return; > > /* Now as we are going to output for LTO initialize sections and labels > ... > but found it doesn't work because flag_generate_offload is actually false. > > I'm now trying this (code snippet copied from symbol_table::compile), but I'm > not sure if setting flag_generate_offload is the proper solution, and if so, > where it should be inserted: > ... > diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c > index e8cc765095d..29a1d038b0e 100644 > --- a/gcc/cgraphunit.c > +++ b/gcc/cgraphunit.c > @@ -2586,6 +2586,10 @@ symbol_table::finalize_compilation_unit (void) > current_function_decl = NULL; > set_cfun (NULL); > > + /* Offloading requires LTO infrastructure. */ > + if (!in_lto_p && g->have_offload) > + flag_generate_offload = 1; > + > /* Do not skip analyzing the functions if there were errors, we > miss diagnostics for following functions otherwise. */ > > ... Moving this earlier from symbol_table::compile to its caller, right before the block emitting early debug looks obvious to me. Where you placed it we might not yet know g->have_offload? That is, we might need analyze_functions ().