First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 25908
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Erik Schnetter <schnetter@aei.mpg.de>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
main.ii.gz Gzipped preprocessed failing source code, part 1 application/octet-stream 2006-01-23 19:47 25.30 KB Edit
sub.ii.gz Gzipped preprocessed failing source code, part 2 application/octet-stream 2006-01-23 19:47 25.29 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 25908 depends on: Show dependency tree
Show dependency graph
Bug 25908 blocks: 25925

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2006-01-23 19:52 Opened: 2006-01-22 00:51
I use gcc (GCC) 4.2.0 20060120 to compile Cactus, a large piece of code
combining C, C++, and Fortran.  I receive many errors from the linker like

/usr/bin/ld: multiple definitions of symbol typeinfo for MPI::Op
/Users/eschnett/Calpha/configs/einstein-orange-gcc-debug/lib/libthorn_Carpet.a(helpers.cc.o)
definition of typeinfo for MPI::Opin section (__DATA,__const)
/Users/eschnett/Calpha/configs/einstein-orange-gcc-debug/lib/libthorn_CarpetAdaptiveRegrid.a(CAR.cc.o)
definition of typeinfo for MPI::Opin section (__DATA,__const)

or

/usr/bin/ld: multiple definitions of symbol vtable for MPI::Op
/Users/eschnett/Calpha/configs/einstein-orange-gcc-debug/lib/libthorn_Carpet.a(helpers.cc.o)
definition of vtable for MPI::Opin section (__DATA,__const)
/Users/eschnett/Calpha/configs/einstein-orange-gcc-debug/lib/libthorn_CarpetAdaptiveRegrid.a(CAR.cc.o)
definition of vtable for MPI::Opin section (__DATA,__const)

(Note that the error messages seem run-together; e.g. "MPI::OPin" seems to
refer to the class "MPI::Op", which is located IN a certain section.)

These errors are not there with gcc (GCC) 4.2.0 20051129.  The code also works
fine on many other architectures.  But with C++, I am not sure what the reason
is.

I have looked on the web, and the gcc PR "[Bug c++/16218] Link problems with
inline virtual function in multiple translation units" seems similar.  At that
time, it apparently was an error in gcc that caused this problem.



I use the linker /usr/bin/ld
Apple Computer, Inc. version cctools-590.18.obj~10

and these C++ classes are defined in LAM MPI 7.0.6-11, which I installed via
fink.

------- Comment #1 From Andrew Pinski 2006-01-23 16:19 -------
Do you have a simple example?

------- Comment #2 From Erik Schnetter 2006-01-23 19:45 -------
Here is a way to reproduce the error with very little source code, but still
depending on the LAM MPI library.  The actual source code I used consists of
two files, main.cc and sub.cc, which I include here for completeness:

main.cc:
#include <mpi.h>

int
main (int argc, char * argv[])
{
  return 0;
}

sub.cc:
#include <mpi.h>

void
sub ()
{
}



I preprocessed these with "g++ -E", and I attach the results.  When I compile
the preprocessed sources, I get:

$ ~/gcc-new/bin/g++ -o lamtest main.ii sub.ii
/usr/bin/ld: multiple definitions of symbol typeinfo for MPI::Op
/var/tmp//ccFSbBVd.o definition of typeinfo for MPI::Opin section
(__DATA,__const)
/var/tmp//cc8Rm38U.o definition of typeinfo for MPI::Opin section
(__DATA,__const)
/usr/bin/ld: multiple definitions of symbol typeinfo for PMPI::Op
/var/tmp//ccFSbBVd.o definition of typeinfo for PMPI::Opin section
(__DATA,__const)
/var/tmp//cc8Rm38U.o definition of typeinfo for PMPI::Opin section
(__DATA,__const)
/usr/bin/ld: multiple definitions of symbol typeinfo for PMPI::Comm
/var/tmp//ccFSbBVd.o definition of typeinfo for PMPI::Commin section
(__DATA,__const)
/var/tmp//cc8Rm38U.o definition of typeinfo for PMPI::Commin section
(__DATA,__const)

(and many more warnings like that).

------- Comment #3 From Erik Schnetter 2006-01-23 19:47 -------
Created an attachment (id=10715) [edit]
Gzipped preprocessed failing source code, part 1

------- Comment #4 From Erik Schnetter 2006-01-23 19:47 -------
Created an attachment (id=10716) [edit]
Gzipped preprocessed failing source code, part 2

------- Comment #5 From Andrew Pinski 2006-01-23 19:51 -------
I think that is enough to reproduce it for now.

Thanks, when my computer (laptop) gets back up and working, I will look into
this.

I think this was caused by the section changes.

------- Comment #6 From Andrew Pinski 2006-01-24 20:04 -------
Trying to reduce this failure.  (I can reproduce it on today's compiler).

------- Comment #7 From Andrew Pinski 2006-01-24 20:14 -------
Reduced testcase:
file1.cc:
class f
{
  virtual void g();
};
inline void f::g()
{}
int sub(void)
{}
file2.cc:
class f
{
  virtual void g();
};
inline void f::g()
{}
int main(void)
{}


------

Now why does this work if I add inline to the method inside the declaration of
the class.

------- Comment #8 From Andrew Pinski 2006-01-24 20:20 -------
Hmm, this testcase works correctly on x86_64-linux-gnu, in that the vtable is
marked as weak.

------- Comment #9 From Andrew Pinski 2006-01-24 20:28 -------
Just to clarify with "gcc (GCC) 4.2.0 20051129", you were able to compile the
example you gave in comment #2?

------- Comment #10 From Erik Schnetter 2006-01-24 21:09 -------
Yes, I am able to compile the code with that version:

$ ~/gcc/bin/g++ --version
g++ (GCC) 4.2.0 20051129 (experimental)

$ ~/gcc/bin/g++ -o lamtest *.ii -L/sw/lib -llammpio -llammpi++ -lmpi -llam

------- Comment #11 From Andrew Pinski 2006-01-24 22:53 -------
It was broken before "20051231".  So we are done to a month.

------- Comment #12 From Andrew Pinski 2006-01-25 00:04 -------
It worked in "20051203".

------- Comment #13 From Andrew Pinski 2006-01-25 01:06 -------
It was broken in "20051217". so only two weeks now.

------- Comment #14 From Andrew Pinski 2006-01-25 01:10 -------
Nathan sorry for CCing you (that was accident).

------- Comment #15 From Andrew Pinski 2006-01-25 02:14 -------
Fails in "20051210".

------- Comment #16 From Andrew Pinski 2006-01-25 03:40 -------
Before the breakage:
        .globl __ZTV1f
        .weak_definition __ZTV1f
        .section __DATA,__const_coal,coalesced

After:
        .globl __ZTV1f
        .const_data

We are doing two things wrong, not marking this as weak and then not putting it
into the coalesced section.

------- Comment #17 From Andrew Pinski 2006-01-25 03:51 -------
Caused by:
        (machopic_select_section): Return the selected section rather than
        emitting assembly code.  Replace the static function table with
        inline conditional expressions.  Update the tests of last_text_section
        and move them into the FUNCTION_DECL block.


I have to figure out why.

------- Comment #18 From Andrew Pinski 2006-01-25 03:58 -------
Or maybe not.  More likely the TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT changes.

------- Comment #19 From Andrew Pinski 2006-01-25 04:07 -------
I might need some C++ help on this one but I think this is valid as the virtual
function is marked as inline so it is vague but can that be a key function?

------- Comment #20 From Andrew Pinski 2006-01-25 04:39 -------
Found the problem and a way to fix it.  The problem is that the key function
needs to be changed to the  arm-eabi way and not the IA64 C++ ABI way.

See http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02645.html for the ARM-eabi
way.

------- Comment #21 From Andrew Pinski 2006-01-25 04:44 -------
To remind me, I should enable g++.dg/abi/key1.C on *-darwin.

------- Comment #22 From Andrew Pinski 2006-01-26 15:32 -------
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2006-01/msg01843.html

------- Comment #23 From Andrew Pinski 2006-02-20 23:48 -------
I am no longer going to work on this, it is too much hassle for me to get this
fixed.

------- Comment #24 From Mike Stump 2006-02-22 22:11 -------
Submitted patch to fix this
http://gcc.gnu.org/ml/gcc-patches/2006-02/msg01705.html

------- Comment #25 From mrs@gcc.gnu.org 2006-03-02 02:20 -------
Subject: Bug 25908

Author: mrs
Date: Thu Mar  2 02:20:54 2006
New Revision: 111632

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111632
Log:
        PR darwin/25908
        * decl2.c (import_export_decl): Fix ABI breakage on darwin.

        * g++.dg/abi/key2.C: Add.

Added:
    trunk/gcc/testsuite/g++.dg/abi/key2.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl2.c
    trunk/gcc/testsuite/ChangeLog

------- Comment #26 From Andrew Pinski 2006-03-02 02:27 -------
Fixed, thanks Mike for fixing this one.

First Last Prev Next    No search results available      Search page      Enter new bug