Bug 1524461 - Run the clock_gettime(CLOCK_MONOTONIC) configure check on OSX. r=froydnj
authorMike Hommey <mh+mozilla@glandium.org>
Mon, 04 Feb 2019 23:26:34 +0000
changeset 456757 3dea9124aaa1c4839dfb4da7533ae1c092dd98ba
parent 456756 65be959384732ebcb4d2329dc35823988722aa52
child 456758 6d73d61bac7d4289ec6ad342d90e47fa2d3761ff
push id35504
push usercsabou@mozilla.com
push dateTue, 05 Feb 2019 21:57:12 +0000
treeherdermozilla-central@1e374e23c02f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1524461
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524461 - Run the clock_gettime(CLOCK_MONOTONIC) configure check on OSX. r=froydnj That will make it detected when we bump the MACOSX_DEPLOYMENT_TARGET to a value >= 10.12. Differential Revision: https://phabricator.services.mozilla.com/D18310
js/src/old-configure.in
old-configure.in
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -998,45 +998,41 @@ then
 fi
 
 
 dnl Checks for library functions.
 dnl ========================================================
 AC_CHECK_FUNCS([getc_unlocked _getc_nolock gmtime_r localtime_r pthread_getname_np pthread_get_name_np])
 
 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
-dnl avoid this on Darwin, since depending on your system config, we may think
-dnl it exists but it really doesn't
-case "$OS_TARGET" in
-Darwin)
-  ;;
-*)
-  AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
-                 ac_cv_clock_monotonic,
-                 [for libs in "" -lrt; do
-                      _SAVE_LIBS="$LIBS"
-                      LIBS="$LIBS $libs"
-                      AC_TRY_LINK([#include <time.h>],
-                                   [ struct timespec ts;
-                                     clock_gettime(CLOCK_MONOTONIC, &ts); ],
-                                   ac_cv_clock_monotonic=$libs
-                                   LIBS="$_SAVE_LIBS"
-                                   break,
-                                   ac_cv_clock_monotonic=no)
-                      LIBS="$_SAVE_LIBS"
-                  done])
-  if test "$ac_cv_clock_monotonic" != "no"; then
-      HAVE_CLOCK_MONOTONIC=1
-      REALTIME_LIBS=$ac_cv_clock_monotonic
-      AC_DEFINE(HAVE_CLOCK_MONOTONIC)
-      AC_SUBST(HAVE_CLOCK_MONOTONIC)
-      AC_SUBST_LIST(REALTIME_LIBS)
-  fi
-  ;;
-esac
+AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
+               ac_cv_clock_monotonic,
+               [for libs in "" -lrt; do
+                    _SAVE_LIBS="$LIBS"
+                    LIBS="$LIBS $libs"
+dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
+dnl we should or not be able to use it. To detect if we can, we need to make the
+dnl availability attribute strict, so that compilation fails when the target is < 10.12.
+                    AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
+                                 #include <time.h>],
+                                 [ struct timespec ts;
+                                   clock_gettime(CLOCK_MONOTONIC, &ts); ],
+                                 ac_cv_clock_monotonic=$libs
+                                 LIBS="$_SAVE_LIBS"
+                                 break,
+                                 ac_cv_clock_monotonic=no)
+                    LIBS="$_SAVE_LIBS"
+                done])
+if test "$ac_cv_clock_monotonic" != "no"; then
+    HAVE_CLOCK_MONOTONIC=1
+    REALTIME_LIBS=$ac_cv_clock_monotonic
+    AC_DEFINE(HAVE_CLOCK_MONOTONIC)
+    AC_SUBST(HAVE_CLOCK_MONOTONIC)
+    AC_SUBST_LIST(REALTIME_LIBS)
+fi
 
 dnl Checks for math functions.
 dnl ========================================================
 AC_CHECK_LIB(m, sin)
 AC_CHECK_LIB(m, sincos, AC_DEFINE(HAVE_SINCOS))
 AC_CHECK_LIB(m, __sincos, AC_DEFINE(HAVE___SINCOS))
 
 AC_CACHE_CHECK(
--- a/old-configure.in
+++ b/old-configure.in
@@ -1273,45 +1273,41 @@ then
 fi
 
 
 dnl Checks for library functions.
 dnl ========================================================
 AC_CHECK_FUNCS(stat64 lstat64 truncate64 statvfs64 statvfs statfs64 statfs getpagesize gmtime_r localtime_r arc4random arc4random_buf mallinfo gettid lchown setpriority strerror syscall)
 
 dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
-dnl avoid this on Darwin, since depending on your system config, we may think
-dnl it exists but it really doesn't
-case "$OS_TARGET" in
-Darwin)
-  ;;
-*)
-  AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
-                 ac_cv_clock_monotonic,
-                 [for libs in "" -lrt; do
-                      _SAVE_LIBS="$LIBS"
-                      LIBS="$LIBS $libs"
-                      AC_TRY_LINK([#include <time.h>],
-                                   [ struct timespec ts;
-                                     clock_gettime(CLOCK_MONOTONIC, &ts); ],
-                                   ac_cv_clock_monotonic=$libs
-                                   LIBS="$_SAVE_LIBS"
-                                   break,
-                                   ac_cv_clock_monotonic=no)
-                      LIBS="$_SAVE_LIBS"
-                  done])
-  if test "$ac_cv_clock_monotonic" != "no"; then
-      HAVE_CLOCK_MONOTONIC=1
-      REALTIME_LIBS=$ac_cv_clock_monotonic
-      AC_DEFINE(HAVE_CLOCK_MONOTONIC)
-      AC_SUBST(HAVE_CLOCK_MONOTONIC)
-      AC_SUBST_LIST(REALTIME_LIBS)
-  fi
-  ;;
-esac
+AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
+               ac_cv_clock_monotonic,
+               [for libs in "" -lrt; do
+                    _SAVE_LIBS="$LIBS"
+                    LIBS="$LIBS $libs"
+dnl clock_gettime is available on OSX since 10.12, so depending on MACOSX_DEPLOYMENT_TARGET,
+dnl we should or not be able to use it. To detect if we can, we need to make the
+dnl availability attribute strict, so that compilation fails when the target is < 10.12.
+                    AC_TRY_LINK([#define availability(os, ...) availability(os, strict, __VA_ARGS)
+                                 #include <time.h>],
+                                 [ struct timespec ts;
+                                   clock_gettime(CLOCK_MONOTONIC, &ts); ],
+                                 ac_cv_clock_monotonic=$libs
+                                 LIBS="$_SAVE_LIBS"
+                                 break,
+                                 ac_cv_clock_monotonic=no)
+                    LIBS="$_SAVE_LIBS"
+                done])
+if test "$ac_cv_clock_monotonic" != "no"; then
+    HAVE_CLOCK_MONOTONIC=1
+    REALTIME_LIBS=$ac_cv_clock_monotonic
+    AC_DEFINE(HAVE_CLOCK_MONOTONIC)
+    AC_SUBST(HAVE_CLOCK_MONOTONIC)
+    AC_SUBST_LIST(REALTIME_LIBS)
+fi
 
 dnl Turn on warnings-as-errors to prevent implicit declaration of
 dnl pthread_cond_timedwait_monotonic_np, which can cause this test to
 dnl inadvertently pass even if the function does not really exist.
 _SAVE_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $WARNINGS_AS_ERRORS"
 AC_CACHE_CHECK(for pthread_cond_timedwait_monotonic_np,
                ac_cv_pthread_cond_timedwait_monotonic_np,