Boost C++ Libraries: Ticket #10942: Boost.Thread fails to build on Cygwin https://svn.boost.org/trac10/ticket/10942 <p> By default on Cygwin, the Boost.Thread headers choose the POSIX API. This decision is made in <code>boost/thread/detail/platform.hpp</code>: </p> <pre class="wiki">#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 </pre><p> In the Cygwin case, neither <code>BOOST_THREAD_POSIX</code> nor <code>BOOST_THREAD_WIN32</code> appear to be defined, but <code>BOOST_THREAD_CYGWIN</code>, so the logic above chooses <code>BOOST_THREAD_PLATFORM_PTHREAD</code>. </p> <p> This is actually correct, in my opinion; Cygwin is a POSIX platform. </p> <p> However, the Jamfile by default chooses Win32 on Cygwin: </p> <pre class="wiki">local rule default_threadapi ( ) { local api = pthread ; if [ os.name ] = "NT" { api = win32 ; } return $(api) ; } </pre><p> which later results in a bunch of errors when <code>win32/thread.cpp</code> is compiled against <code>pthread/thread_data.hpp</code> et al. </p> <p> So, either the default in <code>platform.hpp</code> should be changed to Win32 under Cygwin, or (better) the default <code>threadapi</code> in the Jamfile should be changed to <code>pthread</code> under Cygwin. </p> <p> Manually specifying <code>threadapi=pthread</code> is not a particularly good option, because Boost.Thread is a dependency of some tests, and when </p> <pre class="wiki">b2 toolset=gcc,gcc-cxx11,clang,clang-cxx11,msvc-8.0,msvc-10.0,msvc-11.0,msvc-12.0 </pre><p> (for example) is invoked to test a library, <code>threadapi=pthread</code> is not possible. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10942 Trac 1.4.3 Peter Dimov Sun, 18 Jan 2015 19:12:09 GMT owner changed https://svn.boost.org/trac10/ticket/10942#comment:1 https://svn.boost.org/trac10/ticket/10942#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> </ul> Ticket viboes Sun, 18 Jan 2015 21:47:49 GMT owner changed https://svn.boost.org/trac10/ticket/10942#comment:2 https://svn.boost.org/trac10/ticket/10942#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">viboes</span> to <span class="trac-author">Niall Douglas</span> </li> </ul> <p> I used to have a cygwin installation that worked. I'm unable to test it. I will see if Niall can do something. Niall? </p> Ticket Niall Douglas Mon, 19 Jan 2015 00:59:11 GMT <link>https://svn.boost.org/trac10/ticket/10942#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10942#comment:2" title="Comment 2">viboes</a>: </p> <blockquote class="citation"> <p> I used to have a cygwin installation that worked. I'm unable to test it. I will see if Niall can do something. Niall? </p> </blockquote> <p> I had a sneaking suspicion you'd bump this onto me :) </p> <p> I've actually been pretty ill last few days, the combination of medicines I was on unfortunately led to some poor choices of email to write as you may have noticed, so I deliberately have stayed away until the illness cleared and I no longer needed medicines. I intend to return to work tomorrow, albeit not at 100%. </p> <p> I'll aim for next Saturday, though <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/9856" title="#9856: Bugs: [windows] condition_variable::wait_for returns wrong cv_status on timeout. (closed: wontfix)">#9856</a> is before this in the queue. And, to be honest, that is a more important bug to fix than this in my opinion, so it may take some weeks. </p> <p> Niall </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Mon, 19 Jan 2015 02:09:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10942#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:4</guid> <description> <p> Get well, Niall. I'll try to figure something out. Vicente, if you're on Windows, Cygwin is incredibly easy to install, you just run their setup.exe. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Mon, 19 Jan 2015 03:23:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10942#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:5</guid> <description> <p> Nope, I couldn't figure anything out. :-) It's not possible to change the default value of the feature, because as I understand, in </p> <pre class="wiki">b2 toolset=gcc,msvc-8.0 </pre><p> the default can't have two values at the same time. It's not possible to compile the Win32 sources under Cygwin, this results in errors. Perhaps it's possible to add <code>&lt;threadapi&gt;pthread</code> to the requirements for <code>&lt;toolset&gt;gcc,&lt;target-os&gt;windows</code>, but this would break MinGW. There are references to <code>&lt;target-os&gt;</code> being <code>cygwin</code> in <code>gcc.jam</code>, but it's not. <code>&lt;gcc:flavor&gt;</code> is <code>mingw</code> on MinGW, but not set on Cygwin. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 19 Jan 2015 07:46:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10942#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:6</guid> <description> <p> Thanks Niall, and please, manage the priorities as you consider the best. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Niall Douglas</dc:creator> <pubDate>Tue, 20 Jan 2015 23:48:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10942#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10942#comment:5" title="Comment 5">pdimov</a>: </p> <blockquote class="citation"> <p> the default can't have two values at the same time. It's not possible to compile the Win32 sources under Cygwin, this results in errors. Perhaps it's possible to add <code>&lt;threadapi&gt;pthread</code> to the requirements for <code>&lt;toolset&gt;gcc,&lt;target-os&gt;windows</code>, but this would break MinGW. There are references to <code>&lt;target-os&gt;</code> being <code>cygwin</code> in <code>gcc.jam</code>, but it's not. <code>&lt;gcc:flavor&gt;</code> is <code>mingw</code> on MinGW, but not set on Cygwin. </p> </blockquote> <p> Peter, my expectation for compiling under cygwin is that you would configure b2 as if it were Linux. That means WIN32 is *not* defined. </p> <p> Cygwin isn't intended for compiling code that knows anything about Windows. I know it can be used as a "better than mingw", but to be honest since mingw-w64 came onto the scene it is neither a common use case nor a desirable one. </p> <p> As a personal preference, I'd also like to drop mingw32 support as soon as it presents problems. Mingw-w64 is consuming all the development resources nowadays, and right now mingw32 latest is producing broken segfaulting binaries for AFIO at least. I'm currently intending to drop mingw32 support for the next AFIO release, I simply couldn't be bothered patching around it any more when mingw-w64 just works first time and every time. </p> <p> BTW mingw-w64 also can produce 32 bit binaries. It is a total and much superior replacement for mingw32. </p> <p> Niall </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Thu, 19 Feb 2015 08:31:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10942#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:8</guid> <description> <p> Hi Peter, </p> <p> I'm on MacOS. </p> <p> This used to work. I have not changed anything related to cygwin since a lot time. </p> <p> Do you know of a bjam check that could identify cygwin? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Thu, 19 Feb 2015 13:22:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10942#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:9</guid> <description> <p> No. See </p> <p> <a class="ext-link" href="http://lists.boost.org/Archives/boost/2015/01/219408.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2015/01/219408.php</a> </p> <p> for my unsuccessful attempts to add &lt;threadapi&gt;pthread on Cygwin. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 04 Apr 2015 21:45:28 GMT</pubDate> <title>component changed https://svn.boost.org/trac10/ticket/10942#comment:10 https://svn.boost.org/trac10/ticket/10942#comment:10 <ul> <li><strong>component</strong> <span class="trac-field-old">thread</span> → <span class="trac-field-new">build</span> </li> </ul> <p> Moved to Boost.Build in case them have some ideas. </p> Ticket viboes Sat, 04 Apr 2015 21:46:11 GMT owner changed https://svn.boost.org/trac10/ticket/10942#comment:11 https://svn.boost.org/trac10/ticket/10942#comment:11 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Niall Douglas</span> to <span class="trac-author">Steven Watanabe</span> </li> </ul> <p> Steve, do you have an idea? </p> Ticket Steven Watanabe Sat, 04 Apr 2015 22:46:56 GMT <link>https://svn.boost.org/trac10/ticket/10942#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:12</guid> <description> <p> Use a conditional like this: </p> <pre class="wiki"> feature.feature threadapi : pthread win32 : optional propagated ; rule choose-threadapi ( properties * ) { local result = [ property.select &lt;threadapi&gt; : $(properties) ] ; if $(result) { return $(result) ; } if &lt;target-os&gt;windows in $(properties) { return &lt;threadapi&gt;win32 ; } else { return &lt;threadapi&gt;pthreads ; } } </pre><p> Note that this depends on &lt;target-os&gt;cygwin being set correctly, but that isn't Boost.Thread's problem. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Sat, 04 Apr 2015 22:53:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10942#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10942#comment:13</guid> <description> <p> As written this, of course, hits the "return doesn't really return" bug. It needs another else. </p> </description> <category>Ticket</category> </item> </channel> </rss>