develooper Front page | perl.perl5.porters | Postings from November 2022

GCC link time optimizations (LTO)

Thread Next
From:
Niko Tyni
Date:
November 17, 2022 20:04
Subject:
GCC link time optimizations (LTO)
Message ID:
Y3aTvlsrVQ4B4HI0@estella.local.invalid
Hello porters,

as discussed in GH#20518 [1] many Linux distributions are adopting
(or rather have already adopted) GCC Link Time Optimization [2-6] when
building packages. This is enabled by the -flto compile and link flags.

Unfortunately, building perl with LTO currently leads to a couple of
test failures in t/porting/libperl.t when building on x86 and linking
libperl statically (so making a libperl.a in the process). This is why
I filed an issue about this. Jim requested there I bring it up on p5p.

I'm not much of an expert here, but quoting the Debian Wiki [3]:

  Link time optimization (LTO) is a way to run optimizations across
  multiple translation units, enabling more opportunities for
  optimizations at link time. Each source file is translated to an
  intermediate representation, which is then used at link to build an
  executable or a shared object/library. The optimizations allow for
  faster code and smaller files.

Debian has not yet enabled this by default. Ubuntu has, and i believe they
have already made a long time support release (22.04) where perl was built
with LTO. They just disabled the failing tests. In Debian we now need
to decide whether to follow suit or to disable LTO for the perl package.

I don't know Fedora or openSUSE much, but AFAICT from browsing some
sources and build logs Fedora is building only a shared libperl.so so
they are not encountering the failures, and openSUSE is probably opting
out of LTO for the perl package.

As Dave already pointed out in the ticket, the failures are due to a few
symbol changes in libperl.a . I have no idea how expected or invasive
those changes are. Maybe somebody here on the list does?

  t/porting/libperl ................................................
  # Failed test 3 - has data const symbols at porting/libperl.t line 322
  # Failed test 4 - has PL_no_mem at porting/libperl.t line 323
  FAILED at test 3

TBH I doubt libperl.a as shipped in Debian (or Ubuntu for that matter)
is really used much for anything besides making /usr/bin/perl.  We also
build a shared libperl.so and link all packaged applications embedding
perl against that.

[1] https://github.com/Perl/perl5/issues/20518
[2] https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
[3] https://wiki.debian.org/ToolChain/LTO
[4] https://wiki.ubuntu.com/ToolChain/LTO
[5] https://fedoraproject.org/wiki/LTOByDefault
[6] https://en.opensuse.org/openSUSE:LTO

Thanks for any insight,
-- 
Niko Tyni   ntyni@debian.org

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About