bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regression in ffs() detection on mingw


From: Bruno Haible
Subject: Re: Regression in ffs() detection on mingw
Date: Tue, 17 Jul 2018 00:52:59 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-130-generic; KDE/5.18.0; x86_64; ; )

Hi,

Daniel P. Berrangé wrote:
> Since doing that we see failure to build on mingw32/64 platforms due
> to missing ffs() function
> 
>   util/virrandom.c: In function 'virRandomInt':
>   util/virrandom.c:102:30: error: implicit declaration of function 'ffs' 
> [-Werror=implicit-function-declaration]
>          return virRandomBits(ffs(max) - 1);
>                               ^~~
>   cc1: all warnings being treated as errors
> 
> 
> Reverting the following commit fixes the problem
> 
>   commit 2afc250c6fae929b95e8b8915b17379cd9f2e450
>   Author: Bruno Haible <address@hidden>
>   Date:   Sun May 13 16:13:27 2018 +0200
> 
>     ffs: Fix compilation error on Android.
>     
>     * m4/ffs.m4 (gl_FUNC_FFS): Use AC_LINK_IFELSE instead of AC_CHECK_FUNC.
> 
> ...
> Interestingly, it is failing to detect ffs() because it appears to be a
> built-in. I thought it was not supposed to exist at all on mingw ?
> 
> 
> After that gnulib change was applied for android, it now reports a warning
> about implicit decl, but still succeeds, presumably because its a built-in.
> 
> 
>   configure:25225: checking for ffs
>   configure:25244: i686-w64-mingw32-gcc -o conftest.exe  -O2 -g -pipe -Wall 
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4   conftest.c  
> >&5
>   conftest.c: In function 'main':
>   conftest.c:199:8: warning: implicit declaration of function 'ffs' 
> [-Wimplicit-function-declaration]
>    return ffs(x);
>           ^~~
>   configure:25244: $? = 0
>   configure:25253: result: yes

Thanks for the report. This patch fixes it.


2018-07-16  Bruno Haible  <address@hidden>

        ffs: Ensure declaration on mingw.
        Reported by Daniel P. Berrangé <address@hidden>
        in https://lists.gnu.org/archive/html/bug-gnulib/2018-07/msg00061.html.
        * m4/ffs.m4 (gl_FUNC_FFS): Check whether ffs() not only exists but is
        also declared.

diff --git a/m4/ffs.m4 b/m4/ffs.m4
index 78b13ee..a305f2b 100644
--- a/m4/ffs.m4
+++ b/m4/ffs.m4
@@ -1,4 +1,4 @@
-# ffs.m4 serial 3
+# ffs.m4 serial 4
 dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,13 +10,18 @@ AC_DEFUN([gl_FUNC_FFS],
 
   dnl We can't use AC_CHECK_FUNC here, because ffs() is defined as a
   dnl static inline function when compiling for Android 4.2 or older.
+  dnl But require that ffs() is declared; otherwise we may be using
+  dnl the GCC built-in function, which leads to warnings
+  dnl "warning: implicit declaration of function 'ffs'".
   AC_CACHE_CHECK([for ffs], [gl_cv_func_ffs],
     [AC_LINK_IFELSE(
        [AC_LANG_PROGRAM(
           [[#include <strings.h>
             int x;
           ]],
-          [[return ffs(x);]])
+          [[int (*func) (int) = ffs;
+            return func (x);
+          ]])
        ],
        [gl_cv_func_ffs=yes],
        [gl_cv_func_ffs=no])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]