www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4767] New: dmd generates useless template bloat

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: nfxjfg gmail.com



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: -------
Aug 29 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4767


nfxjfg gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4767


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr puremagic.com
         Resolution|WONTFIX                     |


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 06 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4767


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



21:39:51 PDT ---
What matters is what gets into the exe file, not what's in the object files.

To that end, if you use dmd to generate a library file from source, it will
split each object file into multiple ones (one for each global symbol). Then,
only the referenced symbols get pulled in.

It's not a perfect solution, but it's a start.

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