https://issues.dlang.org/show_bug.cgi?id=16291
Johannes Pfau <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #20 from Johannes Pfau <[email protected]> --- > as nothing directly referring to module ctors, linker just doesn't know that > it > should not optimize 'em away. maybe we can fix that by emiting some flag > for .o > files, but i don't really know -- i never even read about dwarf > object file > format, so i'm not sure if such flag exists. The constructors are referenced by the ModuleInfo. ModuleInfo is theoretically unreferenced which will cause issues with --gc-sections, but as long as you don't use --gc-sections that doesn't matter. (LDC has a workaround, IIRC) The problem in this case is that the linker does not even attempt to link in the object file though. The linker only looks at object files in a static library if it still has some unresolved symbols. A solution is using the whole archive linker option: http://stackoverflow.com/questions/805555/ld-linker-question-the-whole-archive-option As you said this will result in bigger executables though. --
