Thread overview | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 09, 2011 [Issue 6461] New: multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6461 Summary: multiple definitions with typeid and multiobj Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: dawg@dawgfoto.de --- Comment #0 from dawg@dawgfoto.de 2011-08-09 15:43:49 PDT --- --- tmpl.d: module tmpl; struct Tmpl(T) { T a; } ---- a.d: module a; import tmpl; TypeInfo fun() { return typeid(Tmpl!int()); } --- b.d: module b; import tmpl; TypeInfo fun() { return typeid(Tmpl!long()); } --- main.d: import a, b; void main() { auto t1 = a.fun(); auto t2 = b.fun(); assert(t1 != t2); } reproduce: dmd -lib -ofliba.a a dmd -lib -oflibb.a b dmd main -L-L. -L-la -L-lb This bug is caused by Type::getTypeInfo causing a call to obj_append while already being in a deferred genobjfile. The appended symbol is not marked as doppelganger module thus writes out ModuleAssert, ModuleArray et al. Now two different libraries can end up with colliding definitions if count in obj_write_deferred is accidentally the same. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 10, 2011 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 --- Comment #1 from dawg@dawgfoto.de 2011-08-09 18:55:28 PDT --- This bug is not caused by the late obj_append but is a direct consequence of the special handling for Dsymbols that don't have a module in obj_write_deferred. It seems for the D case that TypeInfos are the only DSymbols that don't have a module. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 30, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 Martin Nowak <code@dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |verylonglogin.reg@gmail.com --- Comment #2 from Martin Nowak <code@dawg.eu> 2013-05-30 08:02:26 PDT --- *** Issue 9044 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 30, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 Martin Nowak <code@dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |major -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 30, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 --- Comment #3 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-05-30 22:13:21 MSD --- Change the title please as if Issue 9044 is dup of this, there is no need to generate multiple object files and the issue can be triggered in dmd itself, not in the linker. Also there is no need for `typeid` (at least in user code) as shown in Rainer's example. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 30, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 Rainer Schuetze <r.sagitario@gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |r.sagitario@gmx.de --- Comment #4 from Rainer Schuetze <r.sagitario@gmx.de> 2013-05-30 11:53:13 PDT --- > Also there is no need for `typeid` (at least in user code) as shown in Rainer's example. The "new" implicitely accesses typeid, so I think Martin is correct in marking the issues as duplicates. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 30, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 --- Comment #5 from Martin Nowak <code@dawg.eu> 2013-05-30 11:54:37 PDT --- (In reply to comment #3) > Change the title please as if Issue 9044 is dup of this, there is no need to generate multiple object files It's multiobj not multiple objects and in fact you need at least two archives. > and the issue can be triggered in dmd itself, not in the linker. True > Also there is no need for `typeid` (at least in user code) > as shown in Rainer's example. It happens when TypeInfo instances are emitted, because they are not put into a doppelgänger module, i.e. the object contains definitions for assert, unittest_fail, ModuleInfo. For these TypeInfo instances s->getModule() returns NULL. https://github.com/D-Programming-Language/dmd/blob/20655f957f3729298b79e6c695b9d7840ac5ef0f/src/glue.c#L116 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 30, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 --- Comment #6 from Rainer Schuetze <r.sagitario@gmx.de> 2013-05-30 12:14:03 PDT --- Generating a UUID instead of the simple static counter in obj_write_deferred seems to fix the problem. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 31, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 --- Comment #7 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-05-31 10:28:04 MSD --- (In reply to comment #5) > (In reply to comment #3) > > Change the title please as if Issue 9044 is dup of this, there is no need to generate multiple object files > > It's multiobj not multiple objects and in fact you need at least two archives. Sorry my ignorance, but I sill not sure I understand the terminology. The library produced by `dmd -lib a.b b.d` is multiobj and contains two archives? I thought the library is an archive... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
May 31, 2013 [Issue 6461] multiple definitions with typeid and multiobj | ||||
---|---|---|---|---|
| ||||
Posted in reply to dawg@dawgfoto.de | http://d.puremagic.com/issues/show_bug.cgi?id=6461 --- Comment #8 from Rainer Schuetze <r.sagitario@gmx.de> 2013-05-30 23:58:45 PDT --- "multiobj" is a term used in the compiler source when a module is split into multiple object files (one for each function) to allow linking only referenced functions. It is enabled when you bulid with "-lib". So "dmd -lib a.d" produces a library with 4 objects. If you then run "dmd -lib b.d a.lib", dmd does the same for b.d and then merges the other lib a.lib into b.lib. Doing so it detects the multiple definitions. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation