Re: [cfe-users] optimize template-heavy project with duplicate code removal

2015-09-24 Thread chen xu via cfe-users
Thanks, David.  The build type is Debug. Today I tried removing the debug info 
(-g), the size of the executable could be cut 90%, to around 100MB, which looks 
not bad. Do you know whether there is a way to separate debug info file from 
the executable file on Linux? Mainly our code is already there, refactoring 
might require big effort.. Also, does clang support -fno-implicit-templates? if 
yes, maybe we could use it to eliminate duplicate template instances to control 
the final size. 
Date: Wed, 23 Sep 2015 16:59:04 -0700
Subject: Re: [cfe-users] optimize template-heavy project with duplicate code 
removal
From: dblai...@gmail.com
To: chen...@outlook.com
CC: cfe-users@lists.llvm.org

debug or non-debug build?
& no, for a full release build, measuring the final executable size, there's 
not much you can do with the compiler.

you can try to factor common portions out of your templates (eg: remove 
template parameters where possible - if, for example, a member function of a 
class template doesn't need all the template parameters - pull it out into a 
standalone function template that takes fewer template parameters, and call it 
from the member one)
On Wed, Sep 23, 2015 at 4:43 PM, chen xu via cfe-users 
 wrote:



Hi, our project heavily uses c++ template, and the resulting executable is 
almost 1.5G Bytes, which is too big to be acceptable. Adding -O2 or -Os does 
not seem helping. Is there any way (like link option, etc) to reduce the size?  
  

___

cfe-users mailing list

cfe-users@lists.llvm.org

http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users



  ___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] optimize template-heavy project with duplicate code removal

2015-09-24 Thread David Blaikie via cfe-users
On Thu, Sep 24, 2015 at 3:12 PM, chen xu  wrote:

> Thanks, David.  The build type is Debug. Today I tried removing the debug
> info (-g), the size of the executable could be cut 90%, to around 100MB,
> which looks not bad. Do you know whether there is a way to separate debug
> info file from the executable file on Linux?
>

Yep, -gsplit-dwarf - latest versions of GDB can cope with this debug info

You can also compress the debug info: -Wa,--compress-debug-sections

If you want linked debug info (rather than split debug info), consider
enabling type units to deduplicate debug info in your final executable
(-fdebug-types-section).


>  Mainly our code is already there, refactoring might require big effort..
> Also, does clang support -fno-implicit-templates? if yes, maybe we could
> use it to eliminate duplicate template instances to control the final size.
>

Not sure, off hand, whether Clang supports that.


>
> --
> Date: Wed, 23 Sep 2015 16:59:04 -0700
> Subject: Re: [cfe-users] optimize template-heavy project with duplicate
> code removal
> From: dblai...@gmail.com
> To: chen...@outlook.com
> CC: cfe-users@lists.llvm.org
>
>
> debug or non-debug build?
>
> & no, for a full release build, measuring the final executable size,
> there's not much you can do with the compiler.
>
> you can try to factor common portions out of your templates (eg: remove
> template parameters where possible - if, for example, a member function of
> a class template doesn't need all the template parameters - pull it out
> into a standalone function template that takes fewer template parameters,
> and call it from the member one)
>
> On Wed, Sep 23, 2015 at 4:43 PM, chen xu via cfe-users <
> cfe-users@lists.llvm.org> wrote:
>
> Hi, our project heavily uses c++ template, and the resulting executable is
> almost 1.5G Bytes, which is too big to be acceptable. Adding -O2 or -Os
> does not seem helping. Is there any way (like link option, etc) to reduce
> the size?
>
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
>
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] optimize template-heavy project with duplicate code removal

2015-09-24 Thread chen xu via cfe-users



That's very helpful. Thanks a lot. I will try them out. 
By the way, when linking two libraries, say, they both instantiate classes from 
the same template class (e.g. defined in a 'common' component), into an 
executable, will the linker remove the duplicate class instance?  

Date: Thu, 24 Sep 2015 15:29:09 -0700
Subject: Re: [cfe-users] optimize template-heavy project with duplicate code 
removal
From: dblai...@gmail.com
To: chen...@outlook.com
CC: cfe-users@lists.llvm.org



On Thu, Sep 24, 2015 at 3:12 PM, chen xu  wrote:



Thanks, David.  The build type is Debug. Today I tried removing the debug info 
(-g), the size of the executable could be cut 90%, to around 100MB, which looks 
not bad. Do you know whether there is a way to separate debug info file from 
the executable file on Linux?
Yep, -gsplit-dwarf - latest versions of GDB can cope with this debug info

You can also compress the debug info: -Wa,--compress-debug-sections

If you want linked debug info (rather than split debug info), consider enabling 
type units to deduplicate debug info in your final executable 
(-fdebug-types-section).  Mainly our code is already there, refactoring might 
require big effort.. Also, does clang support -fno-implicit-templates? if yes, 
maybe we could use it to eliminate duplicate template instances to control the 
final size. 
Not sure, off hand, whether Clang supports that. 
Date: Wed, 23 Sep 2015 16:59:04 -0700
Subject: Re: [cfe-users] optimize template-heavy project with duplicate code 
removal
From: dblai...@gmail.com
To: chen...@outlook.com
CC: cfe-users@lists.llvm.org

debug or non-debug build?
& no, for a full release build, measuring the final executable size, there's 
not much you can do with the compiler.

you can try to factor common portions out of your templates (eg: remove 
template parameters where possible - if, for example, a member function of a 
class template doesn't need all the template parameters - pull it out into a 
standalone function template that takes fewer template parameters, and call it 
from the member one)
On Wed, Sep 23, 2015 at 4:43 PM, chen xu via cfe-users 
 wrote:



Hi, our project heavily uses c++ template, and the resulting executable is 
almost 1.5G Bytes, which is too big to be acceptable. Adding -O2 or -Os does 
not seem helping. Is there any way (like link option, etc) to reduce the size?  
  

___

cfe-users mailing list

cfe-users@lists.llvm.org

http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users



  


  ___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users