Recommendation for LTO type (thin or full) to use for Fedora

911 views
Skip to first unread message

Tom Stellard

unread,
Jun 7, 2021, 3:36:28 PM6/7/21
to clang-bu...@googlegroups.com
Hi,

I'm working on adding an option to enable LTO in the Fedora kernel builds. I'm
not sure if I should use thin or full LTO, does anyone have any recommendations?
What do most people use?

Thanks,
Tom

Nick Desaulniers

unread,
Jun 7, 2021, 3:43:38 PM6/7/21
to Tom Stellard, clang-built-linux, android-llvm-dev
It looks like for AOSP LLVM we're using thin LTO:
https://android.googlesource.com/toolchain/llvm_android/+/refs/heads/master/builders.py#186.

I think that's the most reasonable tradeoff for generated code
performance vs build resources required. Full LTO may produce a
faster binary, but I personally don't think it's worth the additional
build time cost. YMMV
--
Thanks,
~Nick Desaulniers

Nick Desaulniers

unread,
Jun 7, 2021, 3:46:04 PM6/7/21
to Tom Stellard, clang-built-linux, android-llvm-dev
On Mon, Jun 7, 2021 at 12:43 PM Nick Desaulniers
<ndesau...@google.com> wrote:
>
> On Mon, Jun 7, 2021 at 12:36 PM Tom Stellard <tste...@redhat.com> wrote:
> >
> > Hi,
> >
> > I'm working on adding an option to enable LTO in the Fedora kernel builds. I'm

Oh, kernel builds (not builds of LLVM), sorry, I just noticed that
after I sent my reply. Android Common Kernel is using full LTO, but
also pares down their configs a bit so the compile time of full LTO
isn't too bad. I think thinLTO is preferable and the full LTO doesn't
buy you enough for the cost; but if you're doing raw performance
comparisons, full LTO might be better. If you're just doing daily
builds for regression testing, thinLTO is probably sufficient. Local
developers prefer thinLTO or disabling LTO entirely while doing local
builds.

> > not sure if I should use thin or full LTO, does anyone have any recommendations?
> > What do most people use?
>
> It looks like for AOSP LLVM we're using thin LTO:
> https://android.googlesource.com/toolchain/llvm_android/+/refs/heads/master/builders.py#186.
>
> I think that's the most reasonable tradeoff for generated code
> performance vs build resources required. Full LTO may produce a
> faster binary, but I personally don't think it's worth the additional
> build time cost. YMMV
> --
> Thanks,
> ~Nick Desaulniers



--
Thanks,
~Nick Desaulniers

Kees Cook

unread,
Jun 8, 2021, 1:51:53 PM6/8/21
to Tom Stellard, clang-bu...@googlegroups.com
ThinLTO is used by Android and is much less resource-heavy at build
time. Full LTO exists as an option mostly to be able to a/b test results
and bugs. :)

--
Kees Cook

Nick Desaulniers

unread,
Jun 8, 2021, 2:02:20 PM6/8/21
to Kees Cook, Tom Stellard, clang-built-linux
No. FullLTO is used by Android. Android Common Kernel made this Full
LTO for S (within the past 2 weeks or so). Every pixel that had an
LTO kernel has shipped with full LTO.
--
Thanks,
~Nick Desaulniers

Kees Cook

unread,
Jun 8, 2021, 2:08:58 PM6/8/21
to Nick Desaulniers, samito...@google.com, Tom Stellard, clang-built-linux
O_o

I defer to Sami, but ThinLTO is going to be much nicer on your builders.
:)

--
Kees Cook

Jesse Chan

unread,
Jun 9, 2021, 8:04:15 AM6/9/21
to Clang Built Linux
Indeed, Android uses full LTO for production kernel [1].

From our experience with AOSP, Kernel is not part of the AOSP build process. It is developed and built separately and then used as prebuilt [2] (TARGET_PREBUILT_KERNEL or  BOARD_USES_GENERIC_KERNEL_IMAGE [3] in DT), so platform people probably don't have to worry too much about the increased build time.

Though, custom Android distributions like LineageOS did build kernel as part of the process [4], and the greatly increased build time is a huge headache, so we disable LTO when the variant is "eng" or simply use ThinLTO. 

Thanks,
Reply all
Reply to author
Forward
0 new messages