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

            Bug ID: 59000
           Summary: lto can't merge user-defined weak builtin functions
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ma.jiang at zte dot com.cn

Created attachment 31156
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31156&action=edit
first source

User defined built-in implementation cause lto error.
Use source files in the attachment, following commands can reproduce this
problem.
xxx-gcc *.c -O2 -flto -c
xxx-gcc *.o -o tt.mid  -r -O2 -flto -nostdlib

lto1: error: two or more sections for .gnu.lto_scalbnf.a2a70fd51cfc1298
(null):0: confused by earlier errors, bailing out
lto-wrapper: ../powerpc-unknown-linux-gnu-gcc returned 1 exit status
collect2: error: lto-wrapper returned 1 exit status
========================================================
It seems that there is a bug in lto_symtab_merge_cgraph_nodes_1 in
lto-symtab.c.

      cgraph_node *ce = dyn_cast <cgraph_node> (e);
      if (ce && !DECL_BUILT_IN (e->symbol.decl))
        lto_cgraph_replace_node (ce, cgraph (prevailing));
      if (varpool_node *ve = dyn_cast <varpool_node> (e))
        lto_varpool_replace_node (ve, varpool (prevailing));

The function will do real replace only when e is NOT referring to a built-in
function.This is not right, because user can provide their own built-in
implementations which should also be merged. we change  DECL_BUILT_IN
(e->symbol.decl)) to DECL_IS_BUILTIN (e->symbol.decl)) to fix this problem, is
the fix ok for the mainstream?

Reply via email to