https://issues.dlang.org/show_bug.cgi?id=22651
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch Component|phobos |dmd Hardware|x86_64 |All See Also| |https://issues.dlang.org/sh | |ow_bug.cgi?id=17181 OS|Linux |All --- Comment #2 from [email protected] --- smaller reproducer: /// common.d template myimported() { import myctor; } /// myctor.d shared static this(){} /// empty.d import common; /// main.d import common; alias x = myimported!(); import empty; void main(){} compile: "dmd main.d common.d myctor.d", gives an undefined symbol error for _D5empty12__ModuleInfoZ i'm not 1000% familiar with this stuff but i think what happens in the original example is 1. using imported!"", a module is imported that has a module constructor - this causes the "needmoduleinfo" flag to be set for a bunch of modules including "object" (it's not normally set for object) 2. a module is imported that doesn't have a ModuleInfo symbol and isn't included in compilation - it inherits the needmoduleinfo flag from object (which it implicitly imports) and linking fails because there's no ModuleInfo symbol for it the thing the patch does to fix this is copied from here: https://github.com/dlang/dmd/blob/375ed51/src/dmd/dsymbolsem.d#L1283-L1292 - it causes "needmoduleinfo" to be set for the module that uses imported!"" instead of the module that defines it the link error in the original example is for std.internal.memory which indeed doesn't have a ModuleInfo symbol inside libphobos2.so --
