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