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

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Tue Oct 25 20:19:42 EEST 2016


Bud-Id: https://bugs.gentoo.org/show_bug.cgi?id=598054
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 configure | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 481f692..14a20ed 100755
--- a/configure
+++ b/configure
@@ -1147,8 +1147,14 @@ check_func_headers(){
         for hdr in $headers; do
             print_include $hdr
         done
+        # 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"
         for func in $funcs; do
-            echo "long check_$func(void) { return (long) $func; }"
+            echo "USED long check_$func(void) { return (long) $func; }"
         done
         echo "int main(void) { return 0; }"
     } | check_ld "cc" "$@" && enable $funcs && enable_safe $headers
-- 
2.9.3


More information about the ffmpeg-devel mailing list