Bug 1141647 - AC_CHECK_FUNC broken by -flto2
AC_CHECK_FUNC broken by -flto2
Classification: openSUSE
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: Development
Other Other
: P5 - None : Normal (vote)
: ---
Assigned To: Mike FABIAN
E-mail List
Depends on:
Blocks: 1133084
  Show dependency treegraph
Reported: 2019-07-16 12:10 UTC by Berthold Gunreben
Modified: 2019-11-08 10:31 UTC (History)
4 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Berthold Gunreben 2019-07-16 12:10:44 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.
Comment 1 Richard Biener 2019-08-15 14:30:22 UTC
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?
Comment 2 Richard Biener 2019-08-15 14:33:46 UTC

/* 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"
/* 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; }
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
f = $ac_func;

  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.
Comment 3 Richard Biener 2019-08-15 14:34:32 UTC
char (* volatile f) ();

in particular.
Comment 4 Michel Normand 2019-08-21 13:31:55 UTC
Any progress on that one ?
Comment 5 Berthold Gunreben 2019-08-21 13:48:27 UTC
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.
Comment 6 Berthold Gunreben 2019-11-08 10:31:10 UTC
This bug is resolved imho.