Boost C++ Libraries: Ticket #9041: [thread] Boost.Thread DSO's may need to link with Boost.Atomic https://svn.boost.org/trac10/ticket/9041 <p> libs/thread/src/pthread/once.cpp includes libs/thread/src/pthread/once_atomic.cpp, which includes boost/atomic.hpp, which (transitively) includes boost/atomic/detail/lockpool.hpp, which, depending on whether BOOST_ATOMIC_FLAG_LOCK_FREE is set, may need external reference to boost::atomics::detail::lockpool::get_lock_for(void const volatile *), defined in libbost_atomic.so.1.54.0. </p> <p> On most targets, BOOST_ATOMIC_FLAG_LOCK_FREE is set and the external reference is not necessary. On some, such as s390, it's not, and when linking to libboost_thread.so.1.54.0, the linker complains about unsatisfied references to above-mentioned symbol, such as: </p> <pre class="wiki">/lib64/libboost_thread.so.1.54.0: undefined reference to `boost::atomics::detail::lockpool::get_lock_for(void const volatile*)' </pre><p> In attached patch, I resolve this by testing whether BOOST_ATOMIC_FLAG_LOCK_FREE is defined. If not, I set up linking of libboost_atomic.so.1.54.0. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9041 Trac 1.4.3 Petr Machata <pmachata@…> Fri, 23 Aug 2013 22:44:47 GMT attachment set https://svn.boost.org/trac10/ticket/9041 https://svn.boost.org/trac10/ticket/9041 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-1.54.0-thread-link_atomic.patch</span> </li> </ul> <p> A fix. </p> Ticket Petr Machata <pmachata@…> Fri, 23 Aug 2013 22:47:15 GMT <link>https://svn.boost.org/trac10/ticket/9041#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:1</guid> <description> <p> Note that this seems to work--on x86_64 this produces no additional DT_NEEDED entry, on a short-circuit build of just Boost.Thread on s390x, this produces additional DT_NEEDED on Boost.Atomic. However, full s390x bootstrap has not yet finished, so I couldn't actually test whether that resolves the original problem (though I expect it to). </p> </description> <category>Ticket</category> </item> <item> <author>Petr Machata <pmachata@…></author> <pubDate>Sat, 24 Aug 2013 10:04:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:2</guid> <description> <p> The bootstrap has finished and I verified that the fix is effective. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 25 Aug 2013 14:48:13 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/9041#comment:3 https://svn.boost.org/trac10/ticket/9041#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Hi, thanks for the patch. I didn't know that we could configure the build in this way. Very interesting. </p> Ticket viboes Sun, 25 Aug 2013 15:04:02 GMT <link>https://svn.boost.org/trac10/ticket/9041#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:4</guid> <description> <p> BTW, how this path works when cross-compiling? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 25 Aug 2013 15:16:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:5</guid> <description> <p> For the time been I will link always with boost_atomic </p> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85464" title="Thread: link with boost_chrono and boost_atomic independently of the ...">[85464]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 25 Aug 2013 15:16:55 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/9041#comment:6 https://svn.boost.org/trac10/ticket/9041#comment:6 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.55.0</span> </li> </ul> Ticket Petr Machata <pmachata@…> Mon, 26 Aug 2013 14:29:24 GMT <link>https://svn.boost.org/trac10/ticket/9041#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:4" title="Comment 4">viboes</a>: </p> <blockquote class="citation"> <p> BTW, how this path works when cross-compiling? </p> </blockquote> <p> I don't know the details, I'm relying on configure.compile to pick the configured compiler. This is how all the configure checks are done FWIW, so I would certainly hope it just does the right thing here. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 26 Aug 2013 21:27:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:8</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:7" title="Comment 7">Petr Machata &lt;pmachata@…&gt;</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:4" title="Comment 4">viboes</a>: </p> <blockquote class="citation"> <p> BTW, how this path works when cross-compiling? </p> </blockquote> <p> I don't know the details, I'm relying on configure.compile to pick the configured compiler. This is how all the configure checks are done FWIW, so I would certainly hope it just does the right thing here. </p> </blockquote> <p> The problem I see is that you can not always run the cross compiled exe on the host. Am I missing something? </p> </description> <category>Ticket</category> </item> <item> <author>Petr Machata <pmachata@…></author> <pubDate>Mon, 26 Aug 2013 23:11:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:8" title="Comment 8">viboes</a>: </p> <blockquote class="citation"> <p> The problem I see is that you can not always run the cross compiled exe on the host. </p> </blockquote> <p> We're just building it, not running it. Even simply compiling the source (sans linking) would be enough, as all the magic is in a static assert, but I couldn't find how to request that. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 08 Sep 2013 09:55:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:10</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85603" title="Thread: merge from trunk upgrade_to_unique_lock::mutex() + doc typos + ...">[85603]</a> on release branch. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 08 Sep 2013 09:58:27 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:11</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:9" title="Comment 9">Petr Machata &lt;pmachata@…&gt;</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:8" title="Comment 8">viboes</a>: </p> <blockquote class="citation"> <p> The problem I see is that you can not always run the cross compiled exe on the host. </p> </blockquote> <p> We're just building it, not running it. Even simply compiling the source (sans linking) would be enough, as all the magic is in a static assert, but I couldn't find how to request that. </p> </blockquote> <p> I understand it now. </p> </description> <category>Ticket</category> </item> <item> <author>Petr Machata <pmachata@…></author> <pubDate>Mon, 09 Sep 2013 13:49:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:12</guid> <description> <p> So, do you intend to add the configure check? It seems like an overkill to link with Boost.Atomic just in case, as most platforms won't need it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 09 Sep 2013 18:03:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:13</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:12" title="Comment 12">Petr Machata &lt;pmachata@…&gt;</a>: </p> <blockquote class="citation"> <p> So, do you intend to add the configure check? It seems like an overkill to link with Boost.Atomic just in case, as most platforms won't need it. </p> </blockquote> <p> yes, see <a class="changeset" href="https://svn.boost.org/trac10/changeset/85616" title="Thread: link with boost_atomic conditionaly.">[85616]</a>. </p> </description> <category>Ticket</category> </item> <item> <author>Petr Machata <pmachata@…></author> <pubDate>Mon, 09 Sep 2013 20:11:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9041#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:14</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9041#comment:13" title="Comment 13">viboes</a>: </p> <blockquote class="citation"> <p> yes, see <a class="changeset" href="https://svn.boost.org/trac10/changeset/85616" title="Thread: link with boost_atomic conditionaly.">[85616]</a>. </p> </blockquote> <p> Awesome, thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 14 Sep 2013 14:24:04 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9041#comment:15 https://svn.boost.org/trac10/ticket/9041#comment:15 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/85666" title="Thread: merge atomic linked conditionaly + future:get_exception_ptr.">[85666]</a>. </p> Ticket Peter Vingelmann <peter@…> Tue, 14 Jan 2014 01:00:30 GMT <link>https://svn.boost.org/trac10/ticket/9041#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9041#comment:16</guid> <description> <p> Sorry for reviving this old issue, but we encountered the same problem again with several gcc 4.7+ cross-compilers. The problem is that atomic/detail/platform.hpp relies on <code>__atomic*</code> intrinsics for certain compiler versions (gcc 4.7+ and clang 3.2+). However, if <code>__GCC_ATOMIC_BOOL_LOCK_FREE</code> is not defined or its value is 1 (where 2 indicates always lock-free, and 1 indicates sometimes lock-free), then <code>BOOST_ATOMIC_FLAG_LOCK_FREE</code> will not be defined in gcc-atomic.hpp, and the external reference to atomic becomes necessary again. </p> <p> For example, consider this listing of defines for an Android cross-compiler: <a class="ext-link" href="http://slowbutdeadly.blogspot.hu/2013/09/android-prebuilt-gcc-47-builtin-macro.html"><span class="icon">​</span>http://slowbutdeadly.blogspot.hu/2013/09/android-prebuilt-gcc-47-builtin-macro.html</a> where <code>__GCC_ATOMIC_BOOL_LOCK_FREE</code> is 1. </p> <p> We would like to avoid linking with atomic, so I attached a patch which checks if <code>__GCC_ATOMIC_BOOL_LOCK_FREE</code> is 2, before including gcc-atomic.hpp. If the value is not 2, then the other include options are exhausted, before we have to link with atomic (depending on platform support). This solution works well for us on a range of cross-compilers. </p> <p> Perhaps the issue should also be raised in atomic. </p> </description> <category>Ticket</category> </item> <item> <author>Peter Vingelmann <peter@…></author> <pubDate>Tue, 14 Jan 2014 01:01:35 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/9041 https://svn.boost.org/trac10/ticket/9041 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost-1.55.0-atomic-check_lock_free_flag.patch</span> </li> </ul> <p> Fix for gcc 4.7+ cross-compilers. </p> Ticket viboes Fri, 17 Jan 2014 20:56:33 GMT component changed https://svn.boost.org/trac10/ticket/9041#comment:17 https://svn.boost.org/trac10/ticket/9041#comment:17 <ul> <li><strong>component</strong> <span class="trac-field-old">thread</span> → <span class="trac-field-new">atomic</span> </li> </ul> <p> Moving to Boost.Atomic. </p> Ticket