www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DMD1 binaries a lot bigger than DMD2 due to weird zero blocks?

reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
Consider a simple "Hello, world" program:

import std.c.stdio;

void main()
{
	printf("Hello, world!\n");
}

When compiled with DMD 1.062 and DMD 2.047:

C:\Downloads\dmd.1.062\dmd\windows\bin> dmd hello.d
C:\Downloads\dmd.1.062\dmd\windows\bin> ls -l hello.exe
-rwxrwxrwx  1 Vladimir 0 177180 2010-08-05 02:17 hello.exe

C:\Downloads\dmd.2.047\dmd2\windows\bin> dmd hello.d
C:\Downloads\dmd.2.047\dmd2\windows\bin> ls -l hello.exe
-rwxrwxrwx  1 Vladimir 0 101404 2010-08-05 02:19 hello.exe

Notice that there is a 74 KB difference. A quick look with a hex editor /  
disassembler reveals multiple zero-filled blocks between functions.

What is causing this? Both versions use the same linker, so it would have  
to be caused by DMD or the precompiled libraries?

-- 
Best regards,
  Vladimir                            mailto:vladimir thecybershadow.net
Aug 04 2010
next sibling parent reply Don <nospam nospam.com> writes:
Vladimir Panteleev wrote:
 Consider a simple "Hello, world" program:
 When compiled with DMD 1.062 and DMD 2.047:
 
 C:\Downloads\dmd.1.062\dmd\windows\bin> dmd hello.d
 C:\Downloads\dmd.1.062\dmd\windows\bin> ls -l hello.exe
 -rwxrwxrwx  1 Vladimir 0 177180 2010-08-05 02:17 hello.exe
 
 C:\Downloads\dmd.2.047\dmd2\windows\bin> dmd hello.d
 C:\Downloads\dmd.2.047\dmd2\windows\bin> ls -l hello.exe
 -rwxrwxrwx  1 Vladimir 0 101404 2010-08-05 02:19 hello.exe
 
 Notice that there is a 74 KB difference. A quick look with a hex editor 
 / disassembler reveals multiple zero-filled blocks between functions.
 
 What is causing this? Both versions use the same linker, so it would 
 have to be caused by DMD or the precompiled libraries?
 
It _might_ be caused by bug 1914, which was fixed in D2, but the patch was not applied to D1. An n-element array literal gets stored n times in the exe...
Aug 05 2010
parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Thu, 05 Aug 2010 10:06:55 +0300, Don <nospam nospam.com> wrote:

 It _might_ be caused by bug 1914, which was fixed in D2, but the patch  
 was not applied to D1. An n-element array literal gets stored n times in  
 the exe...
Applying your patch against DMD 1.062's source code does not resolve the issue. The generated binaries remain identical before and after the patch. (Are you sure that's the right bug? 1914 seems to only affect arrays inside structs, no?) -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Aug 05 2010
parent Don <nospam nospam.com> writes:
Vladimir Panteleev wrote:
 On Thu, 05 Aug 2010 10:06:55 +0300, Don <nospam nospam.com> wrote:
 
 It _might_ be caused by bug 1914, which was fixed in D2, but the patch 
 was not applied to D1. An n-element array literal gets stored n times 
 in the exe...
Applying your patch against DMD 1.062's source code does not resolve the issue. The generated binaries remain identical before and after the patch. (Are you sure that's the right bug? 1914 seems to only affect arrays inside structs, no?)
It was just a guess. I created test cases for that bug which increased exe size by several megabytes. Sounds like you're seeing something else.
Aug 05 2010
prev sibling next sibling parent Leandro Lucarella <luca llucax.com.ar> writes:
Vladimir Panteleev, el  5 de agosto a las 02:23 me escribiste:
 Consider a simple "Hello, world" program:
 
 import std.c.stdio;
 
 void main()
 {
 	printf("Hello, world!\n");
 }
 
 When compiled with DMD 1.062 and DMD 2.047:
 
 C:\Downloads\dmd.1.062\dmd\windows\bin> dmd hello.d
 C:\Downloads\dmd.1.062\dmd\windows\bin> ls -l hello.exe
 -rwxrwxrwx  1 Vladimir 0 177180 2010-08-05 02:17 hello.exe
 
 C:\Downloads\dmd.2.047\dmd2\windows\bin> dmd hello.d
 C:\Downloads\dmd.2.047\dmd2\windows\bin> ls -l hello.exe
 -rwxrwxrwx  1 Vladimir 0 101404 2010-08-05 02:19 hello.exe
 
 Notice that there is a 74 KB difference. A quick look with a hex
 editor / disassembler reveals multiple zero-filled blocks between
 functions.
 
 What is causing this? Both versions use the same linker, so it would
 have to be caused by DMD or the precompiled libraries?
I had a weird problem, a program became 3x slower after a small change, that couldn't cause that. Adding a line of code to an unrelated function that wasn't even executed (one of the tests I done was putting abort() as that extra line), make the program behaves the same as before the change. My only guess was that the compiler is aligning differently in the binary or something, but I never reported the bug because it was impossible to narrow down to a small test case. -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- In 1995 a Japanese trawler sank, because a Russian cargo plane dropped a living cow from 30,000 feet
Aug 05 2010
prev sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
It seems to be caused by the standard library. An executable created from  
an object file compiled by dmd1 but linked by dmd2 does not exhibit the  
size problem.

-- 
Best regards,
  Vladimir                            mailto:vladimir thecybershadow.net
Aug 05 2010