http://d.puremagic.com/issues/show_bug.cgi?id=3274

           Summary: dmd fails to emit code for templates into object file
                    if several files are compiled at once
           Product: D
           Version: 1.046
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: nfx...@gmail.com


If you compile several files at once, and the files instantiate the same
template, dmd outputs the code for that template only into one object file.

This breaks incremental compilation with tools like rebuild/dsss.

ldc doesn't suffer from this bug, and outputs the template code into all
corresponding object files.

Reproduction of that bug:

First put the files listed at the end of the bug report into a.d, b.d and c.d.
Then execute these steps (order of files is important):
1. dmd a.d b.d c.d -c -version=XX
2. dmd a.d -c
   (without version XX -> like a change to the source code; because b.d and c.d
don't depend from a.d, you shouldn't need to recompile it.)
3. dmd a.o b.o c.o

Step 3 gives the error:
b.o: In function `_D1b1xFZv':
b.d:(.text._D1b1xFZv+0x4): undefined reference to
`_D1c13__T6from_cTiZ6from_cFZv'
collect2: ld returned 1 exit status
--- errorlevel 1

If Step 2. is left out, the error doesn't happen. If you compile all files
separately in Step 1, the error doesn't happen.

-- file a.d:
module a;

import b;
import c;

void main() {
    version (XX) {
        from_c!(int)();
    }
}

-- file b.d:
module b;

import c;

void x() {
    from_c!(int)();
}

-- file c.d:
module c;

void from_c(T)() {
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to