Re: LTO

From: Shawn Webb <shawn.webb_at_hardenedbsd.org>
Date: Wed, 28 Feb 2024 17:46:52 UTC
On Wed, Feb 28, 2024 at 05:06:08PM +0000, void wrote:
> On Wed, Feb 28, 2024 at 07:50:59PM +0300, Gleb Popov wrote:
> 
> > ...
> 
> Thank you!
> 
> Is LTO buildable/usable/enable-able for base?

HardenedBSD 14-STABLE and 15-CURRENT build all applications and
libraries in base with thick LTO (-flto). (With one eexception on
15-CURRENT: libc--but that's related to some fallout related to recent
libc/csu/libsys changes in FreeBSD, the goal is to re-enable LTO for
libc soon.)

The problem you'll find with building libraries in base with LTO is
that those ports that use alternative toolchains might break--mainly
if they link with static libraries (.a files) from base. gcc doesn't
read/parse LLVM IR bitcode files.

You might even see some issues with different versions of the same
toolchain. For example, if llvm in base is at version 16, but the port
requests llvm-from-ports version 15, then the port might not build.
llvm's LTO ABI isn't forward compatible.

The reason HardenedBSD builds base libs and apps with LTO is for
future support of Cross-DSO CFI. I've worked on Cross-DSO CFI support
slowly over the past few years, and there's still a long ways to go.

Hopefully that helps.

Thanks,

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

Tor-ified Signal: +1 303-901-1600
https://git.hardenedbsd.org/hardenedbsd/pubkeys/-/raw/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc