Boost C++ Libraries: Ticket #9842: long long not lockfree on i686 compiled with clang https://svn.boost.org/trac10/ticket/9842 <p> $ clang --version Hello, </p> <p> I just discovered that the lockfree test fails on trunk: </p> <h6 class="section" id="BEGINOUTPUT">BEGIN OUTPUT</h6> <p> atomic&lt;char&gt; is always lock free atomic&lt;short&gt; is always lock free atomic&lt;int&gt; is always lock free atomic&lt;long&gt; is always lock free lockfree.cpp(29): test lock_free_macro_val == lock_free_expect failed in function: 'void verify_lock_free(const char *, int, int) [T = long long]' atomic&lt;long long&gt; is never lock free atomic&lt;void *&gt; is always lock free atomic&lt;bool&gt; is always lock free </p> <p> My system is a Mac with 10.9 and Xcode 5.1: Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn) Target: x86_64-apple-darwin13.1.0 Thread model: posix </p> <p> I build the three with: b2 toolset=darwin architecture=x86 address-model=32 </p> <p> I think t boils down to the following: </p> <p> $ clang -march=core2 -dM -E - -m32 &lt; /dev/null|grep -i <span class="underline">GCC_ATOMIC_LLONG_LOCK_FREE #define </span>GCC_ATOMIC_LLONG_LOCK_FREE 1 </p> <p> The lockfree test expects 2 here. </p> <p> (Clang 3.4 on Linux also just returns 1 for long long). </p> <p> If I change the code in the platform header and switch from gcc-atomic.hpp to gcc-x86.hpp the test passes. </p> <p> Thanks, Gregor </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9842 Trac 1.4.3 gregor.jasny@… Mon, 07 Apr 2014 06:31:27 GMT <link>https://svn.boost.org/trac10/ticket/9842#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9842#comment:1</guid> <description> <p> Sorry for the messy formatting. It was late and I hit the wrong button. </p> <p> I just reproduced this on Redhat EL 6 with Clang from EPEL. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Mon, 07 Apr 2014 07:47:44 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/9842#comment:2 https://svn.boost.org/trac10/ticket/9842#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">Andrey.Semashev@…</span> added </li> </ul> <p> I believe there is a bug in clang because all Core 2 generation CPUs support cmpxchg8b instruction or 64-bit cmpxchg in 64-bit mode. The compiler should be defining the __GCC_ATOMIC_LLONG_LOCK_FREE macro to 2. This is what gcc does. Please, report it to clang team. </p> <p> As for Boost.Atomic behavior, it currently does not support "possibly hardware-supported" atomics because in some cases this results in linking errors. </p> <p> In this ticket we could probably work around the clang bug, if it also defines the target CPU macros correctly. If it doesn't there's really nothing we can do. Please, attach a full output of the <em>clang -march=core2 -dM -E - -m32 &lt; /dev/null</em> command to this ticket. </p> Ticket gjasny@… Mon, 07 Apr 2014 16:52:31 GMT <link>https://svn.boost.org/trac10/ticket/9842#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9842#comment:3</guid> <description> <p> I filed a bug report as LLVM Bug report <a class="missing ticket">#19355</a> </p> </description> <category>Ticket</category> </item> <item> <author>gjasny@…</author> <pubDate>Mon, 07 Apr 2014 16:53:44 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/9842 https://svn.boost.org/trac10/ticket/9842 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">clang-preprocessor.txt</span> </li> </ul> <p> clang preprocessor symbols - Xcode 5.1 (5B130a) </p> Ticket anonymous Thu, 17 Apr 2014 05:25:57 GMT <link>https://svn.boost.org/trac10/ticket/9842#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9842#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9842#comment:2" title="Comment 2">andysem</a>: </p> </description> <category>Ticket</category> </item> <item> <author>gjasny@…</author> <pubDate>Wed, 23 Apr 2014 11:14:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9842#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9842#comment:5</guid> <description> <p> Hello, </p> <p> since creation the Clang bug did not receive any attention. And because we cannot change the past I'd suggest that we try to work-around for now. </p> <p> Thanks, Gregor </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Wed, 23 Apr 2014 11:35:01 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9842#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9842#comment:6</guid> <description> <p> I've already added a workaround (although not tested) to my decouple_interface_impl_rewrite branch. I hope I'll be able to finish it and merge to develop before the release. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sat, 17 May 2014 16:15:37 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9842#comment:7 https://svn.boost.org/trac10/ticket/9842#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> The new version has been merged to develop and master and will be released in 1.56. </p> Ticket