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>
next in thread | previous in thread | raw e-mail | index | archive | help
--0000000000009c575b06305147fd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=3Dyes WITHOUT_DTRACE=3Dyes sys/conf/kern.mk -flto=3Dthin (for all clang invocations) Is this the correct way to test LTO atm? Thanks, Ed Maste <emaste@freebsd.org> escreveu (sexta, 14/03/2025 =C3=A0(s) 17:29): > The branch main has been updated by emaste: > > URL: > https://cgit.FreeBSD.org/src/commit/?id=3D1cae7121c667d9caf205832cf45fd02= af3157e6f > > 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 tool= s, > 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 entir= e > executable (or library) at link time and thus allows for more effecti= ve > 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 mino= r > 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 ne= w > 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 detec= t > 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 =3D \ > LLD \ > LLD_BOOTSTRAP \ > LLVM_ASSERTIONS \ > + LLVM_BINUTILS \ > LLVM_COV \ > LLVM_CXXFILT \ > LOADER_BIOS_TEXTONLY \ > @@ -208,7 +209,6 @@ __DEFAULT_NO_OPTIONS =3D \ > HESIOD \ > LOADER_VERBOSE \ > LOADER_VERIEXEC_PASS_MANIFEST \ > - LLVM_BINUTILS \ > LLVM_FULL_DEBUGINFO \ > MALLOC_PRODUCTION \ > OFED_EXTRA \ > > --=20 Nuno Teixeira FreeBSD UNIX: <eduardo@FreeBSD.org> Web: https://FreeBSD.org --0000000000009c575b06305147fd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Hello Ed,</div><div><br></div><div>I have a newbie qu= estion about building world/kernel with LTO.</div><div>I did not found too = much info googling, but I found <a href=3D"https://wiki.freebsd.org/LinkTim= eOptimization">https://wiki.freebsd.org/LinkTimeOptimization</a> and it say= s:</div><div><p class=3D"gmail-line867">Build and link a kernel with:<span = class=3D"gmail-anchor" id=3D"gmail-line-9"></span><span class=3D"gmail-anch= or" id=3D"gmail-line-10"></span></p><p class=3D"gmail-line867">WITHOUT_CTF= =3Dyes<br>WITHOUT_DTRACE=3Dyes<br>sys/conf/<a href=3D"http://kern.mk">kern.= mk</a> -flto=3Dthin (for all clang invocations)</p></div><div>Is this the c= orrect way to test LTO atm?</div><div><br></div><div>Thanks,</div></div><br= ><div class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D= "gmail_attr">Ed Maste <<a href=3D"mailto:emaste@freebsd.org">emaste@free= bsd.org</a>> escreveu (sexta, 14/03/2025 =C3=A0(s) 17:29):<br></div><blo= ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left= :1px solid rgb(204,204,204);padding-left:1ex">The branch main has been upda= ted by emaste:<br> <br> URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D1cae7121c667d9caf= 205832cf45fd02af3157e6f" rel=3D"noreferrer" target=3D"_blank">https://cgit.= FreeBSD.org/src/commit/?id=3D1cae7121c667d9caf205832cf45fd02af3157e6f</a><b= r> <br> commit 1cae7121c667d9caf205832cf45fd02af3157e6f<br> Author:=C2=A0 =C2=A0 =C2=A0Ed Maste <emaste@FreeBSD.org><br> AuthorDate: 2021-07-12 19:32:00 +0000<br> Commit:=C2=A0 =C2=A0 =C2=A0Ed Maste <emaste@FreeBSD.org><br> CommitDate: 2025-03-14 17:29:06 +0000<br> <br> =C2=A0 =C2=A0 Enable LLVM_BINUTILS by default<br> <br> =C2=A0 =C2=A0 Starting in 2014 FreeBSD migrated from GNU binutils to ELF To= ol Chain<br> =C2=A0 =C2=A0 tools.=C2=A0 At that time there were no usable LLVM versions = of those tools,<br> =C2=A0 =C2=A0 but they have been developing rapidly since then.=C2=A0 Migra= te to LLVML's<br> =C2=A0 =C2=A0 tools for both functionality and maintainability reasons.<br> <br> =C2=A0 =C2=A0 This will eventually support the use of link-time optimizatio= n (LTO) in<br> =C2=A0 =C2=A0 the FreeBSD base system.=C2=A0 LTO runs optimization passes o= ver the entire<br> =C2=A0 =C2=A0 executable (or library) at link time and thus allows for more= effective<br> =C2=A0 =C2=A0 optimization than when performed on individual compilation un= its.<br> <br> =C2=A0 =C2=A0 When using LTO object files (.o) including those contained in= static<br> =C2=A0 =C2=A0 library archives (.a) contain LLVM IR bitcode rather than tar= get<br> =C2=A0 =C2=A0 object code.=C2=A0 This means that utilities that operate on = object files<br> =C2=A0 =C2=A0 need to support LLVM IR.<br> <br> =C2=A0 =C2=A0 As with ELF Tool Chain the LLVM tools aim for command line an= d output<br> =C2=A0 =C2=A0 format compatibility with GNU binutils, although there are a = few minor<br> =C2=A0 =C2=A0 differences.=C2=A0 Where these cause a material issue (breaki= ng a port or<br> =C2=A0 =C2=A0 eliminating required functionality) we can submit LLVM bugs a= nd work<br> =C2=A0 =C2=A0 on patches.<br> <br> =C2=A0 =C2=A0 PR:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0258872 (ex= p-run)<br> =C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 bapt<br> =C2=A0 =C2=A0 Sponsored by:=C2=A0 =C2=A0The FreeBSD Foundation<br> =C2=A0 =C2=A0 Differential Revision: <a href=3D"https://reviews.freebsd.org= /D49361" rel=3D"noreferrer" target=3D"_blank">https://reviews.freebsd.org/D= 49361</a><br> ---<br> =C2=A0UPDATING=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 |=C2=A0 5 +++++<br> =C2=A0share/man/man5/src.conf.5 | 16 ++++++++++++----<br> =C2=A0share/mk/<a href=3D"http://src.opts.mk" rel=3D"noreferrer" target=3D"= _blank">src.opts.mk</a>=C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +-<br> =C2=A03 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> =C2=A0 =C2=A0 =C2=A0 =C2=A0 world, or to merely disable the most expensive = debugging functionality<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 at runtime, run "ln -s 'abort:false,ju= nk:false' /etc/malloc.conf".)<br> <br> +20250314:<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0We now use LLVM's binary utilities (nm, obj= copy, etc.) by default.<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0The WITHOUT_LLVM_BINUTILS src.conf(5) knob can = be used to revert to<br> +=C2=A0 =C2=A0 =C2=A0 =C2=A0ELF Tool Chain tools if desired.<br> +<br> =C2=A020250303:<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Commit 4a77657cbc01 changed the ABI between ipf= w(8) and ipfw(4).<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 Please note that the old ipfw(8) binary will no= t 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> =C2=A0.\" DO NOT EDIT-- this file is @generated by tools/build/options= /makeman.<br> -.Dd January 31, 2025<br> +.Dd March 14, 2025<br> =C2=A0.Dt SRC.CONF 5<br> =C2=A0.Os<br> =C2=A0.Sh NAME<br> @@ -933,9 +933,8 @@ the build.<br> =C2=A0To be able to build the system an alternate linker must be provided v= ia XLD.<br> =C2=A0.It Va WITHOUT_LLVM_ASSERTIONS<br> =C2=A0Disable 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> =C2=A0This includes<br> =C2=A0.Xr addr2line 1 ,<br> =C2=A0.Xr ar 1 ,<br> @@ -1762,6 +1761,15 @@ When set, it enforces these options:<br> =C2=A0.It<br> =C2=A0.Va WITHOUT_LLVM_COV<br> =C2=A0.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> =C2=A0.It Va WITH_UBSAN<br> =C2=A0Build the base system with Undefined Behavior Sanitizer (UBSan) to de= tect<br> =C2=A0various kinds of undefined behavior at runtime.<br> diff --git a/share/mk/<a href=3D"http://src.opts.mk" rel=3D"noreferrer" tar= get=3D"_blank">src.opts.mk</a> b/share/mk/<a href=3D"http://src.opts.mk" re= l=3D"noreferrer" target=3D"_blank">src.opts.mk</a><br> index f3141884cd00..ef8711db713f 100644<br> --- a/share/mk/<a href=3D"http://src.opts.mk" rel=3D"noreferrer" target=3D"= _blank">src.opts.mk</a><br> +++ b/share/mk/<a href=3D"http://src.opts.mk" rel=3D"noreferrer" target=3D"= _blank">src.opts.mk</a><br> @@ -124,6 +124,7 @@ __DEFAULT_YES_OPTIONS =3D \<br> =C2=A0 =C2=A0 =C2=A0LLD \<br> =C2=A0 =C2=A0 =C2=A0LLD_BOOTSTRAP \<br> =C2=A0 =C2=A0 =C2=A0LLVM_ASSERTIONS \<br> +=C2=A0 =C2=A0 LLVM_BINUTILS \<br> =C2=A0 =C2=A0 =C2=A0LLVM_COV \<br> =C2=A0 =C2=A0 =C2=A0LLVM_CXXFILT \<br> =C2=A0 =C2=A0 =C2=A0LOADER_BIOS_TEXTONLY \<br> @@ -208,7 +209,6 @@ __DEFAULT_NO_OPTIONS =3D \<br> =C2=A0 =C2=A0 =C2=A0HESIOD \<br> =C2=A0 =C2=A0 =C2=A0LOADER_VERBOSE \<br> =C2=A0 =C2=A0 =C2=A0LOADER_VERIEXEC_PASS_MANIFEST \<br> -=C2=A0 =C2=A0 LLVM_BINUTILS \<br> =C2=A0 =C2=A0 =C2=A0LLVM_FULL_DEBUGINFO \<br> =C2=A0 =C2=A0 =C2=A0MALLOC_PRODUCTION \<br> =C2=A0 =C2=A0 =C2=A0OFED_EXTRA \<br> <br> </blockquote></div><div><br clear=3D"all"></div><br><span class=3D"gmail_si= gnature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature"><d= iv dir=3D"ltr"><div><font color=3D"#888888">Nuno Teixeira</font></div><div>= <div><font color=3D"#888888"> FreeBSD UNIX:=C2=A0 <eduardo@FreeBSD.org>=C2=A0 =C2=A0Web:=C2=A0 <a h= ref=3D"https://FreeBSD.org" rel=3D"noreferrer" target=3D"_blank">https://Fr= eeBSD.org</a><br></font></div></div></div></div> --0000000000009c575b06305147fd--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFDf7UKBe51aU9XfR%2BqWrxFncSX2fKjiQuYeNitoL8OowOpRzg>