Boost C++ Libraries: Ticket #2525: More architectures that do not support __sync_fetch_and_add_4 https://svn.boost.org/trac10/ticket/2525 <p> Hi, </p> <p> As noted in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2263" title="#2263: Bugs: On PA-RISC with GCC 4.3.1, thread primitives are misdetected (closed: fixed)">#2263</a>, Boost makes the incorrect assumption that if the following condition is true: </p> <p> defined( GNUC ) &amp;&amp; ( GNUC * 100 + GNUC_MINOR &gt;= 401 ) </p> <p> then GCC sync primitives (e.g. sync_lock_test_and_set, sync_fetch_and_add) are available. </p> <p> Currently, hppa and arm are listed as exceptions. However, building Boost on Debian's 14 architectures suggests that some more exceptions are needed: <span class="underline">armel</span> (ARM in little endian mode), <span class="underline">m68k</span> and <span class="underline">sparc</span>. I'm attaching a patch to atomic_count.hpp to this effect. </p> <p> When using GNU C++ however, that patch means that all those machines fall through to atomic_count_gcc.hpp, which is known to be broken for GCC &gt; 4.1 (c.f. <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1084" title="#1084: Bugs: atomic_count_gcc.hpp tries to #include nonexistant header (closed: fixed)">#1084</a>, never applied). I'm attaching a patch for this problem, too. </p> <p> Note that these patches are only for the problems I noticed while building Boost, and only because we also build "tools/bcp", which happens to use shared_ptr. From grepping the sources it appears that there are a few others. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2525 Trac 1.4.3 Steven Robbins <smr@…> Sat, 22 Nov 2008 11:31:09 GMT attachment set https://svn.boost.org/trac10/ticket/2525 https://svn.boost.org/trac10/ticket/2525 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">atomic_count.patch</span> </li> </ul> Ticket Steven Robbins <smr@…> Sat, 22 Nov 2008 11:31:38 GMT attachment set https://svn.boost.org/trac10/ticket/2525 https://svn.boost.org/trac10/ticket/2525 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">atomic_count_gcc.patch</span> </li> </ul> Ticket smr@… Wed, 17 Dec 2008 05:28:49 GMT attachment set https://svn.boost.org/trac10/ticket/2525 https://svn.boost.org/trac10/ticket/2525 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">sp_counted_base.patch</span> </li> </ul> Ticket smr@… Wed, 17 Dec 2008 05:30:23 GMT <link>https://svn.boost.org/trac10/ticket/2525#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2525#comment:1</guid> <description> <p> Added sp_counted_base.patch to address another manifestation in sp_counted_base.hpp. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Sat, 28 Feb 2009 17:05:35 GMT</pubDate> <title>status, milestone changed https://svn.boost.org/trac10/ticket/2525#comment:2 https://svn.boost.org/trac10/ticket/2525#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.38.0</span> → <span class="trac-field-new">Boost 1.39.0</span> </li> </ul> Ticket Peter Dimov Sun, 01 Mar 2009 18:01:21 GMT <link>https://svn.boost.org/trac10/ticket/2525#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2525#comment:3</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/51517" title="Refs #2525 (fixed in trunk.)">[51517]</a>) Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2525" title="#2525: Bugs: More architectures that do not support __sync_fetch_and_add_4 (closed: fixed)">#2525</a> (fixed in trunk.) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Mon, 02 Mar 2009 16:42:30 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2525#comment:4 https://svn.boost.org/trac10/ticket/2525#comment:4 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/51538" title="Merge [51517] to release. Closes #2525.">[51538]</a>) Merge <a class="changeset" href="https://svn.boost.org/trac10/changeset/51517" title="Refs #2525 (fixed in trunk.)">[51517]</a> to release. Closes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2525" title="#2525: Bugs: More architectures that do not support __sync_fetch_and_add_4 (closed: fixed)">#2525</a>. </p> Ticket Peter Dimov Tue, 03 Mar 2009 15:29:27 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/2525#comment:5 https://svn.boost.org/trac10/ticket/2525#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> Reopening due to the claim in </p> <p> <a class="ext-link" href="http://lists.boost.org/Archives/boost/2007/11/130479.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2007/11/130479.php</a> </p> <p> that g++ 4.2 has __sync operations on __sparc__. Steven, can you please confirm or deny it? </p> Ticket smr@… Mon, 09 Mar 2009 03:15:27 GMT <link>https://svn.boost.org/trac10/ticket/2525#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2525#comment:6</guid> <description> <p> On the sparc to which I have access (a sparc64 running Debian Linux), I can attest that g++ 4.2 does *not* have all the __sync primitives used in Boost. I created a test program using all the primitives I could find with "rgrep __sync_ *" in the Boost root source directory (SVN head). </p> <p> Here is the transcript. </p> <pre class="wiki">(sid)smr@smetana:~$ uname -a Linux smetana 2.6.26-1-sparc64-smp #1 SMP Sat Jan 10 18:53:17 UTC 2009 sparc64 GNU/Linux (sid)smr@smetana:~$ cat sync-primitives.cc /* Test that uses all the __sync primitives found by grepping the boost sources. */ int main( int ac, char* av[] ) { long value = 0; __sync_lock_release( &amp;value ); return __sync_fetch_and_add( &amp;value, 1 ) + __sync_val_compare_and_swap( &amp;value, 1, 2 ) + __sync_add_and_fetch( &amp;value, 1 ) + __sync_lock_test_and_set( &amp;value, 1 ); } (sid)smr@smetana:~$ g++-4.1 sync-primitives.cc /tmp/ccGOFRyI.o: In function `main': sync-primitives.cc:(.text+0x24): undefined reference to `__sync_fetch_and_add_4' sync-primitives.cc:(.text+0x44): undefined reference to `__sync_val_compare_and_swap_4' sync-primitives.cc:(.text+0x60): undefined reference to `__sync_add_and_fetch_4' sync-primitives.cc:(.text+0x7c): undefined reference to `__sync_lock_test_and_set_4' collect2: ld returned 1 exit status (sid)smr@smetana:~$ g++-4.2 sync-primitives.cc /tmp/ccQg4NKe.o: In function `main': sync-primitives.cc:(.text+0x28): undefined reference to `__sync_fetch_and_add_4' sync-primitives.cc:(.text+0x48): undefined reference to `__sync_val_compare_and_swap_4' sync-primitives.cc:(.text+0x64): undefined reference to `__sync_add_and_fetch_4' collect2: ld returned 1 exit status (sid)smr@smetana:~$ g++-4.3 sync-primitives.cc /tmp/cc8anhqk.o: In function `main': sync-primitives.cc:(.text+0x28): undefined reference to `__sync_fetch_and_add_4' sync-primitives.cc:(.text+0x48): undefined reference to `__sync_val_compare_and_swap_4' sync-primitives.cc:(.text+0x64): undefined reference to `__sync_add_and_fetch_4' collect2: ld returned 1 exit status </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Mon, 09 Mar 2009 15:25:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2525#comment:7 https://svn.boost.org/trac10/ticket/2525#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> OK, closing as fixed, thanks. </p> Ticket