[Issue 4767] New: dmd generates useless template bloat

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 29 20:36:24 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4767

           Summary: dmd generates useless template bloat
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: nfxjfg at gmail.com


--- Comment #0 from nfxjfg at gmail.com 2010-08-29 20:36:13 PDT ---
Merely importing a file that contains template can make dmd generate code. This
not only increases compile times, but it also can be the reason for severe exe
bloat: often the linker will pull in completely unrelated modules just to get
symbols for instantiated templates (the bloat is then caused by unrelated
symbols that have been unnecessarily been pulled in).

$ cat a.d
module a;
import b;

$ cat b.d
module b;

struct Bloat(T)
{
    void foo() {
    }
}

class NotBloat
{
    this(Bloat!(uint) x)
    {
    }
}

$ dmd -c a.d

$ nm a.o|grep Bloat
00000000 W _D1b12__T5BloatTkZ5Bloat3fooMFZv
00000000 V _D1b12__T5BloatTkZ5Bloat6__initZ
00000000 V _D32TypeInfo_S1b12__T5BloatTkZ5Bloat6__initZ

a.d only imports b.d, yet there's this crap in a.o.

Obviously dmd should not generate code in this case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list