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

Michael Niedermayer michael at niedermayer.cc
Wed Oct 26 02:26:25 EEST 2016


On Wed, Oct 26, 2016 at 01:16:13AM +0200, Andreas Cadhalpun wrote:
> 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,
> see e.g. libavutil/attributes.h.
> 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.
> 
> > 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.
> 
> Best regards,
> Andreas
> 

>  configure |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 742684cf379693d08075d43fdfb75ed5e2e936c6  0001-configure-make-sure-LTO-does-not-optimize-out-the-te.patch
> From bb289a0b2b0948afa99227bcff188301c1143624 Mon Sep 17 00:00:00 2001
> From: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> Date: Tue, 25 Oct 2016 19:09:46 +0200
> Subject: [PATCH] configure: make sure LTO does not optimize out the test
>  functions
> 
> Fixes trac ticket #5909
> 
> Bud-Id: https://bugs.gentoo.org/show_bug.cgi?id=598054
> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
> ---
>  configure | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 481f692..54faef1 100755
> --- a/configure
> +++ b/configure
> @@ -1150,7 +1150,12 @@ check_func_headers(){
>          for func in $funcs; do
>              echo "long check_$func(void) { return (long) $func; }"
>          done
> -        echo "int main(void) { return 0; }"
> +        echo "int main(void) { int ret = 0;"
> +        # LTO could optimize out the test functions without this
> +        for func in $funcs; do
> +            echo " ret |= ((intptr_t)check_$func) & 0xFFFF;"
> +        done
> +        echo "return ret; }"

breaks configure

i get this:

ERROR: LoadLibrary/dlopen not found for avisynth

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
ffmpeg-user at ffmpeg.org mailing list or IRC #ffmpeg on irc.freenode.net.
Include the log file "config.log" produced by configure as this will help
solve the problem.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161026/fc2d517c/attachment.sig>


More information about the ffmpeg-devel mailing list