[Issue 22804] New: [REG 2.099] compiling mutliple files without linking produces broken object files

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 21 22:30:12 UTC 2022


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

          Issue ID: 22804
           Summary: [REG 2.099] compiling mutliple files without linking
                    produces broken object files
           Product: D
           Version: D2
          Hardware: All
                OS: Windows
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

Compile these two files:

// xfile.d
module file;

// xstring.d
module xstring;

string[] tokenizeArgs(string text)
{
        return [];
}

///////

with

> dmd -m32mscoff -c xfile.d xstring.d 

and link them with

// main.d
import xstring;

void main(string[] args)
{
        auto arr = tokenizeArgs(args[0]);
}

via

> dmd -m32mscoff main.d xfile.obj xstring.obj

causes

xstring.obj : error LNK2005: __D5xfile12__ModuleInfoZ already defined in
xfile.obj
main.obj : error LNK2019: unresolved external symbol
__D7xstring12tokenizeArgsFAyaZAQf referenced in function __Dmain
main.exe : fatal error LNK1120: 1 unresolved externals
Error: linker exited with status 1120

a) xstring.obj contains a definition for the module xfile

b) the symbol for tokenizeArgs is missing from xstring.obj

Looking at the object files, it seems xfile,obj is repeated inside of
xstring.obj

--


More information about the Digitalmars-d-bugs mailing list