[Issue 18066] New: regression: duplicate symbol __Dmain : worked in dmd.071.2, fails in dmd.072

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 12 02:29:20 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=18066

          Issue ID: 18066
           Summary: regression: duplicate symbol __Dmain : worked in
                    dmd.071.2, fails in dmd.072
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: timothee.cour2 at gmail.com

it worked in dmd2_071_2, it fails in dmd2_072_0.

reduced case:
```
fun1.d:
module fun1;
import std.file; // NOTE: other modules (eg std.stdio) don't have this error

fun2.d:
module fun2;

main_aux.d:
module main_aux; void main(){}
```

```
dmd -of=./build//app.o -c -g fun1.d fun2.d main_aux.d
libtool -static ./build//app.o -o ./build//libapp.a
dmd -of=./build//app -g -L./build//libapp.a main_aux.d

duplicate symbol __Dmain in:
    ./build//app.o
    ./build//libapp.a(app.o)
duplicate symbol _D8main_aux12__ModuleInfoZ in:
    ./build//app.o
    ./build//libapp.a(app.o)
duplicate symbol _D8main_aux7__arrayZ in:
    ./build//app.o
    ./build//libapp.a(app.o)
duplicate symbol _D8main_aux8__assertFiZv in:
    ./build//app.o
    ./build//libapp.a(app.o)
duplicate symbol _D8main_aux15__unittest_failFiZv in:
    ./build//app.o
    ./build//libapp.a(app.o)
duplicate symbol _main in:
    ./build//app.o
    ./build//libapp.a(app.o)
```


NOTE: works if building library directly in this particular case, eg:
`dmd -of=./build//libapp.a -lib -g fun1.d fun2.d main_aux.d`
but this isn't always desirable to do so.

NOTE: I am passing main_aux.d twice but this shouldn't be a problem because
it's first passed as ".o" and then as part of a ".a" which should avoid
duplicate symbol errors:
https://stackoverflow.com/questions/34454355/why-doesnt-the-linker-complain-of-duplicate-symbols

NOTE: this pattern (recompiling a file already part of a library) is
*essential* to support speedy partial recompilation and avoid recompiling the
whole app (eg if we want to speed up edit/recompile cycle) and must be
supported.

--


More information about the Digitalmars-d-bugs mailing list