Comment #0 by default_357-line — 2024-03-27T17:00:41Z
Consider three files:
module test1;
import test2;
void main() { A a = A(5); }
module test2;
import test3;
struct A {
mixin Constructor;
}
module test3;
mixin template Constructor() {
this()(int i) { }
}
You can build all three in one go:
dmd test1.d test2.d test3.d -oftest
You can also build them incremental:
dmd test1.d test2.d test3.d -od. -c
dmd test1.o test2.o test3.o -oftest
But if you rebuild only test2.d:
dmd test2.d -od. -c
Then the link fails:
/usr/bin/ld: test1.o: in function `_Dmain':
test1.d:(.text._Dmain[_Dmain]+0x16): undefined reference to `_D5test21A8__mixin1__T6__ctorZQiMFNaNbNcNiNfiZSQBtQBq'
And looking at test2.o, in the first run the constructor is emitted into it (despite not being called in it!), but when building it in isolation, it is not.
`-allinst` changes nothing.
Comment #1 by robert.schadek — 2024-12-13T19:34:10Z