<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 24, 2015 at 3:12 PM, chen xu <span dir="ltr"><<a href="mailto:chenxuz@outlook.com" target="_blank">chenxuz@outlook.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr"><div>Thanks, David.  <span style="font-size:12pt">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?</span></div></div></div></blockquote><div><br></div><div>Yep, -gsplit-dwarf - latest versions of GDB can cope with this debug info<br><br>You can also compress the debug info: -Wa,--compress-debug-sections<br><br>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).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr"><div><span style="font-size:12pt"> </span><span style="font-size:12pt">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. </span></div></div></div></blockquote><div><br></div><div>Not sure, off hand, whether Clang supports that.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="ltr"><div><br><div><hr>Date: Wed, 23 Sep 2015 16:59:04 -0700<br>Subject: Re: [cfe-users] optimize template-heavy project with duplicate code removal<br>From: <a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a><br>To: <a href="mailto:chenxuz@outlook.com" target="_blank">chenxuz@outlook.com</a><br>CC: <a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><div><div class="h5"><br><br><div dir="ltr">debug or non-debug build?<div><br></div><div>& no, for a full release build, measuring the final executable size, there's not much you can do with the compiler.<br><br>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)</div></div><div><br><div>On Wed, Sep 23, 2015 at 4:43 PM, chen xu via cfe-users <span dir="ltr"><<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a>></span> wrote:<br><blockquote style="border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">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?                                         </div></div>
<br>_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@lists.llvm.org" target="_blank">cfe-users@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users</a><br>
<br></blockquote></div><br></div></div></div></div></div>                                           </div></div>
</blockquote></div><br></div></div>