[glib/glib-2-58: 1/55] build: simplify alloca checks. See #1313



commit 3f9a922d96075bf663b2e94896e188465e1b888f
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Thu Aug 23 17:35:56 2018 +0200

    build: simplify alloca checks. See #1313
    
    The goal of this commit is to reduce differences between the autotools and meson build.
    
    With autotools AC_FUNC_ALLOCA was used which defines HAVE_ALLOCA_H, HAVE_ALLOCA,
    C_ALLOCA. meson tried to replicate that with has_function() but alloca can be a macro
    and and is named _alloca under Windows. Since we require a working alloca anyway
    and only need to know if the header exists replace AC_FUNC_ALLOCA with a simple
    AC_CHECK_HEADERS.
    
    There is still one user of HAVE_ALLOCA in the embedded gnulib, but since alloca is
    always provided through galloca.h just force define HAVE_ALLOCA there and add a comment.
    
    The docs were mentioning alloca as an example for cross compiling. Since that variable no
    longer exists now replace it with another one.

 configure.ac                  | 8 +++-----
 docs/reference/glib/cross.xml | 4 ++--
 glib/gnulib/vasnprintf.c      | 2 ++
 meson.build                   | 1 -
 4 files changed, 7 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 37b2f4858..028a3f861 100644
--- a/configure.ac
+++ b/configure.ac
@@ -477,7 +477,6 @@ AS_IF([test "$glib_native_win32" = "yes"], [
 AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a 
x$glib_win32_static_compilation != xyes])
 
 # Checks for library functions.
-AC_FUNC_ALLOCA
 AC_CHECK_FUNCS(mmap posix_memalign memalign valloc fsync pipe2 issetugid)
 AC_CHECK_FUNCS(timegm gmtime_r posix_spawn)
 AC_FUNC_STRERROR_R()
@@ -641,6 +640,7 @@ AC_CHECK_HEADERS([sys/vfs.h sys/vmount.h sys/statfs.h sys/statvfs.h sys/filio.h
 AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h])
 AC_CHECK_HEADERS([linux/magic.h])
 AC_CHECK_HEADERS([termios.h])
+AC_CHECK_HEADERS([alloca.h])
 
 # Some versions of MSC lack these
 AC_CHECK_HEADERS([dirent.h sys/time.h])
@@ -2985,10 +2985,8 @@ _______EOF
 # on variable expansion in case labels.  Look at the generated config.status
 # for a hint.
 
-if test "x${ac_cv_working_alloca_h+set}" = xset ; then
-  glib_header_alloca_h="$ac_cv_working_alloca_h"
-else
-  glib_header_alloca_h="$ac_cv_header_alloca_h"
+if test x$ac_cv_header_alloca_h = xyes ; then
+  glib_header_alloca_h=yes
 fi
 
 if test x$enable_included_printf = xyes ; then
diff --git a/docs/reference/glib/cross.xml b/docs/reference/glib/cross.xml
index c45200437..aba4c75ef 100644
--- a/docs/reference/glib/cross.xml
+++ b/docs/reference/glib/cross.xml
@@ -84,8 +84,8 @@ meson --cross_file cross_file.txt builddir
            overridden by setting the
            <literal>have_<replaceable>function</replaceable></literal> property
            to <constant>true</constant> or <constant>false</constant>.
-           For example <programlisting>Checking for function "alloca" : YES</programlisting>
-           can be overridden by setting <programlisting>have_alloca = false</programlisting>
+           For example <programlisting>Checking for function "fsync" : YES</programlisting>
+           can be overridden by setting <programlisting>have_fsync = false</programlisting>
         </para>
       </formalpara>
       <formalpara>
diff --git a/glib/gnulib/vasnprintf.c b/glib/gnulib/vasnprintf.c
index 38eab62f5..05d6c2b91 100644
--- a/glib/gnulib/vasnprintf.c
+++ b/glib/gnulib/vasnprintf.c
@@ -55,7 +55,9 @@
 #ifndef VASNPRINTF
 # include <config.h>
 #endif
+/* galloca.h also defines alloca and HAVE_ALLOCA makes the code below use it */
 #include "glib/galloca.h"
+#define HAVE_ALLOCA 1
 
 #include "g-gnulib.h"
 
diff --git a/meson.build b/meson.build
index 0a0de3cec..6308e7d35 100644
--- a/meson.build
+++ b/meson.build
@@ -386,7 +386,6 @@ if host_system == 'windows'
 endif
 
 functions = [
-  'alloca',
   'endmntent',
   'endservent',
   'fallocate',


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