Hello Ed, I have a newbie question about building world/kernel with LTO. I did not found too much info googling, but I found https://wiki.freebsd.org/LinkTimeOptimization and it says:
Build and link a kernel with: WITHOUT_CTF=yes WITHOUT_DTRACE=yes sys/conf/kern.mk -flto=thin (for all clang invocations) Is this the correct way to test LTO atm? Thanks, Ed Maste <ema...@freebsd.org> escreveu (sexta, 14/03/2025 à(s) 17:29): > The branch main has been updated by emaste: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=1cae7121c667d9caf205832cf45fd02af3157e6f > > commit 1cae7121c667d9caf205832cf45fd02af3157e6f > Author: Ed Maste <ema...@freebsd.org> > AuthorDate: 2021-07-12 19:32:00 +0000 > Commit: Ed Maste <ema...@freebsd.org> > CommitDate: 2025-03-14 17:29:06 +0000 > > Enable LLVM_BINUTILS by default > > Starting in 2014 FreeBSD migrated from GNU binutils to ELF Tool Chain > tools. At that time there were no usable LLVM versions of those tools, > but they have been developing rapidly since then. Migrate to LLVML's > tools for both functionality and maintainability reasons. > > This will eventually support the use of link-time optimization (LTO) in > the FreeBSD base system. LTO runs optimization passes over the entire > executable (or library) at link time and thus allows for more effective > optimization than when performed on individual compilation units. > > When using LTO object files (.o) including those contained in static > library archives (.a) contain LLVM IR bitcode rather than target > object code. This means that utilities that operate on object files > need to support LLVM IR. > > As with ELF Tool Chain the LLVM tools aim for command line and output > format compatibility with GNU binutils, although there are a few minor > differences. Where these cause a material issue (breaking a port or > eliminating required functionality) we can submit LLVM bugs and work > on patches. > > PR: 258872 (exp-run) > Reviewed by: bapt > Sponsored by: The FreeBSD Foundation > Differential Revision: https://reviews.freebsd.org/D49361 > --- > UPDATING | 5 +++++ > share/man/man5/src.conf.5 | 16 ++++++++++++---- > share/mk/src.opts.mk | 2 +- > 3 files changed, 18 insertions(+), 5 deletions(-) > > diff --git a/UPDATING b/UPDATING > index 15941028c5bb..6989bb7c7f99 100644 > --- a/UPDATING > +++ b/UPDATING > @@ -27,6 +27,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 15.x IS SLOW: > world, or to merely disable the most expensive debugging > functionality > at runtime, run "ln -s 'abort:false,junk:false' /etc/malloc.conf".) > > +20250314: > + We now use LLVM's binary utilities (nm, objcopy, etc.) by default. > + The WITHOUT_LLVM_BINUTILS src.conf(5) knob can be used to revert to > + ELF Tool Chain tools if desired. > + > 20250303: > Commit 4a77657cbc01 changed the ABI between ipfw(8) and ipfw(4). > Please note that the old ipfw(8) binary will not work with the new > diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 > index 30b5d308724a..321eea708d04 100644 > --- a/share/man/man5/src.conf.5 > +++ b/share/man/man5/src.conf.5 > @@ -1,5 +1,5 @@ > .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. > -.Dd January 31, 2025 > +.Dd March 14, 2025 > .Dt SRC.CONF 5 > .Os > .Sh NAME > @@ -933,9 +933,8 @@ the build. > To be able to build the system an alternate linker must be provided via > XLD. > .It Va WITHOUT_LLVM_ASSERTIONS > Disable debugging assertions in LLVM. > -.It Va WITH_LLVM_BINUTILS > -Install LLVM's binutils (without an llvm- prefix), > -instead of ELF Tool Chain's tools. > +.It Va WITHOUT_LLVM_BINUTILS > +Install ELF Tool Chain's binary utilities instead of LLVM's. > This includes > .Xr addr2line 1 , > .Xr ar 1 , > @@ -1762,6 +1761,15 @@ When set, it enforces these options: > .It > .Va WITHOUT_LLVM_COV > .El > +.Pp > +When set, these options are also in effect: > +.Pp > +.Bl -inset -compact > +.It Va WITHOUT_LLVM_BINUTILS > +(unless > +.Va WITH_LLVM_BINUTILS > +is set explicitly) > +.El > .It Va WITH_UBSAN > Build the base system with Undefined Behavior Sanitizer (UBSan) to detect > various kinds of undefined behavior at runtime. > diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk > index f3141884cd00..ef8711db713f 100644 > --- a/share/mk/src.opts.mk > +++ b/share/mk/src.opts.mk > @@ -124,6 +124,7 @@ __DEFAULT_YES_OPTIONS = \ > LLD \ > LLD_BOOTSTRAP \ > LLVM_ASSERTIONS \ > + LLVM_BINUTILS \ > LLVM_COV \ > LLVM_CXXFILT \ > LOADER_BIOS_TEXTONLY \ > @@ -208,7 +209,6 @@ __DEFAULT_NO_OPTIONS = \ > HESIOD \ > LOADER_VERBOSE \ > LOADER_VERIEXEC_PASS_MANIFEST \ > - LLVM_BINUTILS \ > LLVM_FULL_DEBUGINFO \ > MALLOC_PRODUCTION \ > OFED_EXTRA \ > > -- Nuno Teixeira FreeBSD UNIX: <edua...@freebsd.org> Web: https://FreeBSD.org