[FFmpeg-devel] [PATCH] configure: make sure LTO does not optimize out the test functions

Carl Eugen Hoyos ceffmpeg at gmail.com
Wed Oct 26 11:52:33 EEST 2016


2016-10-26 1:16 GMT+02:00 Andreas Cadhalpun <andreas.cadhalpun at googlemail.com>:
> On 25.10.2016 23:34, Carl Eugen Hoyos wrote:
>> 2016-10-25 19:19 GMT+02:00 Andreas Cadhalpun <andreas.cadhalpun at googlemail.com>:
>>
>>> +        # LTO could optimize out the test functions without this
>>> +        echo "#if defined(__GNUC__) && __GNUC__ >= 4"
>>> +        echo "  #define USED __attribute__((used))"
>>> +        echo "#else"
>>> +        echo "  #define USED"
>>> +        echo "#endif"
>>
>> Why is the ugly #if - #else - #endif necessary?
>
> I'm under the impression that __attribute__((used)) is not available
> for all compilers,

Yes, but __attribute__((foo_bar)) does not break compilation here.

> see e.g. libavutil/attributes.h.

This is not a good reference, you cannot test - for example -
icc like this.

> But thinking more about it, a better way is to actually use the functions so that
> LTO can't optimize them out. This avoids the ugly preprocessor checks.

Imo, they were only ugly as long as they were enclosed in #if - #endif ;-)

>> Please mention ticket #5909 if it is related.
>
> Sure, new patch attached.
>
> By the way, this is not a regression in 3.1.5, but a fix included in
> that release allowed them to drop their distro-specific patch,
> exposing the problem with LTO.

Yes, they are adding a few unneeded flags that make FFmpeg
slower and then they add lto to make compilation slower...

(But it is still a regression: 3.1 should not have seen the patch,
it doesn't support new incompatible external libraries, and the
issue was neither a regression nor security-related.)

Carl Eugen


More information about the ffmpeg-devel mailing list