[LLVMdev] LLVM project binary size

Gordon Henriksen gordonhenriksen at mac.com
Mon May 26 06:48:24 PDT 2008


Hi Nicholas,

On May 26, 2008, at 02:29, Nicolas Capens wrote:

> I realize LLVM is a complex and feature rich project but could  
> anyone give me a rough idea of where most of the executable size is  
> coming from, and maybe give some ideas on how to reduce it if  
> possible?

'nm' can give you this information on Unix. I don't know what the  
equivalent in the VS toolchain is.

> It’s not like 2.6 MB is huge but it just seems disproportionate and  
> I’d like to keep my project lightweight (it could be used for  
> embedded systems one day). Note that I’m basically only using the  
> IRBuilder, JIT, and a few common optimization passes. Removing the  
> optimizations doesn’t seem to affect the executable size at all, so  
> I’m starting to wonder whether there are a lot of other unused  
> features ending up in the binary (I’m using Visual C++ 2005 by the  
> way, which is supposed to be quite good at reducing code size).  
> Maybe there is some way to explicitly disable unused features (not  
> compile them or use stubs)? I’m also under the impression that LLVM  
> uses a lot of static (pre-generated) tables, and maybe they could be  
> somewhat smaller when making some extra assumptions?

Make sure that you're passing /opt:ref to link.exe. Otherwise,  
unreferenced code within the static libraries will be retained. The  
same goes on Unix, though the requisite flags to ld are platform- 
dependent. LLVM is fairly accommodating to unreferenced code omission,  
but a stripped-down JIT is still close to the size you show.

— Gordon





More information about the llvm-dev mailing list