We were not using LTO to build the various runtime libraries. Enabling
this is a no-brainer.
I did measure the code size changes in the hopes that it would provide
an improvement in the size of the dylib. However, after stripping the
dylibs, there is no improvement:
File Without LTO (-O2 -g) With Thin LTO (-flto=thin -O2 -g)
libc++.1.0.dylib 1.0M 1.0M
libc++.a 9.2M 12M
libc++abi.1.0.dylib 252K 252K
libc++abi.a 1.5M 2.0M
The static archives become larger, however this is expected since we
are now including more information that would allow LTO to happen when
users produce their final linked image.
Note that this patch does not enable LTO for libunwind, because this
currently crashes when trying to link libunwind.dylib. I followed up
with linker folks to investigate the issue.