https://sourceware.org/bugzilla/show_bug.cgi?id=32083

            Bug ID: 32083
           Summary: lto1: fatal error: multiple prevailing defs for ‘func’
           Product: binutils
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

When linker sees a common symbol, foo, if there is foo in an archive, linker
calls elf_link_is_defined_archive_symbol to check if foo is a definition. Since
elf_link_is_defined_archive_symbol calls plugin_object_p to check if the LTO
plugin
can claim the archive member.  When plugin_call_all_symbols_read is called, all
symbols from claimed LTO objects are returned, including the unused archive
member.
Since liby.a appears twice on the command line, we get ultiple prevailing defs
error:

[hjl@gnu-cfl-3 lto-2]$ cat exec.c
#include <stdio.h>

int foo;

int main()
{
  if (foo == 1)
    printf ("PASS\n");

  return 0;
}
[hjl@gnu-cfl-3 lto-2]$ cat y.c
int foo;

void
func (void)
{
}
[hjl@gnu-cfl-3 lto-2]$ make y
gcc -B./ -fcommon -flto   -c -o exec.o exec.c
gcc -B./ -fcommon -flto   -c -o y.o y.c
ar -rv liby.a y.o
ar: creating liby.a
a - y.o
gcc -B./ -fcommon -flto -o y exec.o liby.a liby.a
lto1: fatal error: multiple prevailing defs for ‘func’
compilation terminated.
lto-wrapper: fatal error: gcc returned 1 exit status
compilation terminated.
./ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make: *** [Makefile:20: y] Error 1
rm y.o
[hjl@gnu-cfl-3 lto-2]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to