[patch] Dead-strip binaries by default on OS X and posix (was: Reduce size of clang-format by 87% on OS X)

Nico Weber thakis at chromium.org
Fri Dec 27 11:12:40 PST 2013


On Thu, Dec 26, 2013 at 10:04 PM, Chandler Carruth <chandlerc at google.com>wrote:

>
> On Fri, Dec 27, 2013 at 1:02 AM, Chandler Carruth <chandlerc at google.com>wrote:
>
>> Have you checked the other binary size reductions? I wonder why we didn't
>> do this sooner.
>>
>
> Oh, of course, you did this just for clang-format.
>
> Can we instead do this for all LLVM projects by default, and opt maybe
> 'clang', 'opt', 'llc', and 'bugpoint' out of it to support dlopen'ed passes
> and plugins?
>

Something like the attached patch? (Make-only again, but now including the
linux bits. If folks like it, I can do the cmake part as a followup.)

This adds -ffunction-sections -fdata-sections unconditionally, since most
tools have few source files anyways and mostly link in static libs. This
reduces the size of e.g. diagtool from 21 MB to 2.8 MB and clang-format
from 22 MB to 1.8 MB (these numbers are on Linux). libclang.so drops from
29MB to 20MB, but from skimming through `vim -d <(nm old-libclang.so) <(nm
new-libclang.so)` only mangled symbols are getting dropped, and the
libclang makefile sets EXPORTED_SYMBOL_FILE, and tests pass, so hopefully
nothing necessary is getting dropped.

The size of libclang.a grows from 1.6 MB to 2 MB, as you'd expect with
-ffunction-sections. The size of other .a files increases similarly:
libclangARCMigrate goes from 5.9 MB to 8.9 MB, libclangAST.a from 8.1 MB to
11 MB, and so on. This is probably acceptable?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131227/77c89464/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deadstrip-llvm.patch
Type: application/octet-stream
Size: 3273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131227/77c89464/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deadstrip-clang.patch
Type: application/octet-stream
Size: 1128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131227/77c89464/attachment-0001.obj>


More information about the llvm-commits mailing list