public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/52634] New: multiple definition error when using alias
@ 2012-03-20 12:32 tianbin at cernet dot edu.cn
  2012-03-20 13:16 ` [Bug lto/52634] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: tianbin at cernet dot edu.cn @ 2012-03-20 12:32 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 52634
           Summary: multiple definition error when using alias
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tianbin@cernet.edu.cn


When compiling a project which have 11 cpp files with -flto, g++-4.7 reports
the following error
------
xxx.ltrans25.ltrans.o:(.bss+0x0): multiple definition of `cfliteKeyCallBacks'
xxx.ltrans15.ltrans.o:(.bss+0x0): first defined here
xxx.ltrans29.ltrans.o:(.data+0xc80): multiple definition of
`cfliteKeyCallBacks'
xxx.ltrans15.ltrans.o:(.bss+0x0): first defined here

in xxx.ltrans25.s, I found
----
        .hidden cfliteKeyCallBacks
        .globl  cfliteKeyCallBacks
        .bss
        .align 32
        .type   cfliteKeyCallBacks, @object
        .size   cfliteKeyCallBacks, 48
cfliteKeyCallBacks:
        .zero   48
        .set    cfliteArrayCallBacks.4936,cfliteKeyCallBacks

in xxx.ltrans15.s, I found
----
        .hidden cfliteKeyCallBacks
        .globl  cfliteKeyCallBacks
        .bss
        .align 32
        .type   cfliteKeyCallBacks, @object
        .size   cfliteKeyCallBacks, 48
cfliteKeyCallBacks:
        .zero   48
        .set    cfliteValueCallBacks.3513,cfliteKeyCallBacks

in xxx.ltrans29.s, I found
----
        .hidden cfliteKeyCallBacks
        .globl  cfliteKeyCallBacks
        .data
        .align 32
        .type   cfliteKeyCallBacks, @object
        .size   cfliteKeyCallBacks, 48
cfliteKeyCallBacks:
        .quad   0
        .quad   _ZL17cflite_key_retainPK13__CFAllocatorPKv.19440
        .quad   _ZL18cflite_key_releasePK13__CFAllocatorPKv.19434
        .quad   _ZL21cflite_key_copy_descrPKv.19447
        .quad   _ZL16cflite_key_equalPKvS0_.19429
        .quad   _ZL15cflite_key_hashPKv.19425

And in cflite.cpp, the corespond source is
---------------
...
CFDictionaryKeyCallBacks cfliteKeyCallBacks = {
    0,
    cflite_key_retain,
    cflite_key_release,
    cflite_key_copy_descr,
    cflite_key_equal,
    cflite_key_hash,
};

extern CFDictionaryValueCallBacks cfliteValueCallBacks
__attribute__((alias("cfliteKeyCallBacks")));

extern CFArrayCallBacks cfliteArrayCallBacks
__attribute__((alias("cfliteKeyCallBacks")));

The project compiles ok without -flto.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
@ 2012-03-20 13:16 ` rguenth at gcc dot gnu.org
  2012-03-20 14:17 ` tianbin at cernet dot edu.cn
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-20 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |lto
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-20 12:55:45 UTC ---
Can you provide a testcase?  You can try reducing the number of input sources
required by performing a partial link (-r -nostdlib), and use
-flto-partition=1to1
to make that reduction more reliable (if the bug reproduces with that option).
Does the error reproduce with -flto-partition=none?

It seems to me that assembing the target is broken (and thus partitioning).


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
  2012-03-20 13:16 ` [Bug lto/52634] " rguenth at gcc dot gnu.org
@ 2012-03-20 14:17 ` tianbin at cernet dot edu.cn
  2012-03-20 14:31 ` tianbin at cernet dot edu.cn
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tianbin at cernet dot edu.cn @ 2012-03-20 14:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Bin Tian <tianbin at cernet dot edu.cn> 2012-03-20 14:16:02 UTC ---
Created attachment 26931
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26931
patch for make-3.82


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
  2012-03-20 13:16 ` [Bug lto/52634] " rguenth at gcc dot gnu.org
  2012-03-20 14:17 ` tianbin at cernet dot edu.cn
@ 2012-03-20 14:31 ` tianbin at cernet dot edu.cn
  2012-03-20 14:56 ` rguenth at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: tianbin at cernet dot edu.cn @ 2012-03-20 14:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Bin Tian <tianbin at cernet dot edu.cn> 2012-03-20 14:16:49 UTC ---
The bug is reproducable with -r -flto-partition=1to1, and not with -r
-flto-partition=none.

My project is hard to reduce because of complex dependencies. It seems that if
the call graph is too simple, the bug never shows up.

Finally, I make a testcase based on make-3.82
(http://ftp.gnu.org/gnu/make/make-3.82.tar.gz).

Please apply the attached patch on make-3.82, and compile it with the following
instructions:

$ autoreconf -vif
$ ./configure CFLAGS='-g -O2 -flto' CC=gcc-4.7
$ make

The patch is produced with git format-patch.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (2 preceding siblings ...)
  2012-03-20 14:31 ` tianbin at cernet dot edu.cn
@ 2012-03-20 14:56 ` rguenth at gcc dot gnu.org
  2012-03-20 15:05 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-20 14:56 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-03-20
     Ever Confirmed|0                           |1

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-20 14:42:33 UTC ---
Reduced testcase:

t1.c
----
extern int cfliteValueCallBacks;
void baz (int *);
int main () { baz(&cfliteValueCallBacks); }

t2.c
----
int cfliteKeyCallBacks = 5;
extern int cfliteValueCallBacks __attribute__((alias("cfliteKeyCallBacks")));

fails as:

gcc-4.7 -flto -flto-partition=1to1 t1.c t2.c -r -nostdlib
/tmp/ccPs2Uvd.ltrans1.ltrans.o:(.bss+0x0): multiple definition of
`cfliteKeyCallBacks'
/tmp/ccPs2Uvd.ltrans0.ltrans.o:(.data+0x0): first defined here
collect2: error: ld returned 1 exit status

Not sure if the source is valid by design.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (3 preceding siblings ...)
  2012-03-20 14:56 ` rguenth at gcc dot gnu.org
@ 2012-03-20 15:05 ` rguenth at gcc dot gnu.org
  2012-03-20 17:22 ` hubicka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-03-20 15:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-03-20 14:55:42 UTC ---
2
t1.o 3
164 2f48a666878dc458 PREVAILING_DEF_IRONLY_EXP main
169 2f48a666878dc458 UNDEF baz
173 2f48a666878dc458 RESOLVED_IR cfliteValueCallBacks
t2.o 2
164 9f18e45b84a4baf8 PREVAILING_DEF_IRONLY_EXP cfliteValueCallBacks
176 9f18e45b84a4baf8 PREVAILING_DEF_IRONLY_EXP cfliteKeyCallBacks

looks sane, but the partitioning not:

Callgraph/varpool at WPA time:

baz/1 @0x7ffff5a257e0 (asm: baz) availability:not_available reachable
  called by: main/0 (1.00 per call)
  calls:
  References:
  Refering this function:
main/0 @0x7ffff5a256c0 (asm: main) availability:available analyzed needed
reachable externally_visible prevailing_def_ironly_exp finalized
  called by:
  calls: baz/1 (1.00 per call)
  References:  var:cfliteValueCallBacks (addr)
  Refering this function:
cfliteKeyCallBacks: availability:overwritable (asm: cfliteKeyCallBacks)
initialized needed analyzed finalized externally_visible
prevailing_def_ironly_exp
  References:
  Refering this var:  var:cfliteValueCallBacks (alias)
cfliteValueCallBacks: availability:overwritable (asm: cfliteValueCallBacks)
needed analyzed finalized externally_visible prevailing_def_ironly_exp
  References:  var:cfliteKeyCallBacks (alias)
  Refering this var:  fn:main/0 (addr)

Partitions:

Writing partition t2.o to file /tmp/ccZbL7rX.ltrans0.o, 0 insns
cgraph nodes:
varpool nodes: cfliteKeyCallBacks
Writing partition t1.o to file /tmp/ccZbL7rX.ltrans1.o, 5 insns
cgraph nodes: main/0
varpool nodes:

where is the varpool/alias node for cfliteValueCallBacks?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (4 preceding siblings ...)
  2012-03-20 15:05 ` rguenth at gcc dot gnu.org
@ 2012-03-20 17:22 ` hubicka at gcc dot gnu.org
  2012-03-25 10:24 ` hubicka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-03-20 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |hubicka at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #6 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-03-20 16:55:40 UTC ---
mine. The alias node should go along with the variable into the appropriate
partition. It seems that the partitioning logic is confused by fact that the
variable is static but alias is not, so it decides to put alias into both units
and the alias drags variable with it.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (5 preceding siblings ...)
  2012-03-20 17:22 ` hubicka at gcc dot gnu.org
@ 2012-03-25 10:24 ` hubicka at gcc dot gnu.org
  2012-04-09 23:39 ` hubicka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-03-25 10:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-03-25 10:14:40 UTC ---
Hmm, partitioning seems right.
We get into ltrans0:
cfliteValueCallBacks: availability:not-ready (asm: cfliteValueCallBacks) needed
analyzed finalized externally_visible prevailing_def in_other_partition
  References:
  Refering this var:  fn:main/0 (addr)

that is only alias from other partition. We however somehow work out the alias:

cfliteKeyCallBacks: availability:not_available (asm: cfliteKeyCallBacks) needed
  References:
  Refering this var:  var:cfliteValueCallBacks (alias)

and then output it with 0 initialization.  Seems overactive alias processing
somewhere.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (6 preceding siblings ...)
  2012-03-25 10:24 ` hubicka at gcc dot gnu.org
@ 2012-04-09 23:39 ` hubicka at gcc dot gnu.org
  2012-04-10 15:10 ` hubicka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-04-09 23:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-04-09 23:39:15 UTC ---
Author: hubicka
Date: Mon Apr  9 23:39:11 2012
New Revision: 186252

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186252
Log:

    PR lto/52722
    PR lto/51765
    PR lto/52634    
    * lto-cgraph.c (compute_ltrans_boundary): When alias is in the boundary,
    add its target too.
    * lto.c (add_references_to_partition): Add also aliased nodes.
    (add_cgraph_node_to_partition,
    add_varpool_node_to_partition): Work on nodes, not functions/variables;
    when adding alias, add also the aliased object.

    * gcc.dg/lto/pr52634_1.c: New testcase.
    * gcc.dg/lto/pr52634_0.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/lto/pr52634_0.c
    trunk/gcc/testsuite/gcc.dg/lto/pr52634_1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/lto-cgraph.c
    trunk/gcc/lto/lto.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (7 preceding siblings ...)
  2012-04-09 23:39 ` hubicka at gcc dot gnu.org
@ 2012-04-10 15:10 ` hubicka at gcc dot gnu.org
  2012-10-14  9:14 ` tianbin at cernet dot edu.cn
  2021-12-24  8:59 ` pinskia at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: hubicka at gcc dot gnu.org @ 2012-04-10 15:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Jan Hubicka <hubicka at gcc dot gnu.org> 2012-04-10 15:09:27 UTC ---
Fixed on mainline, will backport the fix if no problems shows up.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (8 preceding siblings ...)
  2012-04-10 15:10 ` hubicka at gcc dot gnu.org
@ 2012-10-14  9:14 ` tianbin at cernet dot edu.cn
  2021-12-24  8:59 ` pinskia at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: tianbin at cernet dot edu.cn @ 2012-10-14  9:14 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #10 from Bin Tian <tianbin at cernet dot edu.cn> 2012-10-14 09:14:13 UTC ---
please backport to gcc-4_7-branch, thanks.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug lto/52634] multiple definition error when using alias
  2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
                   ` (9 preceding siblings ...)
  2012-10-14  9:14 ` tianbin at cernet dot edu.cn
@ 2021-12-24  8:59 ` pinskia at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-24  8:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52634

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.8.0
             Status|ASSIGNED                    |RESOLVED

--- Comment #11 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-12-24  8:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-20 12:32 [Bug lto/52634] New: multiple definition error when using alias tianbin at cernet dot edu.cn
2012-03-20 13:16 ` [Bug lto/52634] " rguenth at gcc dot gnu.org
2012-03-20 14:17 ` tianbin at cernet dot edu.cn
2012-03-20 14:31 ` tianbin at cernet dot edu.cn
2012-03-20 14:56 ` rguenth at gcc dot gnu.org
2012-03-20 15:05 ` rguenth at gcc dot gnu.org
2012-03-20 17:22 ` hubicka at gcc dot gnu.org
2012-03-25 10:24 ` hubicka at gcc dot gnu.org
2012-04-09 23:39 ` hubicka at gcc dot gnu.org
2012-04-10 15:10 ` hubicka at gcc dot gnu.org
2012-10-14  9:14 ` tianbin at cernet dot edu.cn
2021-12-24  8:59 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).