https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81936
--- Comment #9 from Tom de Vries <vries at gcc dot gnu.org> --- (In reply to Tom de Vries from comment #8) > 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. */ > > ... That didn't work since g->have_offload is not set yet. Setting it after analyze_functions does work: ... diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index e8cc765095d..080451a44df 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2614,6 +2614,10 @@ symbol_table::finalize_compilation_unit (void) /* Gimplify and lower thunks. */ analyze_functions (/*first_time=*/false); + /* Offloading requires LTO infrastructure. */ + if (!in_lto_p && g->have_offload) + flag_generate_offload = 1; + if (!seen_error ()) { /* Emit early debug for reachable functions, and by consequence, ... And then we run into the next ICE: ... libgomp/testsuite/libgomp.c/pr66714.c:17:1: internal compiler error: in output_loc_operands, at dwarf2out.c:2232 0x86f757 output_loc_operands gcc/dwarf2out.c:2232 0x86f757 output_loc_sequence(dw_loc_descr_node*, int) gcc/dwarf2out.c:2419 0x86ff61 output_die gcc/dwarf2out.c:10038 0x86fa0a output_die gcc/dwarf2out.c:10348 0x86fa0a output_die gcc/dwarf2out.c:10348 0x871118 output_comp_unit gcc/dwarf2out.c:10483 0x898408 dwarf2out_early_finish gcc/dwarf2out.c:30597 0x7fe3b8 symbol_table::finalize_compilation_unit() gcc/cgraphunit.c:2631 Please submit a full bug report, ...