Bug 1269517 - Move various header checks to Python configure. r=glandium
authorChris Manchester <cmanchester@mozilla.com>
Tue, 26 Jul 2016 15:27:19 -0700
changeset 306811 550fc29355f102a40f897b958fee7c2776a99fb3
parent 306810 b50c01f263a5c8f2d55b2bad0603a70b10ae4981
child 306812 83db605b772e7d7fe1e27d0bb3cea5e117ceafad
push id20130
push usercbook@mozilla.com
push dateWed, 27 Jul 2016 14:41:09 +0000
treeherderfx-team@714cca6d49d0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1269517
milestone50.0a1
Bug 1269517 - Move various header checks to Python configure. r=glandium MozReview-Commit-ID: CLn3PQUh4gG
aclocal.m4
build/autoconf/alloc.m4
build/autoconf/mozcommonheader.m4
build/moz.configure/headers.configure
js/src/aclocal.m4
js/src/old-configure.in
moz.configure
old-configure.in
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -11,17 +11,16 @@ builtin(include, build/autoconf/toolchai
 builtin(include, build/autoconf/nspr.m4)dnl
 builtin(include, build/autoconf/nspr-build.m4)dnl
 builtin(include, build/autoconf/nss.m4)dnl
 builtin(include, build/autoconf/pkg.m4)dnl
 builtin(include, build/autoconf/codeset.m4)dnl
 builtin(include, build/autoconf/altoptions.m4)dnl
 builtin(include, build/autoconf/mozprog.m4)dnl
 builtin(include, build/autoconf/mozheader.m4)dnl
-builtin(include, build/autoconf/mozcommonheader.m4)dnl
 builtin(include, build/autoconf/lto.m4)dnl
 builtin(include, build/autoconf/frameptr.m4)dnl
 builtin(include, build/autoconf/compiler-opts.m4)dnl
 builtin(include, build/autoconf/expandlibs.m4)dnl
 builtin(include, build/autoconf/arch.m4)dnl
 builtin(include, build/autoconf/android.m4)dnl
 builtin(include, build/autoconf/zlib.m4)dnl
 builtin(include, build/autoconf/linux.m4)dnl
--- a/build/autoconf/alloc.m4
+++ b/build/autoconf/alloc.m4
@@ -17,26 +17,26 @@ for file in $MALLOC_HEADERS; do
 done
 
 MOZ_CHECK_HEADERS(alloca.h)
 
 AC_CHECK_FUNCS(strndup posix_memalign memalign)
 
 AC_CHECK_FUNCS(malloc_usable_size)
 MALLOC_USABLE_SIZE_CONST_PTR=const
-MOZ_CHECK_HEADERS([malloc.h], [
+if test -n "$HAVE_MALLOC_H"; then
   AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
   AC_TRY_COMPILE([#include <malloc.h>
                   #include <stddef.h>
                   size_t malloc_usable_size(const void *ptr);],
                   [return malloc_usable_size(0);],
                   AC_MSG_RESULT([yes]),
                   AC_MSG_RESULT([no])
                   MALLOC_USABLE_SIZE_CONST_PTR=)
-])
+fi
 AC_DEFINE_UNQUOTED([MALLOC_USABLE_SIZE_CONST_PTR],[$MALLOC_USABLE_SIZE_CONST_PTR])
 
 
 dnl In newer bionic headers, valloc is built but not defined,
 dnl so we check more carefully here.
 AC_MSG_CHECKING([for valloc in malloc.h])
 AC_EGREP_HEADER(valloc, malloc.h,
                 AC_DEFINE(HAVE_VALLOC)
deleted file mode 100644
--- a/build/autoconf/mozcommonheader.m4
+++ /dev/null
@@ -1,8 +0,0 @@
-dnl This Source Code Form is subject to the terms of the Mozilla Public
-dnl License, v. 2.0. If a copy of the MPL was not distributed with this
-dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-AC_DEFUN(MOZ_CHECK_COMMON_HEADERS,
-	MOZ_CHECK_HEADERS(sys/byteorder.h getopt.h unistd.h nl_types.h \
-        malloc.h cpuid.h)
-)
new file mode 100644
--- /dev/null
+++ b/build/moz.configure/headers.configure
@@ -0,0 +1,63 @@
+# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Check for headers defining standard int types.
+check_header('stdint.h')
+have_inttypes = check_header('inttypes.h')
+
+set_config('HAVE_INTTYPES_H', have_inttypes)
+
+# Checks for headers relevant to non-windows systems.
+non_msvc_compiler = depends(c_compiler)(lambda info: info.type != 'msvc')
+
+building_linux = depends(target)(lambda target: target.kernel == 'Linux')
+
+have_malloc = check_header('malloc.h')
+
+add_old_configure_assignment('HAVE_MALLOC_H', have_malloc)
+
+check_headers(
+    'sys/byteorder.h',
+    'getopt.h',
+    'unistd.h',
+    'nl_types.h',
+    'cpuid.h',
+    when=non_msvc_compiler,
+)
+
+# These are all the places some variant of statfs can be hiding.
+check_headers(
+    'sys/statvfs.h',
+    'sys/statfs.h',
+    'sys/vfs.h',
+    'sys/mount.h',
+    when=non_msvc_compiler,
+)
+
+# Quota support
+check_header('sys/quota.h',
+             when=non_msvc_compiler)
+check_header('linux/quota.h',
+             includes=['sys/socket.h'],
+             when=building_linux)
+
+# SCTP support - needs various network include headers
+check_headers(
+    'linux/if_addr.h',
+    'linux/rtnetlink.h',
+    includes=['sys/socket.h'],
+    when=building_linux,
+)
+
+check_header('sys/queue.h',
+             when=non_msvc_compiler)
+
+check_headers(
+    'sys/types.h',
+    'netinet/in.h',
+    'byteswap.h',
+    when=non_msvc_compiler,
+)
--- a/js/src/aclocal.m4
+++ b/js/src/aclocal.m4
@@ -10,17 +10,16 @@ builtin(include, ../../build/autoconf/co
 builtin(include, ../../build/autoconf/toolchain.m4)dnl
 builtin(include, ../../build/autoconf/pkg.m4)dnl
 builtin(include, ../../build/autoconf/nspr.m4)dnl
 builtin(include, ../../build/autoconf/nspr-build.m4)dnl
 builtin(include, ../../build/autoconf/codeset.m4)dnl
 builtin(include, ../../build/autoconf/altoptions.m4)dnl
 builtin(include, ../../build/autoconf/mozprog.m4)dnl
 builtin(include, ../../build/autoconf/mozheader.m4)dnl
-builtin(include, ../../build/autoconf/mozcommonheader.m4)dnl
 builtin(include, ../../build/autoconf/lto.m4)dnl
 builtin(include, ../../build/autoconf/frameptr.m4)dnl
 builtin(include, ../../build/autoconf/compiler-opts.m4)dnl
 builtin(include, ../../build/autoconf/expandlibs.m4)dnl
 builtin(include, ../../build/autoconf/arch.m4)dnl
 builtin(include, ../../build/autoconf/android.m4)dnl
 builtin(include, ../../build/autoconf/zlib.m4)dnl
 builtin(include, ../../build/autoconf/linux.m4)dnl
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -1222,24 +1222,16 @@ dnl Checks for header files.
 dnl ========================================================
 AC_HEADER_DIRENT
 case "$target_os" in
 freebsd*)
 # for stuff like -lXshm
     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
     ;;
 esac
-MOZ_CHECK_COMMON_HEADERS
-
-dnl These are all the places some variant of statfs can be hiding.
-MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
-
-dnl Quota support
-MOZ_CHECK_HEADERS(sys/quota.h)
-MOZ_CHECK_HEADERS(linux/quota.h)
 
 MOZ_ARG_ENABLE_BOOL(dtrace,
               [  --enable-dtrace         build with dtrace support if available (default=no)],
               [enable_dtrace="yes"],)
 if test "x$enable_dtrace" = "xyes"; then
   MOZ_CHECK_HEADER(sys/sdt.h, HAVE_DTRACE=1)
   if test -n "$HAVE_DTRACE"; then
       AC_DEFINE(INCLUDE_MOZILLA_DTRACE)
--- a/moz.configure
+++ b/moz.configure
@@ -102,16 +102,22 @@ include(toolchain_include)
 
 @depends('--disable-compile-environment', '--help')
 def memory_include(compile_env, help):
     if compile_env:
         return 'build/moz.configure/memory.configure'
 
 include(memory_include)
 
+@depends('--disable-compile-environment', '--help')
+def headers_check_include(compile_env, help):
+    if compile_env:
+        return 'build/moz.configure/headers.configure'
+
+include(headers_check_include)
 
 @depends('--help')
 @imports(_from='mozbuild.backend', _import='backends')
 def build_backends_choices(help):
     return tuple(backends)
 
 
 @deprecated_option('--enable-build-backend', nargs='+',
--- a/old-configure.in
+++ b/old-configure.in
@@ -1571,30 +1571,16 @@ dnl Checks for header files.
 dnl ========================================================
 AC_HEADER_DIRENT
 case "$target_os" in
 bitrig*|dragonfly*|freebsd*|openbsd*)
 # for stuff like -lXshm
     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
     ;;
 esac
-MOZ_CHECK_COMMON_HEADERS
-
-dnl These are all the places some variant of statfs can be hiding.
-MOZ_CHECK_HEADERS(sys/statvfs.h sys/statfs.h sys/vfs.h sys/mount.h)
-
-dnl Quota support
-MOZ_CHECK_HEADERS(sys/quota.h)
-MOZ_CHECK_HEADERS([linux/quota.h],,,[#include <sys/socket.h>])
-
-dnl SCTP support - needs various network include headers
-MOZ_CHECK_HEADERS([linux/if_addr.h linux/rtnetlink.h],,,[#include <sys/socket.h>])
-MOZ_CHECK_HEADERS(sys/queue.h)
-
-MOZ_CHECK_HEADERS(sys/types.h netinet/in.h byteswap.h)
 
 dnl Check for sin_len and sin6_len - used by SCTP; only appears in Mac/*BSD generally
 AC_CACHE_CHECK(for sockaddr_in.sin_len,
                    ac_cv_sockaddr_in_sin_len,
                    [AC_TRY_COMPILE([#ifdef HAVE_SYS_TYPES_H
                                     #include <sys/types.h>
                                     #endif
                                     #include <netinet/in.h>
@@ -5861,27 +5847,16 @@ elif test -z "$MOZ_TREE_CAIRO"; then
 fi
 
 if test "$MOZ_TREE_PIXMAN"; then
     AC_DEFINE(MOZ_TREE_PIXMAN)
 else
     PKG_CHECK_MODULES(MOZ_PIXMAN, pixman-1 >= 0.19.2)
 fi
 
-# Check for headers defining standard int types.
-if test -n "$COMPILE_ENVIRONMENT"; then
-    MOZ_CHECK_HEADERS(stdint.h inttypes.h)
-
-    if test "${ac_cv_header_inttypes_h}" = "yes"; then
-        HAVE_INTTYPES_H=1
-    fi
-fi
-
-AC_SUBST(HAVE_INTTYPES_H)
-
 if test "$MOZ_TREE_CAIRO"; then
     MOZ_CAIRO_CFLAGS="-I${DIST}/include/cairo"
     AC_DEFINE(MOZ_TREE_CAIRO)
 
     if test "$OS_ARCH" = "WINNT"; then
         # For now we assume that we will have a uint64_t available through
         # one of the above headers or mozstdint.h.
         AC_DEFINE(HAVE_UINT64_T)