Bug 1480834 - 4. Specify -Werror for pthread_cond_timedwait_monotonic_np check; r=glandium
authorJim Chen <nchen@mozilla.com>
Thu, 13 Sep 2018 12:09:25 -0400
changeset 436219 ced591ff6815b83d035f2dac731265f14c1cb092
parent 436218 c12699660620ccb2f2bdac4e1a2049659748cdde
child 436220 704af02a849d08aa2c4c72c44e65bd6af1e75b0a
push id34631
push usernerli@mozilla.com
push dateThu, 13 Sep 2018 22:02:04 +0000
treeherdermozilla-central@e923330d5bd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1480834
milestone64.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 1480834 - 4. Specify -Werror for pthread_cond_timedwait_monotonic_np check; r=glandium On 64-bit Android, `pthread_cond_timedwait_monotonic_np` is only available for API 28+. The issue is, even though the NDK header does not define `pthread_cond_timedwait_monotonic_np` for API 27 and below, the NDK library _does_ include the function (in order to support builds targeting API 28+). During our configure test, the compiler only emits a warning about `pthread_cond_timedwait_monotonic_np` being undefined, but linking succeeds because the function is present in the library. Because linking succeeds, the test inadvertently passes. This patch adds a '-Werror' flag to the compilation, so the warning turns into an error to make the test fail. Differential Revision: https://phabricator.services.mozilla.com/D4482
old-configure.in
--- a/old-configure.in
+++ b/old-configure.in
@@ -1467,25 +1467,31 @@ Darwin)
       REALTIME_LIBS=$ac_cv_clock_monotonic
       AC_DEFINE(HAVE_CLOCK_MONOTONIC)
       AC_SUBST(HAVE_CLOCK_MONOTONIC)
       AC_SUBST_LIST(REALTIME_LIBS)
   fi
   ;;
 esac
 
+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,
                AC_TRY_LINK([#include <pthread.h>],
                            [pthread_cond_timedwait_monotonic_np(0, 0, 0);],
                            ac_cv_pthread_cond_timewait_monotonic_np=yes,
                            ac_cv_pthread_cond_timewait_monotonic_np=no))
 if test "$ac_cv_pthread_cond_timewait_monotonic_np" != "no"; then
     AC_DEFINE(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC)
 fi
+CFLAGS=$_SAVE_CFLAGS
 
 AC_CACHE_CHECK(
     [for res_ninit()],
     ac_cv_func_res_ninit,
     [if test "$OS_TARGET" = NetBSD -o "$OS_TARGET" = OpenBSD; then
         dnl no need for res_ninit() on NetBSD and OpenBSD
         ac_cv_func_res_ninit=no
      else