<div dir="auto">@Nico: could you let me know your build configuration? (cmake options)<div dir="auto"><br></div><div dir="auto">I'm surprised this went unnoticed for so long.</div><div dir="auto"><br></div><div dir="auto">Thanks.</div><div dir="auto"><br></div><div dir="auto">/ Asiri</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 25 Jan 2017 5:52 p.m., "Asiri Rathnayake" <<a href="mailto:asiri.rathnayake@gmail.com">asiri.rathnayake@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">(including cfe-commits)<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 25, 2017 at 5:51 PM, Asiri Rathnayake <span dir="ltr"><<a href="mailto:asiri.rathnayake@gmail.com" target="_blank">asiri.rathnayake@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Nico,<div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 25, 2017 at 5:32 PM, Nico Weber 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Is it intentional that this change affects non-LIBCXX_HAS_EXTERNAL_THREAD<wbr>_API builds at all?#</div></blockquote><div><br></div><div>Nope. But I'm not sure how this got broken on Mac.</div><div><br></div><div>IIRC, <pthread.h> defines mach_port_t type on Mac, which gets included when _LIBCPP_HAS_THREAD_API_PT<wbr>HREAD is defined (which is what we expect to be the case on Mac, normally).</div><div><br></div><div>I'll have to build this on a Mac tomorrow. Hopefully that's OK?</div><div><br></div><div>Cheers,</div><div><br></div><div>/ Asiri</div><div><div class="m_9039017513823276460h5"><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="m_9039017513823276460m_-4316322079215227851gmail-HOEnZb"><div class="m_9039017513823276460m_-4316322079215227851gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 25, 2017 at 12:31 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">This breaks all our mac builds with:<div><br></div><div><div>/b/c/b/ClangToTMac__dbg_/src/t<wbr>hird_party/llvm-build/Release+<wbr>Asserts/bin/../include/c++/v1/<wbr>__threading_support:154:1: error: unknown type name 'mach_port_t'</div><div>mach_port_t __libcpp_thread_get_port();</div></div></div><div class="m_9039017513823276460m_-4316322079215227851gmail-m_6791344453587598749HOEnZb"><div class="m_9039017513823276460m_-4316322079215227851gmail-m_6791344453587598749h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 3, 2017 at 7:59 AM, Asiri Rathnayake 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: asiri<br>
Date: Tue Jan  3 06:59:50 2017<br>
New Revision: 290889<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=290889&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=290889&view=rev</a><br>
Log:<br>
[libcxx] Add build/test support for the externally threaded libc++abi variant<br>
<br>
Differential revision: <a href="https://reviews.llvm.org/D27576" rel="noreferrer" target="_blank">https://reviews.llvm.org/D2757<wbr>6</a><br>
<br>
Reviewers: EricWF<br>
<br>
Modified:<br>
    libcxx/trunk/CMakeLists.txt<br>
    libcxx/trunk/include/__threadi<wbr>ng_support<br>
    libcxx/trunk/test/CMakeLists.t<wbr>xt<br>
    libcxx/trunk/test/libcxx/test/<wbr>config.py<br>
    libcxx/trunk/test/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg<wbr>.in</a><br>
<br>
Modified: libcxx/trunk/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=290889&r1=290888&r2=290889&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/CMakeLists.<wbr>txt?rev=290889&r1=290888&r2=29<wbr>0889&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/CMakeLists.txt (original)<br>
+++ libcxx/trunk/CMakeLists.txt Tue Jan  3 06:59:50 2017<br>
@@ -221,14 +221,21 @@ if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_<br>
                       " when LIBCXX_ENABLE_THREADS is also set to OFF.")<br>
 endif()<br>
<br>
-if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX_ENABLE_THREADS)<br>
-  message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"<br>
-                      " when LIBCXX_ENABLE_THREADS is also set to ON.")<br>
+if(NOT LIBCXX_ENABLE_THREADS)<br>
+  if(LIBCXX_HAS_PTHREAD_API)<br>
+    message(FATAL_ERROR "LIBCXX_HAS_PTHREAD_API can only be set to ON"<br>
+                        " when LIBCXX_ENABLE_THREADS is also set to ON.")<br>
+  endif()<br>
+  if(LIBCXX_HAS_EXTERNAL_THREAD_<wbr>API)<br>
+    message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_AP<wbr>I can only be set to ON"<br>
+                        " when LIBCXX_ENABLE_THREADS is also set to ON.")<br>
+  endif()<br>
 endif()<br>
<br>
-if(LIBCXX_HAS_EXTERNAL_THREAD<wbr>_API AND NOT LIBCXX_ENABLE_THREADS)<br>
-  message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_AP<wbr>I can only be set to ON"<br>
-                      " when LIBCXX_ENABLE_THREADS is also set to ON.")<br>
+if(LIBCXX_HAS_PTHREAD_API AND LIBCXX_HAS_EXTERNAL_THREAD_API<wbr>)<br>
+  message(FATAL_ERROR "The options LIBCXX_HAS_EXTERNAL_THREAD_API<wbr>"<br>
+                      "and LIBCXX_HAS_PTHREAD_API cannot be both"<br>
+                      "set to ON at the same time.")<br>
 endif()<br>
<br>
 # Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE<br>
<br>
Modified: libcxx/trunk/include/__threadi<wbr>ng_support<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__threading_support?rev=290889&r1=290888&r2=290889&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/include/__t<wbr>hreading_support?rev=290889&r1<wbr>=290888&r2=290889&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/include/__threadi<wbr>ng_support (original)<br>
+++ libcxx/trunk/include/__threadi<wbr>ng_support Tue Jan  3 06:59:50 2017<br>
@@ -67,7 +67,11 @@ typedef pthread_mutex_t __libcpp_mutex_t<br>
 typedef pthread_cond_t __libcpp_condvar_t;<br>
 #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER<br>
<br>
-// THread ID<br>
+// Execute once<br>
+typedef pthread_once_t __libcpp_exec_once_flag;<br>
+#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT<br>
+<br>
+// Thread id<br>
 typedef pthread_t __libcpp_thread_id;<br>
<br>
 // Thread<br>
@@ -110,7 +114,17 @@ int __libcpp_condvar_timedwait(__l<wbr>ibcpp_<br>
 _LIBCPP_THREAD_ABI_VISIBILITY<br>
 int __libcpp_condvar_destroy(__lib<wbr>cpp_condvar_t* __cv);<br>
<br>
-// Thread ID<br>
+// Execute once<br>
+_LIBCPP_THREAD_ABI_VISIBILITY<br>
+int __libcpp_execute_once(__libcpp<wbr>_exec_once_flag *flag,<br>
+                          void (*init_routine)(void));<br>
+<br>
+// Thread id<br>
+#if defined(__APPLE__) && !defined(__arm__)<br>
+_LIBCPP_THREAD_ABI_VISIBILITY<br>
+mach_port_t __libcpp_thread_get_port();<br>
+#endif<br>
+<br>
 _LIBCPP_THREAD_ABI_VISIBILITY<br>
 bool __libcpp_thread_id_equal(__lib<wbr>cpp_thread_id t1, __libcpp_thread_id t2);<br>
<br>
@@ -145,7 +159,7 @@ _LIBCPP_THREAD_ABI_VISIBILITY<br>
 void *__libcpp_tls_get(__libcpp_tls<wbr>_key __key);<br>
<br>
 _LIBCPP_THREAD_ABI_VISIBILITY<br>
-void __libcpp_tls_set(__libcpp_tls_<wbr>key __key, void *__p);<br>
+int __libcpp_tls_set(__libcpp_tls_<wbr>key __key, void *__p);<br>
<br>
 #if defined(_LIBCPP_HAS_THREAD_API<wbr>_PTHREAD) || \<br>
     defined(_LIBCPP_BUILDING_THRE<wbr>AD_API_EXTERNAL_PTHREAD)<br>
@@ -221,6 +235,19 @@ int __libcpp_condvar_destroy(__lib<wbr>cpp_co<br>
   return pthread_cond_destroy(__cv);<br>
 }<br>
<br>
+// Execute once<br>
+int __libcpp_execute_once(__libcpp<wbr>_exec_once_flag *flag,<br>
+                          void (*init_routine)(void)) {<br>
+  return pthread_once(flag, init_routine);<br>
+}<br>
+<br>
+// Thread id<br>
+#if defined(__APPLE__) && !defined(__arm__)<br>
+mach_port_t __libcpp_thread_get_port() {<br>
+    return pthread_mach_thread_np(pthread<wbr>_self());<br>
+}<br>
+#endif<br>
+<br>
 // Returns non-zero if the thread ids are equal, otherwise 0<br>
 bool __libcpp_thread_id_equal(__lib<wbr>cpp_thread_id t1, __libcpp_thread_id t2)<br>
 {<br>
@@ -276,9 +303,9 @@ void *__libcpp_tls_get(__libcpp_tls<wbr>_key<br>
   return pthread_getspecific(__key);<br>
 }<br>
<br>
-void __libcpp_tls_set(__libcpp_tls_<wbr>key __key, void *__p)<br>
+int __libcpp_tls_set(__libcpp_tls_<wbr>key __key, void *__p)<br>
 {<br>
-  pthread_setspecific(__key, __p);<br>
+    return pthread_setspecific(__key, __p);<br>
 }<br>
<br>
 #endif // _LIBCPP_HAS_THREAD_API_PTHREAD<br>
<br>
Modified: libcxx/trunk/test/CMakeLists.t<wbr>xt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=290889&r1=290888&r2=290889&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/CMakeL<wbr>ists.txt?rev=290889&r1=290888&<wbr>r2=290889&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/CMakeLists.t<wbr>xt (original)<br>
+++ libcxx/trunk/test/CMakeLists.t<wbr>xt Tue Jan  3 06:59:50 2017<br>
@@ -55,18 +55,20 @@ configure_file(<br>
   ${CMAKE_CURRENT_BINARY_DIR}/l<wbr>it.site.cfg<br>
   @ONLY)<br>
<br>
+set(LIBCXX_TEST_DEPS "")<br>
+<br>
 if (LIBCXX_ENABLE_EXPERIMENTAL_LI<wbr>BRARY)<br>
-  set(experimental_dep cxx_experimental)<br>
+  set(LIBCXX_TEST_DEPS cxx_experimental)<br>
 endif()<br>
<br>
 if (LIBCXX_HAS_EXTERNAL_THREAD_AP<wbr>I)<br>
-  set(external_threads_dep cxx_external_threads)<br>
+  list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)<br>
 endif()<br>
<br>
 add_lit_testsuite(check-cxx<br>
   "Running libcxx tests"<br>
   ${CMAKE_CURRENT_BINARY_DIR}<br>
-  DEPENDS cxx ${experimental_dep} ${external_threads_dep})<br>
+  DEPENDS cxx ${LIBCXX_TEST_DEPS})<br>
<br>
 add_custom_target(check-libcx<wbr>x DEPENDS check-cxx)<br>
<br>
<br>
Modified: libcxx/trunk/test/libcxx/test/<wbr>config.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=290889&r1=290888&r2=290889&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/libcxx<wbr>/test/config.py?rev=290889&r1=<wbr>290888&r2=290889&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/libcxx/test/<wbr>config.py (original)<br>
+++ libcxx/trunk/test/libcxx/test/<wbr>config.py Tue Jan  3 06:59:50 2017<br>
@@ -579,10 +579,6 @@ class Configuration(object):<br>
                 self.cxx.link_flags += [abs_path]<br>
             else:<br>
                 self.cxx.link_flags += ['-lc++']<br>
-        # This needs to come after -lc++ as we want its unresolved thread-api symbols<br>
-        # to be picked up from this one.<br>
-        if self.get_lit_bool('libcxx_exte<wbr>rnal_thread_api', default=False):<br>
-            self.cxx.link_flags += ['-lc++external_threads']<br>
<br>
     def configure_link_flags_abi_libra<wbr>ry(self):<br>
         cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')<br>
@@ -611,6 +607,8 @@ class Configuration(object):<br>
                 'C++ ABI setting %s unsupported for tests' % cxx_abi)<br>
<br>
     def configure_extra_library_flags(<wbr>self):<br>
+        if self.get_lit_bool('cxx_ext_thr<wbr>eads', default=False):<br>
+            self.cxx.link_flags += ['-lc++external_threads']<br>
         self.target_info.add_cxx_link<wbr>_flags(self.cxx.link_flags)<br>
<br>
     def configure_color_diagnostics(se<wbr>lf):<br>
<br>
Modified: libcxx/trunk/test/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg<wbr>.in</a><br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=290889&r1=290888&r2=290889&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/libcxx/trunk/test/lit.si<wbr>te.cfg.in?rev=290889&r1=290888<wbr>&r2=290889&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- libcxx/trunk/test/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg<wbr>.in</a> (original)<br>
+++ libcxx/trunk/test/<a href="http://lit.site.cfg.in" rel="noreferrer" target="_blank">lit.site.cfg<wbr>.in</a> Tue Jan  3 06:59:50 2017<br>
@@ -28,7 +28,7 @@ config.has_libatomic            = "@LIBC<br>
 config.use_libatomic            = "@LIBCXX_HAVE_CXX_ATOMICS_WITH<wbr>_LIB@"<br>
<br>
 config.libcxxabi_shared         = "@LIBCXXABI_ENABLE_SHARED@"<br>
-config.libcxx_external_thread<wbr>_api  = "@LIBCXX_HAS_EXTERNAL_THREAD_A<wbr>PI@"<br>
+config.cxx_ext_threads          = "@LIBCXX_HAS_EXTERNAL_THREAD_A<wbr>PI@"<br>
<br>
 # Let the main config do the real work.<br>
 config.loaded_site_config = True<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">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>
</div></div></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">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>
<br></blockquote></div></div></div><br></div></div></div>
</blockquote></div><br></div></div>
</blockquote></div></div>