[Boost-bugs] [Boost C++ Libraries] #10942: Boost.Thread fails to build on Cygwin

Subject: [Boost-bugs] [Boost C++ Libraries] #10942: Boost.Thread fails to build on Cygwin
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-18 19:11:18


#10942: Boost.Thread fails to build on Cygwin
------------------------------+----------------------
 Reporter: pdimov | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
  Version: Boost 1.57.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------
 By default on Cygwin, the Boost.Thread headers choose the POSIX API. This
 decision is made in `boost/thread/detail/platform.hpp`:

 {{{
 #if defined(BOOST_THREAD_POSIX)
 # define BOOST_THREAD_PLATFORM_PTHREAD
 #else
 # if defined(BOOST_THREAD_WIN32)
 # define BOOST_THREAD_PLATFORM_WIN32
 # elif defined(BOOST_HAS_PTHREADS)
 # define BOOST_THREAD_PLATFORM_PTHREAD
 # else
 # error "Sorry, no boost threads are available for this platform."
 # endif
 #endif
 }}}

 In the Cygwin case, neither `BOOST_THREAD_POSIX` nor `BOOST_THREAD_WIN32`
 appear to be defined, but `BOOST_THREAD_CYGWIN`, so the logic above
 chooses `BOOST_THREAD_PLATFORM_PTHREAD`.

 This is actually correct, in my opinion; Cygwin is a POSIX platform.

 However, the Jamfile by default chooses Win32 on Cygwin:

 {{{
 local rule default_threadapi ( )
 {
     local api = pthread ;
     if [ os.name ] = "NT" { api = win32 ; }
     return $(api) ;
 }
 }}}

 which later results in a bunch of errors when `win32/thread.cpp` is
 compiled against `pthread/thread_data.hpp` et al.

 So, either the default in `platform.hpp` should be changed to Win32 under
 Cygwin, or (better) the default `threadapi` in the Jamfile should be
 changed to `pthread` under Cygwin.

 Manually specifying `threadapi=pthread` is not a particularly good option,
 because Boost.Thread is a dependency of some tests, and when

 {{{
 b2 toolset=gcc,gcc-cxx11,clang,clang-
 cxx11,msvc-8.0,msvc-10.0,msvc-11.0,msvc-12.0
 }}}

 (for example) is invoked to test a library, `threadapi=pthread` is not
 possible.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10942>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC