From 3b605b8f060ff1b8e124894e5e84d99a0e09607f Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 17 Sep 2008 16:15:54 +0100 Subject: [PATCH] Don't import _externals from every module We were doing this to get access to the logger, but this leads to a subtle problem: - If a module has a static constructor, it needs a ModuleInfo structure. - If a module imports a module with a ModuleInfo structure, it needs one too, and it also needs access to that module's ModuleInfo (I think it chains them together). - tango.io.Console has a static constructor. If _externals imports tango.io.Console then it needs ModuleInfo. Everything that imports _externals then needs ModuleInfo, which is everything. Including third party libraries, which then fail to link. Conflicts: dmd/module.c --- dmd/module.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/dmd/module.c b/dmd/module.c index f60af92..3cc4053 100644 --- a/dmd/module.c +++ b/dmd/module.c @@ -691,15 +691,33 @@ void Module::semantic() //printf("Module = %p, linkage = %d\n", sc->scopesym, sc->linkage); + // Find Main class + for (i = 0; i < members->dim; i++) + { Dsymbol *s; + + s = (Dsymbol *)members->data[i]; + + if (s->ident && s->ident == Id::Main) { + Dsymbol *mainFn = addMainFunction(s); + if (!mainFn) + return; + members->push(mainFn); + + Import *im = new Import(0, NULL, Id::_externals, NULL, true); + members->shift(im); + + break; + } + } + // Add import of "object" if this module isn't "object" if (ident != Id::object) { Import *im = new Import(0, NULL, Id::object, NULL, 0); members->shift(im); - // For logging + if (ident != Id::_externals) { - Import *im = new Import(0, NULL, Id::_externals, NULL, true); - members->shift(im); + // Logging? } } #ifdef IN_GCC @@ -723,22 +741,6 @@ void Module::semantic() } #endif - // Find Main class - for (i = 0; i < members->dim; i++) - { Dsymbol *s; - - s = (Dsymbol *)members->data[i]; - - if (s->ident && s->ident == Id::Main) { - Dsymbol *mainFn = addMainFunction(s); - if (!mainFn) - return; - members->push(mainFn); - - break; - } - } - // Add all symbols into module's symbol table symtab = new DsymbolTable(); for (i = 0; i < members->dim; i++) -- 2.11.4.GIT