From: luizluca@... Date: 2019-02-08T04:00:35+00:00 Subject: [ruby-core:91487] [Ruby trunk Bug#15595] configure.in fails to detect isinf() and finite() when they are macros Issue #15595 has been reported by luizluca (Luiz Angelo Daros de Luca). ---------------------------------------- Bug #15595: configure.in fails to detect isinf() and finite() when they are macros https://bugs.ruby-lang.org/issues/15595 * Author: luizluca (Luiz Angelo Daros de Luca) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.6.1 * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- 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 . ``` ... 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_\ with HAVE_DECL_\, 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_\ with HAVE_DECL_\, I manually set HAVE_\ 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 ]]) 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 ]]) +#AC_REPLACE_FUNCS(isnan) +AC_CHECK_DECLS([isnan], [AC_DEFINE(HAVE_ISNAN)], [AC_LIBOBJ(isnan)], [[#include ]]) AC_REPLACE_FUNCS(lgamma_r) AC_REPLACE_FUNCS(memmove) AC_REPLACE_FUNCS(nextafter) ``` Is it the way to go? -- https://bugs.ruby-lang.org/ Unsubscribe: