Project

General

Profile

Actions

Bug #15595

closed

configure.in fails to detect isinf() and finite() when they are macros

Added by luizluca (Luiz Angelo Daros de Luca) almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:91487]

Description

Hello,

While building ruby with uclibc (openwrt), ./configure fails to detect isinf() and finite() as
AC_REPLACE_FUNCS(isinf) uses AC_CHECK_FUNCS() which simply tries to link that function.
Obviously, a macro will fail to link. I'm still not sure why isnan() passes as it is
also defined as a macro in uclibc <math.h>.

...
checking for finite... no
checking for flock... yes
checking for hypot... yes
checking for isinf... no
checking for isnan... yes
...

Similar problems was already reported as in https://bugs.ruby-lang.org/issues/4999.
Maybe the changes related to that is why isnan passes (but not others).

If those functions are not detected, ruby includes independent implementations, which conflicts with
existing ones.

There is a dirty workaround forcing configure vars, but it is not ideal:

	ac_cv_func_finite=yes
	ac_cv_func_isinf=yes
	ac_cv_func_isnan=yes

I'm not an autoconf expert and one of the best matches google gave me was this:
https://lists.gnu.org/archive/html/autoconf/2008-12/msg00010.html

It recommends to use AC_CHECK_DECLS instead of AC_REPLACE_FUNCS and replace
HAVE_<FUNC> with HAVE_DECL_<FUNC>,

I did a quick patch replacing AC_REPLACE_FUNCS with AC_CHECK_DECLS. It fixed the problem and
ruby compiled. However, instead of replacing HAVE_<FUNC> with HAVE_DECL_<FUNC>, I
manually set HAVE_<FUNC> when detected.

--- a/configure.ac
+++ b/configure.ac
@@ -2212,11 +2212,14 @@ AC_REPLACE_FUNCS(dup2)
 AC_REPLACE_FUNCS(erf)
 AC_REPLACE_FUNCS(explicit_bzero)
 AC_REPLACE_FUNCS(ffs)
-AC_REPLACE_FUNCS(finite)
+#AC_REPLACE_FUNCS(finite)
+AC_CHECK_DECLS([finite], [AC_DEFINE(HAVE_FINITE)], [AC_LIBOBJ(finite)], [[#include <math.h>]])
 AC_REPLACE_FUNCS(flock)
 AC_REPLACE_FUNCS(hypot)
-AC_REPLACE_FUNCS(isinf)
-AC_REPLACE_FUNCS(isnan)
+#AC_REPLACE_FUNCS(isinf)
+AC_CHECK_DECLS([isinf], [AC_DEFINE(HAVE_ISINF)], [AC_LIBOBJ(isinf)], [[#include <math.h>]])
+#AC_REPLACE_FUNCS(isnan)
+AC_CHECK_DECLS([isnan], [AC_DEFINE(HAVE_ISNAN)], [AC_LIBOBJ(isnan)], [[#include <math.h>]])
 AC_REPLACE_FUNCS(lgamma_r)
 AC_REPLACE_FUNCS(memmove)
 AC_REPLACE_FUNCS(nextafter)

Is it the way to go?

Actions

Also available in: Atom PDF

Like0
Like0