http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53572

--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-06-04 
14:19:02 UTC ---
I do not have linker plugin enabled setup handy at the moment, but the
following patch should fix it:
Index: cgraph.h
===================================================================
--- cgraph.h    (revision 188138)
+++ cgraph.h    (working copy)
@@ -1126,7 +1126,8 @@ varpool_can_remove_if_no_refs (struct va
   if (DECL_EXTERNAL (node->symbol.decl))
     return true;
   return (!node->symbol.force_output &&
!node->symbol.used_from_other_partition
-         && (DECL_COMDAT (node->symbol.decl)
+         && ((DECL_COMDAT (node->symbol.decl)
+              && symtab_used_from_object_file_p ((symtab_node) node))
              || !node->symbol.externally_visible
              || DECL_HAS_VALUE_EXPR_P (node->symbol.decl)));
 }

I am testing this patch for mainline.
As discussed on IRC, this patch can have negative effect on V1 linker API
setups: here all comdats appears to be externally visible and thus they will be
forced to output.

But perhaps it is now resonable to expect V2 linker API even for GCC 4.7 based
setups for sane LTO with C++?  We already mention in release notes that V1 API
is bad idea...

Honza

Reply via email to