From patchwork Wed Jul 7 01:18:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Avoid duplicate toplevel asms with WHOPR Date: Tue, 06 Jul 2010 15:18:45 -0000 From: Jan Hubicka X-Patchwork-Id: 58075 Message-Id: <20100707011845.GC12425@kam.mff.cuni.cz> To: gcc-patches@gcc.gnu.org Hi, this fixes problem linking Mozilla. The problem is that libffi use toplevel asms for stub functions and they get shipped into every partition producing about 1million linker error messages. This patch makes them go to only first partition. It is not very clean, but I can't think of anything pretty here. Boostrapped/regtested x86_64-linux, OK? Honza * lto-cgraph.c (output_cgraph): Output toplevel asms only into first partition. Index: lto-cgraph.c =================================================================== --- lto-cgraph.c (revision 161898) +++ lto-cgraph.c (working copy) @@ -881,14 +884,21 @@ output_cgraph (cgraph_node_set set, varp lto_output_uleb128_stream (ob->main_stream, 0); - /* Emit toplevel asms. */ - for (can = cgraph_asm_nodes; can; can = can->next) + /* Emit toplevel asms. + When doing WPA we must output every asm just once. Since we do not partition asm + nodes at all, output them to first output. This is kind of hack, but should work + well. */ + if (!asm_nodes_output) { - int len = TREE_STRING_LENGTH (can->asm_str); - lto_output_uleb128_stream (ob->main_stream, len); - for (i = 0; i < len; ++i) - lto_output_1_stream (ob->main_stream, - TREE_STRING_POINTER (can->asm_str)[i]); + asm_nodes_output = true; + for (can = cgraph_asm_nodes; can; can = can->next) + { + int len = TREE_STRING_LENGTH (can->asm_str); + lto_output_uleb128_stream (ob->main_stream, len); + for (i = 0; i < len; ++i) + lto_output_1_stream (ob->main_stream, + TREE_STRING_POINTER (can->asm_str)[i]); + } } lto_output_uleb128_stream (ob->main_stream, 0);