Hi Mike, Can you check if https://reviews.llvm.org/D24475 fixes the issue for you? This looks like a bug in the gcc pre-processor (in older versions of gcc).
I'm a bit hesitant because my gcc (4.8.3) bumps into a different issue (crash!) as well, but that seem to have nothing to do with my patch (can reproduce without my patch...). Cheers, / Asiri On Mon, Sep 12, 2016 at 9:49 PM, Asiri Rathnayake < asiri.rathnay...@gmail.com> wrote: > OK, I'm able to reproduce locally. Looks like gcc (4.8.3 at least) does > not like my patch. > > Working on a fix... > > On Mon, Sep 12, 2016 at 9:43 PM, Asiri Rathnayake < > asiri.rathnay...@gmail.com> wrote: > >> Hi Mike, >> >> That does look related to my change. Is this an internal build? I was >> looking out for the bots on llvm.org but didn't spot any issues (yet). >> >> Will try to reproduce locally. Would it be OK if I find a fix tomorrow? >> (night time here in the UK), can revert if this is blocking you. >> >> Cheers, >> >> / Asiri >> >> >> On Mon, Sep 12, 2016 at 9:25 PM, Mike Aizatsky via cfe-commits < >> cfe-commits@lists.llvm.org> wrote: >> >>> Asiri, >>> >>> The boot strap build has started to fail for. Your change seems to be >>> related, right? >>> >>> [14/22] Building CXX object projects/libcxx/lib/CMakeFiles >>> /cxx_objects.dir/__/src/locale.cpp.o >>> FAILED: /usr/bin/g++ -D_DEBUG -D_GNU_SOURCE >>> -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D__STDC_CONSTANT_MACROS >>> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/libcxx/lib >>> -I/usr/local/google/home/aizatsky/ >>> src/llvm/projects/libcxx/lib -Iinclude >>> -I/usr/local/google/home/aizatsky/src/llvm/include >>> -I/usr/local/google/home/aizatsky/src/llvm/projects/libcxx/include >>> -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unuse >>> d-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers >>> -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor >>> -Wno-comment -std=c++11 -ffunction-sections -fdata-sections -O3 -UN >>> DEBUG -DLIBCXX_BUILDING_LIBCXXABI -std=c++11 -nostdinc++ -Wall -Wextra >>> -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long -Werror=return-type >>> -Wno-attributes -Wno-literal-suffix -Wno-c++14-compat -Wno-erro >>> r -fPIC -MMD -MT projects/libcxx/lib/CMakeFiles >>> /cxx_objects.dir/__/src/locale.cpp.o -MF projects/libcxx/lib/CMakeFiles >>> /cxx_objects.dir/__/src/locale.cpp.o.d -o projects/libcxx/lib/CMakeFiles >>> /cxx_objects.dir/__/ >>> src/locale.cpp.o -c /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/src/locale.cpp >>> In file included from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/__mutex_base:17:0, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/mutex:189, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/__locale:18, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/locale:182, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/src/locale.cpp:17: >>> /usr/local/google/home/aizatsky/src/llvm/projects/libcxx/inc >>> lude/__threading_support:22:90: error: missing binary operator before >>> token "(" >>> #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && >>> (!defined(__has_include) || __has_include(<__external_threading>)) >>> >>> ^ >>> In file included from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/algorithm:637:0, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/__string:55, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/string_view:166, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/include/string:464, >>> from /usr/local/google/home/aizatsk >>> y/src/llvm/projects/libcxx/src/locale.cpp:16: >>> >>> >>> On Sun, Sep 11, 2016 at 2:55 PM Asiri Rathnayake via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> >>>> Author: asiri >>>> Date: Sun Sep 11 16:46:40 2016 >>>> New Revision: 281179 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=281179&view=rev >>>> Log: >>>> [libcxx] Introduce an externally-threaded libc++ variant. >>>> >>>> This patch further decouples libc++ from pthread, allowing libc++ to be >>>> built >>>> against other threading systems. There are two main use cases: >>>> >>>> - Building libc++ against a thread library other than pthreads. >>>> >>>> - Building libc++ with an "external" thread API, allowing a separate >>>> library to >>>> provide the implementation of that API. >>>> >>>> The two use cases are quite similar, the second one being sligtly more >>>> de-coupled than the first. The cmake option >>>> LIBCXX_HAS_EXTERNAL_THREAD_API >>>> enables both kinds of builds. One needs to place an >>>> <__external_threading> >>>> header file containing an implementation of the "libc++ thread API" >>>> declared >>>> in the <__threading_support> header. >>>> >>>> For the second use case, the implementation of the libc++ thread API can >>>> delegate to a custom "external" thread API where the implementation of >>>> this >>>> external API is provided in a seperate library. This mechanism allows >>>> toolchain >>>> vendors to distribute a build of libc++ with a custom >>>> thread-porting-layer API >>>> (which is the "external" API above), platform vendors (recipients of the >>>> toolchain/libc++) are then required to provide their implementation of >>>> this API >>>> to be linked with (end-user) C++ programs. >>>> >>>> Note that the second use case still requires establishing the basic >>>> types that >>>> get passed between the external thread library and the libc++ library >>>> (e.g. __libcpp_mutex_t). These cannot be opaque pointer types (libc++ >>>> sources >>>> won't compile otherwise). It should also be noted that the second use >>>> case can >>>> have a slight performance penalty; as all the thread constructs need to >>>> cross a >>>> library boundary through an additional function call. >>>> >>>> When the header <__external_threading> is omitted, libc++ is built with >>>> the >>>> "libc++ thread API" (declared in <__threading_support>) as the >>>> "external" thread >>>> API (basic types are pthread based). An implementation (pthread based) >>>> of this >>>> API is provided in test/support/external_threads.cpp, which is built >>>> into a >>>> separate DSO and linked in when running the libc++ test suite. A test >>>> run >>>> therefore demonstrates the second use case (less the intermediate >>>> custom API). >>>> >>>> Differential revision: https://reviews.llvm.org/D21968 >>>> >>>> Reviewers: bcraig, compnerd, EricWF, mclow.lists >>>> >>>> Added: >>>> libcxx/trunk/test/support/external_threads.cpp >>>> - copied, changed from r280988, libcxx/trunk/test/libcxx/threa >>>> d/thread.mutex/thread.mutex.requirements/thread.mutex.requir >>>> ements.mutex/thread.mutex.class/native_handle.pass.cpp >>>> Modified: >>>> libcxx/trunk/CMakeLists.txt >>>> libcxx/trunk/include/__config >>>> libcxx/trunk/include/__config_site.in >>>> libcxx/trunk/include/__threading_support >>>> libcxx/trunk/include/thread >>>> libcxx/trunk/lib/CMakeLists.txt >>>> libcxx/trunk/test/CMakeLists.txt >>>> libcxx/trunk/test/libcxx/test/config.py >>>> libcxx/trunk/test/libcxx/thread/thread.condition/thread.cond >>>> ition.condvar/native_handle.pass.cpp >>>> libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex. >>>> class/native_handle.pass.cpp >>>> libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex. >>>> recursive/native_handle.pass.cpp >>>> libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread >>>> .class/thread.thread.member/native_handle.pass.cpp >>>> libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread >>>> .class/types.pass.cpp >>>> libcxx/trunk/test/lit.site.cfg.in >>>> >>>> Modified: libcxx/trunk/CMakeLists.txt >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists. >>>> txt?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/CMakeLists.txt (original) >>>> +++ libcxx/trunk/CMakeLists.txt Sun Sep 11 16:46:40 2016 >>>> @@ -140,6 +140,9 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK >>>> This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." >>>> ON) >>>> option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C >>>> library" OFF) >>>> option(LIBCXX_HAS_PTHREAD_API "Ignore auto-detection and force use of >>>> pthread API" OFF) >>>> +option(LIBCXX_HAS_EXTERNAL_THREAD_API >>>> + "Build libc++ with an externalized threading API. >>>> + This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." >>>> OFF) >>>> >>>> # Misc options ------------------------------ >>>> ---------------------------------- >>>> # FIXME: Turn -pedantic back ON. It is currently off because it warns >>>> @@ -197,6 +200,11 @@ if(LIBCXX_HAS_PTHREAD_API AND NOT LIBCXX >>>> " when LIBCXX_ENABLE_THREADS is also set to ON.") >>>> endif() >>>> >>>> +if(LIBCXX_HAS_EXTERNAL_THREAD_API AND NOT LIBCXX_ENABLE_THREADS) >>>> + message(FATAL_ERROR "LIBCXX_HAS_EXTERNAL_THREAD_API can only be set >>>> to ON" >>>> + " when LIBCXX_ENABLE_THREADS is also set to ON.") >>>> +endif() >>>> + >>>> # Ensure LLVM_USE_SANITIZER is not specified when >>>> LIBCXX_GENERATE_COVERAGE >>>> # is ON. >>>> if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) >>>> @@ -371,6 +379,17 @@ if (NOT LIBCXX_ENABLE_RTTI) >>>> add_compile_flags_if_supported(-fno-rtti) >>>> endif() >>>> >>>> +# Threading flags ============================== >>>> =============================== >>>> +if (LIBCXX_HAS_EXTERNAL_THREAD_API AND LIBCXX_ENABLE_SHARED) >>>> + # Need to allow unresolved symbols if this is to work with shared >>>> library builds >>>> + if (APPLE) >>>> + add_link_flags("-undefined dynamic_lookup") >>>> + else() >>>> + # Relax this restriction from HandleLLVMOptions >>>> + string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS >>>> "${CMAKE_SHARED_LINKER_FLAGS}") >>>> + endif() >>>> +endif() >>>> + >>>> # Assertion flags ============================== >>>> =============================== >>>> define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) >>>> define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) >>>> @@ -432,6 +451,7 @@ config_define_if_not(LIBCXX_ENABLE_MONOT >>>> config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS >>>> _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) >>>> >>>> config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD >>>> ) >>>> +config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API >>>> _LIBCPP_HAS_THREAD_API_EXTERNAL) >>>> config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) >>>> >>>> if (LIBCXX_NEEDS_SITE_CONFIG) >>>> >>>> Modified: libcxx/trunk/include/__config >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__c >>>> onfig?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/include/__config (original) >>>> +++ libcxx/trunk/include/__config Sun Sep 11 16:46:40 2016 >>>> @@ -831,7 +831,9 @@ extern "C" void __sanitizer_annotate_con >>>> #endif >>>> >>>> // Thread API >>>> -#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_THREAD_AP >>>> I_PTHREAD) >>>> +#if !defined(_LIBCPP_HAS_NO_THREADS) && \ >>>> + !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ >>>> + !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) >>>> # if defined(__FreeBSD__) || \ >>>> defined(__NetBSD__) || \ >>>> defined(__linux__) || \ >>>> @@ -849,6 +851,11 @@ extern "C" void __sanitizer_annotate_con >>>> _LIBCPP_HAS_NO_THREADS is not defined. >>>> #endif >>>> >>>> +#if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API >>>> _EXTERNAL) >>>> +# error _LIBCPP_HAS_EXTERNAL_THREAD_API may not be defined when \ >>>> + _LIBCPP_HAS_NO_THREADS is defined. >>>> +#endif >>>> + >>>> #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && >>>> !defined(_LIBCPP_HAS_NO_THREADS) >>>> # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ >>>> _LIBCPP_HAS_NO_THREADS is defined. >>>> >>>> Modified: libcxx/trunk/include/__config_site.in >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__c >>>> onfig_site.in?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/include/__config_site.in (original) >>>> +++ libcxx/trunk/include/__config_site.in Sun Sep 11 16:46:40 2016 >>>> @@ -20,5 +20,6 @@ >>>> #cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS >>>> #cmakedefine _LIBCPP_HAS_MUSL_LIBC >>>> #cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD >>>> +#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL >>>> >>>> #endif // _LIBCPP_CONFIG_SITE >>>> >>>> Modified: libcxx/trunk/include/__threading_support >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__t >>>> hreading_support?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/include/__threading_support (original) >>>> +++ libcxx/trunk/include/__threading_support Sun Sep 11 16:46:40 2016 >>>> @@ -19,20 +19,83 @@ >>>> >>>> #ifndef _LIBCPP_HAS_NO_THREADS >>>> >>>> -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) >>>> +#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) && >>>> (!defined(__has_include) || __has_include(<__external_threading>)) >>>> +#include <__external_threading> >>>> +#else >>>> #include <pthread.h> >>>> #include <sched.h> >>>> #endif >>>> >>>> -_LIBCPP_BEGIN_NAMESPACE_STD >>>> +#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) >>>> +#define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_FUNC_VIS >>>> +#else >>>> +#define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_INLINE_VISIBILITY >>>> +#endif >>>> >>>> -#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) >>>> +_LIBCPP_BEGIN_NAMESPACE_STD >>>> >>>> // Mutex >>>> -#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER >>>> typedef pthread_mutex_t __libcpp_mutex_t; >>>> +#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER >>>> + >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_mutex_lock(__libcpp_mutex_t* __m); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_mutex_trylock(__libcpp_mutex_t* __m); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_mutex_unlock(__libcpp_mutex_t* __m); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_mutex_destroy(__libcpp_mutex_t* __m); >>>> + >>>> +// Condition variable >>>> +typedef pthread_cond_t __libcpp_condvar_t; >>>> +#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_condvar_signal(__libcpp_condvar_t* __cv); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* >>>> __m); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, >>>> __libcpp_mutex_t* __m, timespec* __ts); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); >>>> + >>>> +// Thread id >>>> +typedef pthread_t __libcpp_thread_id; >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +bool __libcpp_thread_id_equal(__libcpp_thread_id t1, >>>> __libcpp_thread_id t2); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +bool __libcpp_thread_id_less(__libcpp_thread_id t1, >>>> __libcpp_thread_id t2); >>>> + >>>> +// Thread >>>> +typedef pthread_t __libcpp_thread_t; >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_thread_create(__libcpp_thread_t* __t, void* >>>> (*__func)(void*), void* __arg); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +__libcpp_thread_id __libcpp_thread_get_current_id(); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* >>>> __t); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_thread_join(__libcpp_thread_t* __t); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_thread_detach(__libcpp_thread_t* __t); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +void __libcpp_thread_yield(); >>>> + >>>> +// Thread local storage >>>> +typedef pthread_key_t __libcpp_tls_key; >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +int __libcpp_tls_create(__libcpp_tls_key* __key, void >>>> (*__at_exit)(void*)); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +void* __libcpp_tls_get(__libcpp_tls_key __key); >>>> +_LIBCPP_THREAD_ABI_VISIBILITY >>>> +void __libcpp_tls_set(__libcpp_tls_key __key, void* __p); >>>> + >>>> +#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || >>>> defined(_LIBCPP_BUILDING_EXTERNAL_THREADS) >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_recursive_mutex_init(__libcpp_mutex_t* __m) >>>> { >>>> pthread_mutexattr_t attr; >>>> @@ -59,144 +122,112 @@ int __libcpp_recursive_mutex_init(__libc >>>> return 0; >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_mutex_lock(__libcpp_mutex_t* __m) >>>> { >>>> return pthread_mutex_lock(__m); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_mutex_trylock(__libcpp_mutex_t* __m) >>>> { >>>> return pthread_mutex_trylock(__m); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) >>>> { >>>> return pthread_mutex_unlock(__m); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) >>>> { >>>> return pthread_mutex_destroy(__m); >>>> } >>>> >>>> // Condition variable >>>> -#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER >>>> -typedef pthread_cond_t __libcpp_condvar_t; >>>> - >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) >>>> { >>>> return pthread_cond_signal(__cv); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) >>>> { >>>> return pthread_cond_broadcast(__cv); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* >>>> __m) >>>> { >>>> return pthread_cond_wait(__cv, __m); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, >>>> __libcpp_mutex_t* __m, timespec* __ts) >>>> { >>>> return pthread_cond_timedwait(__cv, __m, __ts); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) >>>> { >>>> return pthread_cond_destroy(__cv); >>>> } >>>> >>>> -// Thread id >>>> -typedef pthread_t __libcpp_thread_id; >>>> - >>>> // Returns non-zero if the thread ids are equal, otherwise 0 >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> bool __libcpp_thread_id_equal(__libcpp_thread_id t1, >>>> __libcpp_thread_id t2) >>>> { >>>> return pthread_equal(t1, t2) != 0; >>>> } >>>> >>>> // Returns non-zero if t1 < t2, otherwise 0 >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> bool __libcpp_thread_id_less(__libcpp_thread_id t1, >>>> __libcpp_thread_id t2) >>>> { >>>> return t1 < t2; >>>> } >>>> >>>> // Thread >>>> -typedef pthread_t __libcpp_thread_t; >>>> - >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_thread_create(__libcpp_thread_t* __t, void* >>>> (*__func)(void*), void* __arg) >>>> { >>>> return pthread_create(__t, 0, __func, __arg); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> __libcpp_thread_id __libcpp_thread_get_current_id() >>>> { >>>> return pthread_self(); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) >>>> { >>>> return *__t; >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_thread_join(__libcpp_thread_t* __t) >>>> { >>>> return pthread_join(*__t, 0); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> int __libcpp_thread_detach(__libcpp_thread_t* __t) >>>> { >>>> return pthread_detach(*__t); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> void __libcpp_thread_yield() >>>> { >>>> sched_yield(); >>>> } >>>> >>>> // Thread local storage >>>> -typedef pthread_key_t __libcpp_tl_key; >>>> - >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> -int __libcpp_tl_create(__libcpp_tl_key* __key, void >>>> (*__at_exit)(void*)) >>>> +int __libcpp_tls_create(__libcpp_tls_key* __key, void >>>> (*__at_exit)(void*)) >>>> { >>>> return pthread_key_create(__key, __at_exit); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> -void* __libcpp_tl_get(__libcpp_tl_key __key) >>>> +void* __libcpp_tls_get(__libcpp_tls_key __key) >>>> { >>>> return pthread_getspecific(__key); >>>> } >>>> >>>> -inline _LIBCPP_ALWAYS_INLINE >>>> -void __libcpp_tl_set(__libcpp_tl_key __key, void* __p) >>>> +void __libcpp_tls_set(__libcpp_tls_key __key, void* __p) >>>> { >>>> pthread_setspecific(__key, __p); >>>> } >>>> >>>> -#else // !_LIBCPP_HAS_THREAD_API_PTHREAD >>>> - #error "No thread API selected." >>>> -#endif >>>> +#endif // _LIBCPP_HAS_THREAD_API_PTHREAD || >>>> _LIBCPP_BUILDING_EXTERNAL_THREADS >>>> >>>> _LIBCPP_END_NAMESPACE_STD >>>> >>>> >>>> Modified: libcxx/trunk/include/thread >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/thr >>>> ead?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/include/thread (original) >>>> +++ libcxx/trunk/include/thread Sun Sep 11 16:46:40 2016 >>>> @@ -137,7 +137,7 @@ public: >>>> template <class _Tp> >>>> class __thread_specific_ptr >>>> { >>>> - __libcpp_tl_key __key_; >>>> + __libcpp_tls_key __key_; >>>> >>>> // Only __thread_local_data() may construct a >>>> __thread_specific_ptr >>>> // and only with _Tp == __thread_struct. >>>> @@ -155,7 +155,7 @@ public: >>>> ~__thread_specific_ptr(); >>>> >>>> _LIBCPP_INLINE_VISIBILITY >>>> - pointer get() const {return static_cast<_Tp*>(__libcpp_tl_ >>>> get(__key_));} >>>> + pointer get() const {return static_cast<_Tp*>(__libcpp_tls >>>> _get(__key_));} >>>> _LIBCPP_INLINE_VISIBILITY >>>> pointer operator*() const {return *get();} >>>> _LIBCPP_INLINE_VISIBILITY >>>> @@ -173,7 +173,7 @@ __thread_specific_ptr<_Tp>::__at_thread_ >>>> template <class _Tp> >>>> __thread_specific_ptr<_Tp>::__thread_specific_ptr() >>>> { >>>> - int __ec = __libcpp_tl_create( >>>> + int __ec = __libcpp_tls_create( >>>> &__key_, >>>> &__thread_specific_ptr::__at_thread_exit); >>>> if (__ec) >>>> @@ -196,7 +196,7 @@ __thread_specific_ptr<_Tp>::set_pointer( >>>> { >>>> _LIBCPP_ASSERT(get() == nullptr, >>>> "Attempting to overwrite thread local data"); >>>> - __libcpp_tl_set(__key_, __p); >>>> + __libcpp_tls_set(__key_, __p); >>>> } >>>> >>>> class _LIBCPP_TYPE_VIS thread; >>>> >>>> Modified: libcxx/trunk/lib/CMakeLists.txt >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLi >>>> sts.txt?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/lib/CMakeLists.txt (original) >>>> +++ libcxx/trunk/lib/CMakeLists.txt Sun Sep 11 16:46:40 2016 >>>> @@ -201,6 +201,23 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) >>>> ) >>>> endif() >>>> >>>> +if (LIBCXX_HAS_EXTERNAL_THREAD_API) >>>> + file(GLOB LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES >>>> ../test/support/external_threads.cpp) >>>> + >>>> + if (LIBCXX_ENABLE_SHARED) >>>> + add_library(cxx_external_threads SHARED >>>> ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES}) >>>> + else() >>>> + add_library(cxx_external_threads STATIC >>>> ${LIBCXX_EXTERNAL_THREADING_SUPPORT_SOURCES}) >>>> + endif() >>>> + >>>> + set_target_properties(cxx_external_threads >>>> + PROPERTIES >>>> + LINK_FLAGS "${LIBCXX_LINK_FLAGS}" >>>> + COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" >>>> + OUTPUT_NAME "c++external_threads" >>>> + ) >>>> +endif() >>>> + >>>> # Generate a linker script inplace of a libc++.so symlink. Rerun this >>>> command >>>> # after cxx builds. >>>> if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) >>>> >>>> Modified: libcxx/trunk/test/CMakeLists.txt >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeL >>>> ists.txt?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/CMakeLists.txt (original) >>>> +++ libcxx/trunk/test/CMakeLists.txt Sun Sep 11 16:46:40 2016 >>>> @@ -22,6 +22,7 @@ pythonize_bool(LIBCXXABI_ENABLE_SHARED) >>>> pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) >>>> pythonize_bool(LIBCXX_HAS_ATOMIC_LIB) >>>> pythonize_bool(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB) >>>> +pythonize_bool(LIBCXX_HAS_EXTERNAL_THREAD_API) >>>> >>>> # The tests shouldn't link to any ABI library when it has been linked >>>> into >>>> # libc++ statically or via a linker script. >>>> @@ -52,10 +53,14 @@ if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY) >>>> set(experimental_dep cxx_experimental) >>>> endif() >>>> >>>> +if (LIBCXX_HAS_EXTERNAL_THREAD_API) >>>> + set(external_threads_dep cxx_external_threads) >>>> +endif() >>>> + >>>> add_lit_testsuite(check-cxx >>>> "Running libcxx tests" >>>> ${CMAKE_CURRENT_BINARY_DIR} >>>> - DEPENDS cxx ${experimental_dep}) >>>> + DEPENDS cxx ${experimental_dep} ${external_threads_dep}) >>>> >>>> add_custom_target(check-libcxx DEPENDS check-cxx) >>>> >>>> >>>> Modified: libcxx/trunk/test/libcxx/test/config.py >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx >>>> /test/config.py?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/libcxx/test/config.py (original) >>>> +++ libcxx/trunk/test/libcxx/test/config.py Sun Sep 11 16:46:40 2016 >>>> @@ -510,6 +510,10 @@ class Configuration(object): >>>> self.cxx.link_flags += [abs_path] >>>> else: >>>> self.cxx.link_flags += ['-lc++'] >>>> + # This needs to come after -lc++ as we want its unresolved >>>> thread-api symbols >>>> + # to be picked up from this one. >>>> + if self.get_lit_bool('libcxx_external_thread_api', >>>> default=False): >>>> + self.cxx.link_flags += ['-lc++external_threads'] >>>> >>>> def configure_link_flags_abi_library(self): >>>> cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi') >>>> >>>> Modified: libcxx/trunk/test/libcxx/thread/thread.condition/thread.cond >>>> ition.condvar/native_handle.pass.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx >>>> /thread/thread.condition/thread.condition.condvar/native_ >>>> handle.pass.cpp?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/libcxx/thread/thread.condition/thread.cond >>>> ition.condvar/native_handle.pass.cpp (original) >>>> +++ libcxx/trunk/test/libcxx/thread/thread.condition/thread.cond >>>> ition.condvar/native_handle.pass.cpp Sun Sep 11 16:46:40 2016 >>>> @@ -7,7 +7,7 @@ >>>> // >>>> //===------------------------------------------------------ >>>> ----------------===// >>>> // >>>> -// UNSUPPORTED: libcpp-has-no-threads >>>> +// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external >>>> >>>> // <condition_variable> >>>> >>>> >>>> Modified: libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex. >>>> class/native_handle.pass.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx >>>> /thread/thread.mutex/thread.mutex.requirements/thread.mutex. >>>> requirements.mutex/thread.mutex.class/native_handle. >>>> pass.cpp?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp >>>> (original) >>>> +++ libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp >>>> Sun Sep 11 16:46:40 2016 >>>> @@ -7,7 +7,7 @@ >>>> // >>>> //===------------------------------------------------------ >>>> ----------------===// >>>> // >>>> -// UNSUPPORTED: libcpp-has-no-threads >>>> +// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external >>>> >>>> // <mutex> >>>> >>>> >>>> Modified: libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex. >>>> recursive/native_handle.pass.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx >>>> /thread/thread.mutex/thread.mutex.requirements/thread.mutex. >>>> requirements.mutex/thread.mutex.recursive/native_handle. >>>> pass.cpp?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex. >>>> recursive/native_handle.pass.cpp (original) >>>> +++ libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex. >>>> recursive/native_handle.pass.cpp Sun Sep 11 16:46:40 2016 >>>> @@ -7,7 +7,7 @@ >>>> // >>>> //===------------------------------------------------------ >>>> ----------------===// >>>> // >>>> -// UNSUPPORTED: libcpp-has-no-threads >>>> +// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external >>>> >>>> // <mutex> >>>> >>>> >>>> Modified: libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread >>>> .class/thread.thread.member/native_handle.pass.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx >>>> /thread/thread.threads/thread.thread.class/thread.thread.mem >>>> ber/native_handle.pass.cpp?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread >>>> .class/thread.thread.member/native_handle.pass.cpp (original) >>>> +++ libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread >>>> .class/thread.thread.member/native_handle.pass.cpp Sun Sep 11 16:46:40 >>>> 2016 >>>> @@ -7,7 +7,7 @@ >>>> // >>>> //===------------------------------------------------------ >>>> ----------------===// >>>> // >>>> -// UNSUPPORTED: libcpp-has-no-threads >>>> +// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external >>>> >>>> // <thread> >>>> >>>> >>>> Modified: libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread >>>> .class/types.pass.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx >>>> /thread/thread.threads/thread.thread.class/types.pass.cpp?re >>>> v=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- >>>> libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp >>>> (original) >>>> +++ >>>> libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp >>>> Sun Sep 11 16:46:40 2016 >>>> @@ -7,7 +7,7 @@ >>>> // >>>> //===------------------------------------------------------ >>>> ----------------===// >>>> // >>>> -// UNSUPPORTED: libcpp-has-no-threads >>>> +// UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external >>>> >>>> // <thread> >>>> >>>> >>>> Modified: libcxx/trunk/test/lit.site.cfg.in >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.si >>>> te.cfg.in?rev=281179&r1=281178&r2=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/lit.site.cfg.in (original) >>>> +++ libcxx/trunk/test/lit.site.cfg.in Sun Sep 11 16:46:40 2016 >>>> @@ -26,6 +26,7 @@ config.has_libatomic = "@LIBC >>>> config.use_libatomic = "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@" >>>> >>>> config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@" >>>> +config.libcxx_external_thread_api = "@LIBCXX_HAS_EXTERNAL_THREAD_API@ >>>> " >>>> >>>> # Let the main config do the real work. >>>> lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg") >>>> >>>> Copied: libcxx/trunk/test/support/external_threads.cpp (from r280988, >>>> libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex. >>>> class/native_handle.pass.cpp) >>>> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/suppor >>>> t/external_threads.cpp?p2=libcxx/trunk/test/support/external >>>> _threads.cpp&p1=libcxx/trunk/test/libcxx/thread/thread. >>>> mutex/thread.mutex.requirements/thread.mutex.requirements. >>>> mutex/thread.mutex.class/native_handle.pass.cpp&r1= >>>> 280988&r2=281179&rev=281179&view=diff >>>> ============================================================ >>>> ================== >>>> --- libcxx/trunk/test/libcxx/thread/thread.mutex/thread.mutex.re >>>> quirements/thread.mutex.requirements.mutex/thread.mutex.class/native_handle.pass.cpp >>>> (original) >>>> +++ libcxx/trunk/test/support/external_threads.cpp Sun Sep 11 16:46:40 >>>> 2016 >>>> @@ -6,22 +6,5 @@ >>>> // Source Licenses. See LICENSE.TXT for details. >>>> // >>>> //===------------------------------------------------------ >>>> ----------------===// >>>> -// >>>> -// UNSUPPORTED: libcpp-has-no-threads >>>> - >>>> -// <mutex> >>>> - >>>> -// class mutex; >>>> - >>>> -// typedef pthread_mutex_t* native_handle_type; >>>> -// native_handle_type native_handle(); >>>> - >>>> -#include <mutex> >>>> -#include <cassert> >>>> - >>>> -int main() >>>> -{ >>>> - std::mutex m; >>>> - pthread_mutex_t* h = m.native_handle(); >>>> - assert(h); >>>> -} >>>> +#define _LIBCPP_BUILDING_EXTERNAL_THREADS >>>> +#include <__threading_support> >>>> >>>> >>>> _______________________________________________ >>>> cfe-commits mailing list >>>> cfe-commits@lists.llvm.org >>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >>>> >>> -- >>> Mike >>> Sent from phone >>> >>> _______________________________________________ >>> cfe-commits mailing list >>> cfe-commits@lists.llvm.org >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >>> >>> >> >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits