http://bugzilla.gdcproject.org/show_bug.cgi?id=199
Johannes Pfau <johannesp...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED CC| |johannesp...@gmail.com --- Comment #1 from Johannes Pfau <johannesp...@gmail.com> --- I think we can't fix this. Does this work with DMD or LDC? The problem is this: We already build the ModuleInfo chain by emitting one c constructor per module. This means all unittests are referenced by ModuleInfos which are referenced by c constructors which are always kept in the executable by linker scripts. This enures that, as long as you link all objects explicitly, all unittests will be linked in, even without explicitly importing modules. However, this does not work for code in static libraries because c constructors in static libraries do not work: http://stackoverflow.com/questions/1202494/why-doesnt-attribute-constructor-work-in-a-static-library The linker only looks at object files in static libraries if it searches an undefined symbol. If all symbols are defined, it does not search the object files. Now you want this to work without imports in your main application. But how could gdc know, when compiling the main applications which additional modules might exists in a static library? If we know module X exists we can add an reference to force the linker. But in your case we explicitly do not know about additional modules so we can't add a reference. You can use the same workarounds C++ uses though: http://stackoverflow.com/a/4767951/471401 Use it with GDC like this: gdc -funittest main.d -Wl,--whole-archive libtest.a -Wl,--no-whole-archive -- You are receiving this mail because: You are watching all bug changes.