Fix undefined symbols in LTO Mozilla build

Jan Hubicka hubicka@ucw.cz
Wed Jan 9 21:27:00 GMT 2013


Hi,
currently Mozilla does not build with undefined symbol on 
error: /tmp/cc0oq4BG.ltrans1.ltrans.o: requires dynamic R_X86_64_PC32 reloc
against '_ZN12SkAnnotationC1ER23SkFlattenableReadBuffer' which may overflow at
runtime; recompile with -fPIC

This is actually bug in Mozilla (the module is calling the function but it is not 
linked with the implementation). The call is however from dead virtual function and
is optimized even at -O0 without LTO.
What breaks is that currently we do symtab_remove_unreachable_nodes in post-inlining
mode only from cgraphunit path that is completely bypassed by WPA.

This is bug.  The cleanup is supposed to happen just before inlining functions
called once.  The patch also adds the cleanup to same place into
do_whole_program_analysis and updates cgraphclones.c so we do not ice when
removing offline copy of the function after inlining.

We really ought to do post-inlining cleanup from passmanager, too, but this
will require some bookeeping, so it is post 4.8 material.

Bootstrapped/regtested x86_64, lto-bootstrapped and tested with lto Mozilla.
Unforutnately there seems to be yet another undefined symbol problem as described
by Markus.

Honza

	PR lto/45375
	* ipa-inline.c (ipa_inline): Remove extern inlines and virtual functions.
	* cgraphclones.c (cgraph_clone_node): Cpoy also LTO file data.

	* lto.c (do_whole_program_analysis): Remove unreachable nodes after IPA.
Index: ipa-inline.c
===================================================================
--- ipa-inline.c	(revision 195047)
+++ ipa-inline.c	(working copy)
@@ -1793,7 +1793,7 @@ ipa_inline (void)
     }
 
   inline_small_functions ();
-  symtab_remove_unreachable_nodes (true, dump_file);
+  symtab_remove_unreachable_nodes (false, dump_file);
   free (order);
 
   /* Inline functions with a property that after inlining into all callers the
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 195047)
+++ lto/lto.c	(working copy)
@@ -3215,6 +3215,7 @@ do_whole_program_analysis (void)
   cgraph_state = CGRAPH_STATE_IPA_SSA;
 
   execute_ipa_pass_list (all_regular_ipa_passes);
+  symtab_remove_unreachable_nodes (false, dump_file);
 
   if (cgraph_dump_file)
     {
Index: cgraphclones.c
===================================================================
--- cgraphclones.c	(revision 195047)
+++ cgraphclones.c	(working copy)
@@ -184,6 +184,7 @@ cgraph_clone_node (struct cgraph_node *n
   new_node->symbol.decl = decl;
   symtab_register_node ((symtab_node)new_node);
   new_node->origin = n->origin;
+  new_node->symbol.lto_file_data = n->symbol.lto_file_data;
   if (new_node->origin)
     {
       new_node->next_nested = new_node->origin->nested;



More information about the Gcc-patches mailing list