[Pixman] [PATCH] Fix pixman build with older GCC releases

Siarhei Siamashka siarhei.siamashka at gmail.com
Wed Oct 9 16:16:29 PDT 2013


On Wed, 9 Oct 2013 01:52:22 -0400
Brad Smith <brad at comstyle.com> wrote:

> The following patch fixes building pixman with older GCC releases
> such as GCC 3.3 and older (OpenBSD; some older archs use GCC 3.3.6)
> by changing the method of detecting the presence of __builtin_clz
> to utilizing an autoconf check to determine its presence. Compilers
> that pretend to be GCC, implement __builtin_clz and are already
> utilizing the intrinsic include LLVM/Clang, Open64, EKOPath and
> PCC.

Thanks, the commit message looks good.

> ---
>  configure.ac           | 16 ++++++++++++++++
>  pixman/pixman-matrix.c |  2 +-
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 263c63e..a269f21 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1036,6 +1036,22 @@ fi
>  
>  AC_MSG_RESULT($support_for_float128)
>  
> +dnl =====================================
> +dnl __builtin_clz
> +
> +support_for_builtin_clz=no
> +
> +AC_MSG_CHECKING(for __builtin_clz)
> +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[

Have you verified that this actually works as expected with GCC 3.3?

For example, when compiling pixman with TCC (it does not support
__builtin_clz), this configure check thinks that __builtin_clz is
supported, but then the build fails at the linking stage with
"undefined symbol '__builtin_clz'" error.

The other similar checks from configure.ac are all using AC_LINK_IFELSE
instead of AC_COMPILE_IFELSE.

> +unsigned int x = 11; int main (void) { __builtin_clz(x); }

"return __builtin_clz (x)" would be a cleaner warning-free code.

> +]])], support_for_builtin_clz=yes)
> +
> +if test x$support_for_builtin_clz = xyes; then
> +   AC_DEFINE([HAVE_BUILTIN_CLZ], [], [Whether the compiler supports __builtin_clz])
> +fi
> +
> +AC_MSG_RESULT($support_for_builtin_clz)
> +
>  dnl ==================
>  dnl libpng
>  
> diff --git a/pixman/pixman-matrix.c b/pixman/pixman-matrix.c
> index 89b9682..4032c13 100644
> --- a/pixman/pixman-matrix.c
> +++ b/pixman/pixman-matrix.c
> @@ -37,7 +37,7 @@
>  static force_inline int
>  count_leading_zeros (uint32_t x)
>  {
> -#ifdef __GNUC__
> +#ifdef HAVE_BUILTIN_CLZ
>      return __builtin_clz (x);
>  #else
>      int n = 0;

-- 
Best regards,
Siarhei Siamashka


More information about the Pixman mailing list