Bug 13178 – Duplicate symbol of compiler generated symbols
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2014-07-21T18:48:00Z
Last change time
2014-08-04T16:41:12Z
Assigned to
nobody
Creator
doob
Comments
Comment #0 by doob — 2014-07-21T18:48:54Z
Compiling DVM [1] worked fine with DMD 2.065.0 but with 2.066.0-b5 I get duplicate symbols, like these:
duplicate symbol _D5tango4core6Traits12__ModuleInfoZ in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-coreTraits-inline.o)
duplicate symbol _D5tango4core6Traits7__arrayZ in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-coreTraits-inline.o)
duplicate symbol _D5tango4core6Traits8__assertFiZv in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-coreTraits-inline.o)
duplicate symbol _D5tango4core6Traits15__unittest_failFiZv in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-coreTraits-inline.o)
duplicate symbol _D5tango2io4Path2FS6__initZ in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-ioPath-inline.o)
duplicate symbol _D5tango2io4Path2FS6Stamps6__initZ in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-ioPath-inline.o)
duplicate symbol _D5tango2io4Path2FS7Listing6__initZ in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-ioPath-inline.o)
duplicate symbol _D5tango2io4Path12__ModuleInfoZ in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-ioPath-inline.o)
duplicate symbol _D5tango2io4Path7__arrayZ in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-ioPath-inline.o)
duplicate symbol _D5tango2io4Path8__assertFiZv in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-ioPath-inline.o)
duplicate symbol _D5tango2io4Path15__unittest_failFiZv in:
/tmp/.rdmd-501/rdmd-dvm.d-A99850633B527F37D8244D20D34B9D7A/objs/dvm.o
/Users/doob/.dvm/compilers/dmd-2.066.0-b5/lib/libtango.a(tango-ioPath-inline.o)
ld: 11 duplicate symbols for architecture x86_64
collect2: ld returned 1 exit status
--- errorlevel 1
If I compile with the -debug flag I don't get these errors.
[1] https://github.com/jacob-carlborg/dvm
Comment #1 by bugzilla — 2014-07-25T05:32:02Z
Does this happen on any other platform?
Comment #2 by doob — 2014-07-25T20:31:44Z
(In reply to Walter Bright from comment #1)
> Does this happen on any other platform?
Yes, on Linux 64bit. But I get a lot symbol duplication error for a lot more symbols.
Comment #3 by bugzilla — 2014-07-26T06:17:11Z
(In reply to Jacob Carlborg from comment #2)
> (In reply to Walter Bright from comment #1)
> > Does this happen on any other platform?
>
> Yes, on Linux 64bit. But I get a lot symbol duplication error for a lot more
> symbols.
Could you please try to get a small test case?
Comment #4 by doob — 2014-07-26T14:18:00Z
(In reply to Walter Bright from comment #3)
> Could you please try to get a small test case?
I don't have access to my development computer right now. So I want be able to do that in the near future.
Comment #5 by public — 2014-07-27T20:50:39Z
I think this is related to https://github.com/D-Programming-Language/tools/pull/133 - tango had a special case in rdmd that got finally removed. Proper solution is to manually supply --exclude=tango in your application build script.
I will shortly prepare rdmd pull request that warns about behaviour change upon encountering `tango` package path.
(In reply to Dicebot from comment #5)
> I think this is related to
> https://github.com/D-Programming-Language/tools/pull/133 - tango had a
> special case in rdmd that got finally removed. Proper solution is to
> manually supply --exclude=tango in your application build script.
>
> I will shortly prepare rdmd pull request that warns about behaviour change
> upon encountering `tango` package path.
Does this mean I cannot use RDMD together with static libraries?
Comment #10 by public — 2014-08-04T16:23:42Z
(In reply to Jacob Carlborg from comment #9)
> Does this mean I cannot use RDMD together with static libraries?
You can but using --exclude=pkgname for those is necessary - rdmd itself can't know relation between static library file and package names of compiled sources. Phobos is excluded by default and tango was only non-standard pre-defined exclusion until recently. All other static libraries have needed it all the time.
Comment #11 by doob — 2014-08-04T16:27:12Z
(In reply to Dicebot from comment #10)
> You can but using --exclude=pkgname for those is necessary - rdmd itself
> can't know relation between static library file and package names of
> compiled sources. Phobos is excluded by default and tango was only
> non-standard pre-defined exclusion until recently. All other static
> libraries have needed it all the time.
Shouldn't the linker only search for undefined symbols in libraries? If rdmd compiled Tango it shouldn't need to search any symbols.
BTW, I think it was a bit strange that only compiler generated symbols resulted in conflicts.
Comment #12 by public — 2014-08-04T16:41:12Z
Depends on the (In reply to Jacob Carlborg from comment #11)
> Shouldn't the linker only search for undefined symbols in libraries? If rdmd
> compiled Tango it shouldn't need to search any symbols.
It does. But when it searches for undefined symbol it finds two definitions in the text section - one in local object files and one in static library. Static libraries are really nothing but just collection of object files packaged together and are processed by linker in a same way. At this point of time there is no "application vs library" distinction, just many object files to merge into single binary. This is not something D can affect.
Linker can ignore duplicates for weak symbols ('W' in nm output, usually done for templates) but those are considerably slower to process.