Index: object_.d =================================================================== --- object_.d (revision 315) +++ object_.d (working copy) @@ -26,6 +26,7 @@ import core.stdc.stdlib; import rt.util.hash; import rt.util.string; + import rt.util.console; debug(PRINTF) import core.stdc.stdio; extern (C) void onOutOfMemoryError(); @@ -1767,6 +1768,7 @@ if (m.flags & MIctorstart) { if (skip || m.flags & MIstandalone) continue; + _printModuleCycle(null); throw new Exception("Cyclic dependency in module " ~ m.name); } @@ -1789,6 +1791,39 @@ } } +extern(C) void _printModuleCycle(ubyte[] flags) +{ + console("Modules in detected cycle:\n"); + _printRunningModCtors(_moduleinfo_array, flags); +} + +extern(C) void _printRunningModCtors(ModuleInfo *[] mi, ubyte[] flags) +{ + for (uint i = 0; i < mi.length; i++) + { + ModuleInfo* m = mi[i]; + + if (!m) + continue; + uint mflags = (flags == null) ? m.flags : flags[m.index]; + if (mflags & MIctordone) + continue; + + + if (mflags & MIctorstart) + { + console("\t")(m.name)("\n"); + if(flags == null) + m.flags = mflags & ~MIctorstart; + else + flags[m.index] &= ~MIctorstart; + + _printRunningModCtors(m.importedModules, flags); + + } + } +} + /******************************************** * Run static constructors for thread local global data. */ @@ -1827,6 +1862,7 @@ if (flags[m.index] & MIctorstart) { if (skip || m.flags & MIstandalone) continue; + _printModuleCycle(flags); throw new Exception("Cyclic dependency in module " ~ m.name); }