http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55466
--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> 2012-12-07 18:49:10 UTC --- (In reply to comment #7) > This patch: > > diff --git a/gcc/lto-symtab.c b/gcc/lto-symtab.c > index 0b0cdac..295fd37 100644 > --- a/gcc/lto-symtab.c > +++ b/gcc/lto-symtab.c > @@ -443,10 +443,6 @@ lto_symtab_merge_decls_1 (symtab_node first) > > symtab_prevail_in_asm_name_hash (prevailing); > > - /* Record the prevailing variable. */ > - if (TREE_CODE (prevailing->symbol.decl) == VAR_DECL) > - vec_safe_push (lto_global_var_decls, prevailing->symbol.decl); > - > /* Diagnose mismatched objects. */ > for (e = prevailing->symbol.next_sharing_asm_name; > e; e = e->symbol.next_sharing_asm_name) > diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c > index 376af85..177fbfc 100644 > --- a/gcc/lto/lto.c > +++ b/gcc/lto/lto.c > @@ -2910,6 +2910,7 @@ read_cgraph_and_symbols (unsigned nfiles, const char > **fnames) > struct cgraph_node *node; > int count = 0; > struct lto_file_decl_data **decl_data; > + struct varpool_node *vnode; > > init_cgraph (); > > @@ -3088,6 +3089,10 @@ read_cgraph_and_symbols (unsigned nfiles, const char > **fnames) > > timevar_pop (TV_IPA_LTO_CGRAPH_MERGE); > > + /* Record the global variables. */ > + FOR_EACH_DEFINED_VARIABLE (vnode) > + vec_safe_push (lto_global_var_decls, vnode->symbol.decl); > + > timevar_push (TV_IPA_LTO_DECL_INIT_IO); > > /* Indicate that the cgraph is built and ready. */ > > or > > diff --git a/gcc/lto-symtab.c b/gcc/lto-symtab.c > index 0b0cdac..295fd37 100644 > --- a/gcc/lto-symtab.c > +++ b/gcc/lto-symtab.c > @@ -443,10 +443,6 @@ lto_symtab_merge_decls_1 (symtab_node first) > > symtab_prevail_in_asm_name_hash (prevailing); > > - /* Record the prevailing variable. */ > - if (TREE_CODE (prevailing->symbol.decl) == VAR_DECL) > - vec_safe_push (lto_global_var_decls, prevailing->symbol.decl); > - > /* Diagnose mismatched objects. */ > for (e = prevailing->symbol.next_sharing_asm_name; > e; e = e->symbol.next_sharing_asm_name) > diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c > index 376af85..c7e1100 100644 > --- a/gcc/lto/lto.c > +++ b/gcc/lto/lto.c > @@ -3373,6 +3373,8 @@ lto_main (void) > > if (!seen_error ()) > { > + struct varpool_node *vnode; > + > /* If WPA is enabled analyze the whole call graph and create an > optimization plan. Otherwise, read in all the function > bodies and continue with optimization. */ > @@ -3398,6 +3400,10 @@ lto_main (void) > if (flag_lto_report) > print_lto_report_1 (); > } > + > + /* Record the global variables. */ > + FOR_EACH_DEFINED_VARIABLE (vnode) > + vec_safe_push (lto_global_var_decls, vnode->symbol.decl); > } > > /* Here we make LTO pretend to be a parser. */ > > seem to work. It doesn't work. When gcc is configured with --enable-languages=c,c++,fortran,java,lto,objc,obj-c++,go, I got lto1: internal compiler error: in add_AT_specification, at dwarf2out.c:3985 0x629ad9 add_AT_specification /export/gnu/import/git/gcc/gcc/dwarf2out.c:3985 0x64dabb gen_variable_die /export/gnu/import/git/gcc/gcc/dwarf2out.c:18327 0x65336b gen_decl_die /export/gnu/import/git/gcc/gcc/dwarf2out.c:20033 0x653fcd dwarf2out_decl(tree_node*) /export/gnu/import/git/gcc/gcc/dwarf2out.c:20348 0x6535f9 dwarf2out_global_decl /export/gnu/import/git/gcc/gcc/dwarf2out.c:20083 0x997703 emit_debug_global_declarations(tree_node**, int) /export/gnu/import/git/gcc/gcc/toplev.c:530 0x521aaa lto_write_globals /export/gnu/import/git/gcc/gcc/lto/lto-lang.c:1067 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. make[6]: *** [/tmp/cc3yYR7d.ltrans4.ltrans.o] Error 1 lto-wrapper: make returned 2 exit status lto-wrapper: make returned 2 exit status /usr/local/x86_64-unknown-linux-gnu/bin/ld: lto-wrapper failed collect2: error: ld returned 1 exit status make[5]: *** [go1] Error 1