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 ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2015-11-20 02:19 UTC by .
Modified: 2022-08-01 22:30 UTC (History)
1 user (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 . 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 )
fi
```

It affects all versions in the tree.
Comment 1 . 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 <aballier@gentoo.org>
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.
    https://bugs.gentoo.org/show_bug.cgi?id=566282
    
    Package-Manager: portage-2.2.26
    Signed-off-by: Alexis Ballier <aballier@gentoo.org>


thx!
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 . 2016-01-06 21:20:29 UTC
Actually, my local overlay contains this:

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

***notice the star***
Comment 5 Alexis Ballier gentoo-dev 2016-01-07 07:33:28 UTC
commit 326cefdf8855ccef084426e4581ebae1af4989e2
Author: Alexis Ballier <aballier@gentoo.org>
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 <aballier@gentoo.org>

thx :)
Comment 6 . 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 )
fi
```
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.
Comment 8 Jason Chan 2019-10-28 05:26:13 UTC
Something strange is going on with my ebuild tool.  

For 4.2.1, ./ffbuild/pkgconfig_generate.sh is expecting to source
Comment 9 Jason Chan 2019-10-28 05:32:15 UTC
Sorry! Didn't mean to send that. LTO is still failing in 4.2.1 because ./ffbuild/config.sh has libdir=${something}/lib and ./ffbuild/pkgconfig_generate.sh is sourcing that (so setting --libdir isn't helping). The linking stage will fail because ffmpeg will try linking x86_64 libs with x86, correct me if I'm wrong.

For some reason, config.sh and other files aren't populating at any ebuild stage so I'm at a loss on continuing.