[Issue 311] Object files missing certain template instantiations

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Oct 8 15:57:32 PDT 2006


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


kirklin.mcdonald at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Comment #3 from kirklin.mcdonald at gmail.com  2006-10-08 17:57 -------
Though DMD 0.167 did fix the case in the original bug report, this bug can
still manifest in more complex cases.

In the following example, we have a small "library" consisting of four modules,
and a piece of "client" code that imports the library and uses it.

The library has a diamond-shaped layout: "lib" imports a and b, which both
import "back".

[test.d]
import lib;

void main() {
    func_a("Hello".dup");
    func_b(34);
}

[lib.d]
public import a;
public import b;

[a.d]
private import std.stdio;
private import back;

void func_a(T) (T t) {
    writef("func_a: ");
    backend_func(t);
}

[b.d]
private import std.stdio;
private import back;

void func_b(T) (T t) {
    writef("func_b: ");
    backend_func(t);
}

[back.d]
private import std.stdio;

void backend_func(T) (T t) {
    writefln(t);
}

When compiled on Windows with DMD 0.169, we get:

>dmd -c test.d
>dmd -c a.d
>dmd -c b.d
>dmd -c back.d
>dmd -c lib.d
>dmd test.obj a.obj b.obj back.obj lib.obj
C:\dmd\dmd\bin\..\..\dm\bin\link.exe test+a+b+back+lib,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

test.obj(test)
 Error 42: Symbol Undefined __arguments_Aa
test.obj(test)
 Error 42: Symbol Undefined __arguments_i
--- errorlevel 2

Roughly equivalent (though more verbose) errors occur on Linux. The code works
fine on either platform when compiled all at once:

$ dmd test a b back lib
gcc test.o a.o b.o back.o lib.o -o test -m32 -lphobos -lpthread -lm
$ ./test
func_a: Hello
func_b: 34

It is interesting to compare sizes of the object files generated by the two
methods. This is on Linux with DMD 0.169:

Compiled all at once:

Size Name
2420 a.o
2408 b.o
2248 back.o
1204 lib.o
2828 test.o

Compiled one by one:

Size Name
1716 a.o
1716 b.o
1700 back.o
1204 lib.o
3496 test.o


-- 




More information about the Digitalmars-d-bugs mailing list