<div dir="ltr">This appears to have broken the Chromium build:<div><a href="https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac/builds/12620/steps/gclient%20runhooks/logs/stdio">https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac/builds/12620/steps/gclient%20runhooks/logs/stdio</a><br><div><div>FAILED: projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o </div><div>/Applications/Xcode8.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++   -D_DEBUG -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/libcxx/lib -I/b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/lib -Iinclude -I/b/c/b/ClangToTMac/src/third_party/llvm/include -I/b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/include -DLLVM_FORCE_HEAD_REVISION -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers  -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -Werror=date-time -std=c++11 -fcolor-diagnostics -O3  -isysroot /Applications/Xcode8.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.11    -UNDEBUG -std=c++11 -nostdinc++ -fvisibility-inlines-hidden -Wall -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type -Wno-user-defined-literals -Wno-covered-switch-default -Wno-error -fPIC -MMD -MT projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o -MF projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o.d -o projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o -c /b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/src/chrono.cpp</div><div>/b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/src/chrono.cpp:102:5: error: use of undeclared identifier 'gettimeofday'</div><div>    gettimeofday(&tv, 0);</div><div>    ^</div></div></div><div><br></div><div>The interesting flag in there is probably -mmacosx-version-min=10.11. Any thoughts on what's going wrong?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 9, 2017 at 11:21 AM, Bruno Cardoso Lopes via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bruno<br>
Date: Mon Jan  9 13:21:48 2017<br>
New Revision: 291466<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=291466&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=291466&view=rev</a><br>
Log:<br>
[Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW<br>
<br>
Use CLOCK_UPTIME_RAW in case clock_gettime is available on Darwin.<br>
<br>
On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able<br>
to time functions in the nanosecond range. Thus, they are the only<br>
acceptable implementations of steady_clock.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D27429" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D27429</a><br>
<br>
rdar://problem/29449467<br>
<br>
Modified:<br>
    libcxx/trunk/src/chrono.cpp<br>
<br>
Modified: libcxx/trunk/src/chrono.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=291466&r1=291465&r2=291466&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/libcxx/trunk/src/<wbr>chrono.cpp?rev=291466&r1=<wbr>291465&r2=291466&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/src/chrono.cpp (original)<br>
+++ libcxx/trunk/src/chrono.cpp Mon Jan  9 13:21:48 2017<br>
@@ -12,6 +12,28 @@<br>
 #include "system_error"  // __throw_system_error<br>
 #include <time.h>        // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME<br>
<br>
+#if (__APPLE__)<br>
+#if defined(__ENVIRONMENT_MAC_OS_<wbr>X_VERSION_MIN_REQUIRED__)<br>
+#if __ENVIRONMENT_MAC_OS_X_<wbr>VERSION_MIN_REQUIRED__ >= 101200<br>
+#define _LIBCXX_USE_CLOCK_GETTIME<br>
+#endif<br>
+#elif defined(__ENVIRONMENT_IPHONE_<wbr>OS_VERSION_MIN_REQUIRED__)<br>
+#if __ENVIRONMENT_IPHONE_OS_<wbr>VERSION_MIN_REQUIRED__ >= 100000<br>
+#define _LIBCXX_USE_CLOCK_GETTIME<br>
+#endif<br>
+#elif defined(__ENVIRONMENT_TV_OS_<wbr>VERSION_MIN_REQUIRED__)<br>
+#if __ENVIRONMENT_TV_OS_VERSION_<wbr>MIN_REQUIRED__ >= 100000<br>
+#define _LIBCXX_USE_CLOCK_GETTIME<br>
+#endif<br>
+#elif defined(__ENVIRONMENT_WATCH_<wbr>OS_VERSION_MIN_REQUIRED__)<br>
+#if __ENVIRONMENT_WATCH_OS_<wbr>VERSION_MIN_REQUIRED__ >= 30000<br>
+#define _LIBCXX_USE_CLOCK_GETTIME<br>
+#endif<br>
+#endif // __ENVIRONMENT_.*_VERSION_MIN_<wbr>REQUIRED__<br>
+#else<br>
+#define _LIBCXX_USE_CLOCK_GETTIME<br>
+#endif // __APPLE__<br>
+<br>
 #if defined(_LIBCPP_WIN32API)<br>
 #define WIN32_LEAN_AND_MEAN<br>
 #define VC_EXTRA_LEAN<br>
@@ -70,16 +92,16 @@ system_clock::now() _NOEXCEPT<br>
                        static_cast<__int64>(ft.<wbr>dwLowDateTime)};<br>
   return time_point(duration_cast<<wbr>duration>(d - nt_to_unix_epoch));<br>
 #else<br>
-#ifdef CLOCK_REALTIME<br>
+#if defined(_LIBCXX_USE_CLOCK_<wbr>GETTIME) && defined(CLOCK_REALTIME)<br>
     struct timespec tp;<br>
     if (0 != clock_gettime(CLOCK_REALTIME, &tp))<br>
         __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");<br>
     return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));<br>
-#else  // !CLOCK_REALTIME<br>
+#else<br>
     timeval tv;<br>
     gettimeofday(&tv, 0);<br>
     return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));<br>
-#endif  // CLOCK_REALTIME<br>
+#endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME<br>
 #endif<br>
 }<br>
<br>
@@ -106,6 +128,18 @@ const bool steady_clock::is_steady;<br>
<br>
 #if defined(__APPLE__)<br>
<br>
+// Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW<br>
+#if defined(_LIBCXX_USE_CLOCK_<wbr>GETTIME) && defined(CLOCK_UPTIME_RAW)<br>
+steady_clock::time_point<br>
+steady_clock::now() _NOEXCEPT<br>
+{<br>
+    struct timespec tp;<br>
+    if (0 != clock_gettime(CLOCK_UPTIME_<wbr>RAW, &tp))<br>
+        __throw_system_error(errno, "clock_gettime(CLOCK_UPTIME_<wbr>RAW) failed");<br>
+    return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));<br>
+}<br>
+<br>
+#else<br>
 //   mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of<br>
 //   nanoseconds since the computer booted up.  MachInfo.numer and MachInfo.denom<br>
 //   are run time constants supplied by the OS.  This clock has no relationship<br>
@@ -157,6 +191,7 @@ steady_clock::now() _NOEXCEPT<br>
     static FP fp = init_steady_clock();<br>
     return time_point(duration(fp()));<br>
 }<br>
+#endif // defined(_LIBCXX_USE_CLOCK_<wbr>GETTIME) && defined(CLOCK_UPTIME_RAW)<br>
<br>
 #elif defined(_LIBCPP_WIN32API)<br>
<br>
@@ -175,6 +210,13 @@ steady_clock::now() _NOEXCEPT<br>
<br>
 #elif defined(CLOCK_MONOTONIC)<br>
<br>
+// On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to<br>
+// time functions in the nanosecond range. Thus, they are the only acceptable<br>
+// implementations of steady_clock.<br>
+#ifdef __APPLE__<br>
+#error "Never use CLOCK_MONOTONIC for steady_clock::now on Apple platforms"<br>
+#endif<br>
+<br>
 steady_clock::time_point<br>
 steady_clock::now() _NOEXCEPT<br>
 {<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>