Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 509552 - =x11-libs/cairo-1.12.16-r3 could disable LTO USE flag on memory-restricted arches
Summary: =x11-libs/cairo-1.12.16-r3 could disable LTO USE flag on memory-restricted ar...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo X packagers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-04 15:05 UTC by Xavier Miller (RETIRED)
Modified: 2014-05-04 17:52 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xavier Miller (RETIRED) gentoo-dev 2014-05-04 15:05:03 UTC
even with LTO disabled, it fails on Raspberry pi rev 1 (256 MB). Previous version is OK, I don't use LTO !!!

>>> Verifying ebuild manifests
>>> Running pre-merge checks for x11-libs/cairo-1.12.16-r3
 * Checking for sufficient memory to build cairo with USE=lto
 * Checking for at least 768 MiB RAM ...                                 [ !! ]
 * There is NOT at least 768 MiB RAM


Reproducible: Always
Comment 1 Xavier Miller (RETIRED) gentoo-dev 2014-05-04 15:07:53 UTC
it seems IUSE=+lto in that new version.

Please disable LTO in memory-restricted arches.
Comment 2 Xavier Miller (RETIRED) gentoo-dev 2014-05-04 15:15:28 UTC
it passes by setting USE="-lto" in make.conf
Comment 3 Alex Xu (Hello71) 2014-05-04 16:00:58 UTC
    <flag name="lto">Try to build with Link-Time Optimization if supported by
        the compiler. This is recommended by upstream, but can cause build
        failure in some environments and on machines with little memory.</flag>
Comment 4 Tom Wijsman (TomWij) (RETIRED) gentoo-dev 2014-05-04 16:10:20 UTC
(In reply to Xavier Miller from comment #1)
> Please disable LTO in memory-restricted arches.

This sounds like a reasonable request; though, are there architectures that only have low memory devices available? Every time I see a bug like this I start to like the ideas of mixins (eg. a lowmemory mixin) and/or board specific profiles (eg. a Raspberry Pi profile) more and more.
Comment 5 Alex Xu (Hello71) 2014-05-04 16:15:40 UTC
(In reply to Tom Wijsman (TomWij) from comment #4)
> (In reply to Xavier Miller from comment #1)
> > Please disable LTO in memory-restricted arches.
> 
> This sounds like a reasonable request; though, are there architectures that
> only have low memory devices available? Every time I see a bug like this I
> start to like the ideas of mixins (eg. a lowmemory mixin) and/or board
> specific profiles (eg. a Raspberry Pi profile) more and more.

I think the only thing we can do here is give a better error message.
Comment 6 Alexandre Rostovtsev (RETIRED) gentoo-dev 2014-05-04 16:19:08 UTC
Previous versions of cairo *always* built with lto, and *always* failed for people trying to build e.g. on machines with 320M memory and no swap.

I tried to measure memory usage on amd64 with USE=lto and different gcc versions, and got figures between 500MB and 650MB, so marked the minimum memory requirements as 768M to be safe. But I don't have access to an arm machine, maybe lto on arm is more memory-efficient. Could you test how much it takes on the Raspberry Pi?

To measure, get the memusg script from https://gist.github.com/netj/526585 and run

# USE=lto I_KNOW_WHAT_I_AM_DOING=yes bash memusg.sh emerge -1 cairo
Comment 7 Alexandre Rostovtsev (RETIRED) gentoo-dev 2014-05-04 16:35:22 UTC
Or even simpler (as suggested by Alex Xu):

# USE=lto I_KNOW_WHAT_I_AM_DOING=yes busybox time -v emerge -1 cairo

and look at the "Maximum resident set size" line.
Comment 8 Rémi Cardona (RETIRED) gentoo-dev 2014-05-04 16:41:16 UTC
(In reply to Alexandre Rostovtsev from comment #7)
> I_KNOW_WHAT_I_AM_DOING=yes

Please! No more! Gentoo users, *by definition*, should know what they're doing. While a nice error message is a welcome improvement, we should not prevent people from shooting themselves in the feet *if they so choose*. And I believe LTO falls into that category.

My humble 2 euro cents. :)
Comment 9 Alexandre Rostovtsev (RETIRED) gentoo-dev 2014-05-04 16:45:30 UTC
(In reply to Rémi Cardona from comment #8)

Unlike most packages in the tree, cairo's upstream build system injects -flto if it detects that the compiler supports it. It's a completely different case from someone shooting themselves in the foot by enabling lto globally in CFLAGS in their make.conf.
Comment 10 Xavier Miller (RETIRED) gentoo-dev 2014-05-04 17:25:43 UTC
(In reply to Alexandre Rostovtsev from comment #6)
> Previous versions of cairo *always* built with lto, and *always* failed for
> people trying to build e.g. on machines with 320M memory and no swap.
> 
> I tried to measure memory usage on amd64 with USE=lto and different gcc
> versions, and got figures between 500MB and 650MB, so marked the minimum
> memory requirements as 768M to be safe. But I don't have access to an arm
> machine, maybe lto on arm is more memory-efficient. Could you test how much
> it takes on the Raspberry Pi?
> 
> To measure, get the memusg script from https://gist.github.com/netj/526585
> and run
> 
> # USE=lto I_KNOW_WHAT_I_AM_DOING=yes bash memusg.sh emerge -1 cairo

memusg: peak=108448

BUT this is a X-less version (headless system, cairo used by cups), using distcc:

[ebuild   R    ] x11-libs/cairo-1.12.16-r3  USE="glib lto svg -X (-aqua) -debug -directfb (-drm) (-gallium) (-gles2) -legacy-drivers -opengl -openvg (-qt4) -static-libs -valgrind -xcb -xlib-xcb" 0 kB
Comment 11 Alexandre Rostovtsev (RETIRED) gentoo-dev 2014-05-04 17:52:55 UTC
(In reply to Xavier Miller from comment #10)

Well, on a headless system, cairo should not be enabling lto by default - squeezing out maximum performance matters when you are using gtk-based graphical applications and cairo is responsible for most of the rendering work.

I think the best way to solve this is to enable USE=lto by default only in desktop profiles (and hopefully, people running a desktop profile have a machine with sufficient memory).

+  04 May 2014; Alexandre Rostovtsev <tetromino@gentoo.org>
+  targets/desktop/package.use:
+  Enable cairo LTO by default only for desktop profiles, bug #509552

+  04 May 2014; Alexandre Rostovtsev <tetromino@gentoo.org>
+  cairo-1.12.16-r3.ebuild, cairo-9999.ebuild:
+  Do not enable LTO by default everywhere (bug #509552); it will be enabled by
+  default in profiles where needed.