www.digitalmars.com         C & C++   DMDScript  

D.gnu - My D cross-compiler for wince generates huge binary

reply Vincent Richomme <forumer smartmobili.com> writes:
Hi,

When trying o build a simple D program with a wince cross compiler the 
generated binary is about 1 MB for a simple MessageBox.


$> arm-mingw32ce-gdc test.d -O2 -o testD.exe
$>ls -la
-rwxr-xr-x 1 Vincent Aucun 1231211 Aug 15 16:16 testD.exe

I don't understand why the binary is so big ? Is it normal ?
Maybe it's because of D runtime and in this case how can I build it as a 
shared lib ?
Aug 15 2008
next sibling parent Vincent Richomme <forumer smartmobili.com> writes:
Vincent Richomme a écrit :
 Hi,
 
 When trying o build a simple D program with a wince cross compiler the 
 generated binary is about 1 MB for a simple MessageBox.
 
 
 $> arm-mingw32ce-gdc test.d -O2 -o testD.exe
 $>ls -la
 -rwxr-xr-x 1 Vincent Aucun 1231211 Aug 15 16:16 testD.exe
 
 I don't understand why the binary is so big ? Is it normal ?
 Maybe it's because of D runtime and in this case how can I build it as a 
 shared lib ?
 

because on wince/mingw libstdc++ is statically linked so I wonder if it couln't be an explanation. But I don't think it can explain everything ...
Aug 15 2008
prev sibling parent reply David Friedman <dvdfrdmn users.ess-eff.net> writes:
Vincent Richomme wrote:
 Hi,
 
 When trying o build a simple D program with a wince cross compiler the 
 generated binary is about 1 MB for a simple MessageBox.
 
 
 $> arm-mingw32ce-gdc test.d -O2 -o testD.exe
 $>ls -la
 -rwxr-xr-x 1 Vincent Aucun 1231211 Aug 15 16:16 testD.exe
 
 I don't understand why the binary is so big ? Is it normal ?
 Maybe it's because of D runtime and in this case how can I build it as a 
 shared lib ?
 

D executables tend to be large because of the garbage collector and the fact that the library modules generate monolith objects. You can mitigate the latter problem by building Phobos (and your apps) with -ffunction-sections and -fdata-sections. Then use -Wl,-gc-sections in the link command. Also: Have you tried stripping the executable? David
Aug 15 2008
parent reply Vincent Richomme <forumer smartmobili.com> writes:
David Friedman a écrit :
 Vincent Richomme wrote:
 Hi,

 When trying o build a simple D program with a wince cross compiler the 
 generated binary is about 1 MB for a simple MessageBox.


 $> arm-mingw32ce-gdc test.d -O2 -o testD.exe
 $>ls -la
 -rwxr-xr-x 1 Vincent Aucun 1231211 Aug 15 16:16 testD.exe

 I don't understand why the binary is so big ? Is it normal ?
 Maybe it's because of D runtime and in this case how can I build it as 
 a shared lib ?

D executables tend to be large because of the garbage collector and the fact that the library modules generate monolith objects. You can mitigate the latter problem by building Phobos (and your apps) with -ffunction-sections and -fdata-sections. Then use -Wl,-gc-sections in the link command. Also: Have you tried stripping the executable? David

I have tried to strip it and now I get 242 kB but it's far too big for emebedded world. I would prefer to split things, I mean would it be possible to have on one side a shared lib emebedding garbage collector and on the other side user applications ?
Aug 16 2008
parent David Friedman <dvdfrdmn users.ess-eff.net> writes:
Vincent Richomme wrote:
 David Friedman a écrit :
 Vincent Richomme wrote:
 Hi,

 When trying o build a simple D program with a wince cross compiler 
 the generated binary is about 1 MB for a simple MessageBox.


 $> arm-mingw32ce-gdc test.d -O2 -o testD.exe
 $>ls -la
 -rwxr-xr-x 1 Vincent Aucun 1231211 Aug 15 16:16 testD.exe

 I don't understand why the binary is so big ? Is it normal ?
 Maybe it's because of D runtime and in this case how can I build it 
 as a shared lib ?

D executables tend to be large because of the garbage collector and the fact that the library modules generate monolith objects. You can mitigate the latter problem by building Phobos (and your apps) with -ffunction-sections and -fdata-sections. Then use -Wl,-gc-sections in the link command. Also: Have you tried stripping the executable? David

I have tried to strip it and now I get 242 kB but it's far too big for emebedded world. I would prefer to split things, I mean would it be possible to have on one side a shared lib emebedding garbage collector and on the other side user applications ?

It should be possible to build Phobos as a dll.
Aug 16 2008