According to Dmitry V. Levin on 1/21/2010 4:40 PM:
> Hi,
> 
> There is no news that AC_CHECK_FUNC fails to find built-in functions when
> either AC_LANG_WERROR is used or -Werror is included in CFLAGS:

Yes, this is a well-known and frequently reported issue, and our usual
response has been to tell people "don't do it if it hurts".

> For a long time I maintain a patch that remedies this problem.  While the
> patch is probably not quite suitable for inclusion as is, it is known to
> work.  I've updated it for the HEAD and decided to give it a chance to be
> discussed here.  I hope the idea behind this patch could be used for a
> more acceptable fix.

Indeed - proposing patches is always a better approach than complaining.
No promises on when I can give this a deep-down review, but at least
you've got the ball rolling.

> +m4_define([AC_LANG_FUNC_LINK_TRY_GCC_BUILTIN(C)],
> +[AC_LANG_PROGRAM(
> +[#ifndef __GNUC__
> +choke me
> +#else
> +#undef $1
> +/* Declare this function with same prototype as __builtin_$1.
> +  This removes warning about conflicting type with builtin */
> +__typeof__(__builtin_$1) $1;
> +
> +__typeof__(__builtin_$1) *f = $1;
> +#endif
> +], [return f != $1;])])

Since we are really only caring about silencing gcc -Werror, I see no
reason to force a compilation for non-gcc compilers.  But the idea of
exploiting __GNUC__ and known gcc extensions, to avoid conflicts with
__builtin_* functions, does seem appealing, especially since we now have
the machinery to do it only once in a function rather than bloating every
use of AC_CHECK_FUNC throughout the configure file.

>    [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY($[]2)],
>                 [AS_VAR_SET([$[]3], [yes])],
> -               [AS_VAR_SET([$[]3], [no])])])
> +               [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY_GCC_BUILTIN($[]2)],
> +                               [AS_VAR_SET([$[]3], [yes])],
> +                               [AS_VAR_SET([$[]3], [no])])])])
>    AS_LINENO_POP
>  ])# _AC_CHECK_FUNC_BODY

It would be even slicker to do this without having to recompile (that is,
rewrite AC_LANG_FUNC_LINK_TRY to use the new logic, rather than making
AC_CHECK_FUNC call AC_LINK_IFELSE twice).

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             e...@byu.net

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to