Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 566282 - media-video/ffmpeg fails to build with LTO - "--enable-lto" configure option is missing
Summary: media-video/ffmpeg fails to build with LTO - "--enable-lto" configure option ...
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: media-video herd
Depends on:
Reported: 2015-11-20 02:19 UTC by Jan Chren (rindeal)
Modified: 2019-02-26 21:15 UTC (History)
1 user (show)

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


Note You need to log in before you can comment on or make changes to this bug.
Description Jan Chren (rindeal) 2015-11-20 02:19:31 UTC
I'm using GCC 5.2 with LTO enabled and unless I edit the ebuild to include "--enable-lto" flag in the ./configure arguments, it fails to build with various errors during the final linking stage.

I've edited the ebuild to include something like this:

if is-flag flto; then
    myconf+=( --enable-flto )

It affects all versions in the tree.
Comment 1 Jan Chren (rindeal) 2015-11-22 21:45:03 UTC
Also, all my LTO builds have "--enable-flto" in "EXTRA_ECONF", but unfortunately ffmpeg ebuilds do not use econf.
Comment 2 Alexis Ballier gentoo-dev 2016-01-05 08:34:57 UTC
commit caed356beda25dacd829f7988c2b8b1011583111
Author: Alexis Ballier <>
Date:   Tue Jan 5 09:26:56 2016 +0100

    media-video/ffmpeg: Pass --enable-lto to configure if -flto is in *FLAGS.
    Fixes build with lto.
    Package-Manager: portage-2.2.26
    Signed-off-by: Alexis Ballier <>

Comment 3 Steffen Hau 2016-01-06 14:24:43 UTC
The fix does not apply when -flto is set to a value for concurrency:

The is-flagq function in eclass/flag-o-matic.eclass checks for equality:
+ [[ -flto=5 == -flto ]]

So in my case --enable-lto will not be added to $myconf.
Comment 4 Jan Chren (rindeal) 2016-01-06 21:20:29 UTC
Actually, my local overlay contains this:

if is-flagq '-flto*'; then
    myconf+=( --enable-lto )

***notice the star***
Comment 5 Alexis Ballier gentoo-dev 2016-01-07 07:33:28 UTC
commit 326cefdf8855ccef084426e4581ebae1af4989e2
Author: Alexis Ballier <>
Date:   Thu Jan 7 08:32:47 2016 +0100

    media-video/ffmpeg: check -flto* for enabling lto, instead of only flto. Bug #566282 by rindeal & Steffen Hau.
    Package-Manager: portage-2.2.26
    Signed-off-by: Alexis Ballier <>

thx :)
Comment 6 Jan Chren (rindeal) 2016-01-08 22:01:50 UTC
sorry for such late idea, but what if someone had `-flto -fno-lto` in their *FLAGS? GCC prefers -fno-* flags. So (hopefully) the final check should be:

if ! is-flagq '-fno-lto' && is-flagq '-flto*'; then
    myconf+=( --enable-lto )
Comment 7 Ragas 2019-02-26 21:15:51 UTC
Can this be changed to the solution that Jan Chren proposed?

For me ffmpeg does not compile even with --enable-flto but I still want to have -flto set as the default.

So I have a package environment that adds "-fno-lto" only for ffmpeg and end up with exactly the "-flto -fno-lto" case that Jan Chren described.