diff mbox

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

Message ID 8019a3b4-c436-a2fa-8d58-b7d387af4190@googlemail.com
State Superseded
Headers show

Commit Message

Andreas Cadhalpun Oct. 25, 2016, 5:19 p.m. UTC
Bud-Id: https://bugs.gentoo.org/show_bug.cgi?id=598054
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 configure | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Carl Eugen Hoyos Oct. 25, 2016, 9:34 p.m. UTC | #1
2016-10-25 19:19 GMT+02:00 Andreas Cadhalpun <andreas.cadhalpun@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?

Please mention ticket #5909 if it is related.

Carl Eugen
diff mbox

Patch

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