Walter Bright wrote:
The problem appears to be that optlink cannot deal correctly with weak references. I've modified the compiler to not emit weak references, and the problem goes away. It's not a perfect fix, but it works.

With the modified compiler, does the following link? If so, is the output correct?

----
module a;
import c;
alias C!(int) aC;
import b;

extern(C) int printf(char*, ...);

void main() {
        printf("&aC.x == %x"\n, &aC.x);
        printf("&bC.x == %x"\n, &bC.x);
        assert (&aC.x is &bC.x);
}
----
module b;
import c;
alias C!(int) bC;
----
module c;
template C(T) {
        int x;
}
----
dmd -c a.d
dmd -c b.d
dmd -c c.d
dmd a.obj b.obj c.obj
a.exe
----

I'm getting:
&aC.x == 419c30
&bC.x == 419c30

I'm afraid that it might refuse to link and then even if OPTLINK allowed multiple strong symbols of the same name, I'd expect the assertion to fail. Aren't weak symbols essential to properly handling templates?

Of course compiling the modules together causes only one symbol to be emitted for the template instantiations. Yet this is not an option for a larger project, since compilation times and memory usage can get rather high.


--
Tomasz Stachowiak
http://h3.team0xf.com/
h3/h3r3tic on #D freenode

Reply via email to