Bug 3364 – module with unittest forces entire import chain

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-10-05T05:59:32Z
Last change time
2019-08-10T18:39:58Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
anonymous4

Comments

Comment #0 by dfj1esp02 — 2009-10-05T05:59:32Z
This bug forces link of any module that indirectly imports any module with unittest (nearly ANY module) even when I compile without -unittest switch. It forced me to link in a module working with registry, thus forcing dependency on extra library advapi32.dll even when I didn't use anything from that module, this just killed me. I'm not sure whether this is one bug or two, but together they are fearful. test.d --- import test2; int main() { return 0; } --- test2.d --- module test2; import test3; --- test3.d --- module test3; import test4; extern void Foo(); void Goo() { switch("c") { case "a": break; //comment this line case "b": break; case "c": break; case "d": break; default: break; } Foo(); } --- test4.d --- module test4; unittest { } --- As you see, the main module does basically nothing, everything compiles, but doesn't link. First I tried this command. >dmd test.d -oftest.exe OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. test.obj(test) Error 42: Symbol Undefined _D5test212__ModuleInfoZ --- errorlevel 1 It clearly misses test2 module. But why? test2 is nearly empty, there's nothing to link from there! Linker doesn't calm down until you compile and link all 4 modules. Then... >dmd test.d test2.d test3.d test4.d -oftest.exe OPTLINK (R) for Win32 Release 8.00.1 Copyright (C) Digital Mars 1989-2004 All rights reserved. test.obj(test) Error 42: Symbol Undefined _D5test33FooFZv --- errorlevel 1 Now comment case "a" line in test3 and it links. I don't understand, why.
Comment #1 by dfj1esp02 — 2009-10-05T06:04:16Z
dmd test.d -oftest.exe must link the testcase because there's nothing to link from other modules.
Comment #2 by pro.mathias.lang — 2019-08-10T18:39:58Z
This test case now compiles successfully.