Bugzilla – Bug 1141647
AC_CHECK_FUNC broken by -flto2
Last modified: 2019-11-08 10:31:10 UTC
During the debug of package fwnn, I found that the check for existing functions with AC_CHECK_FUNC always succeeds. Looking into this, I found, that this seems to be caused by -flto=2. In particular, the function closesocket is considered existing, but it actually is not there. After removing -flto=2 for the testcompile, the correct results are found. Maybe we should make sure that for autoconf, no link time optimization is active.
For me AC_CHECK_FUNC expands to char closesocket (); int main() { return closesocket (); } which should fail to link if closesocket is not available. Maybe your autoconf is too old, not doing a function call but doing sth else?
Indeed: /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ #include <assert.h> /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); char (*f) (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else f = $ac_func; #endif ; return 0; } the global variable 'f' is unused and thus elided by -flto, removing the reference to the function we want to check for. Making 'f' volatile would also help.
char (* volatile f) (); in particular.
Any progress on that one ?
I found that the current autoconf can handle this. However, fwnn delivers an old configure script that is just too old. Created sr #725078 to update the fwnn package to use autoreconf -fi which lets the package build again.
This bug is resolved imho.