Boost C++ Libraries: Ticket #7473: clang defines __GNUC__ and confuses the libstdcpp3.hpp configuration header https://svn.boost.org/trac10/ticket/7473 <p> clang defines (at least on the current trunk) <span class="underline">GNUC</span>, <span class="underline">GNUC_MINOR</span>, and <span class="underline">GNUC_PATCHLEVEL</span> to 4, 2, and 1 respectively. When used with -std=c++11 <span class="underline">GXX_EXPERIMENTAL_CXX0X</span> will be defined as well. When using libstdcpp in combination with clang the boost configuration header libstdcpp3.hpp will use those broken version to detect library headers and features. Given the relatively low version number, most headers wont be available, which is counter-intuitive and can break in subtle ways. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7473 Trac 1.4.3 viboes Mon, 29 Oct 2012 02:22:08 GMT <link>https://svn.boost.org/trac10/ticket/7473#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:1</guid> <description> <p> I guess that you need to link with libc++ with clang as libstdcpp doesn't support c++11 features. </p> <p> I'm using this </p> <pre class="wiki">using clang : 3.2xl : /Users/viboes/clang/build/Debug+Asserts/bin/clang++ : &lt;cxxflags&gt;"-std=c++11 -stdlib=libc++" &lt;linkflags&gt;"-std=c++11 -stdlib=libc++" ; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Mon, 29 Oct 2012 03:38:07 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:2</guid> <description> <p> Clang can work with more recent versions of libstdc++ than gcc-4.2's libstdc++ (though sometimes <a class="ext-link" href="http://clang.llvm.org/cxx_status.html"><span class="icon">​</span>patches</a> are needed). With those stdlib, we can use C++11 features. </p> <p> What is needed here is to use <code>__GLIBCXX__</code> to detect the version of libstdc++. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Michel Morin</dc:creator> <pubDate>Mon, 29 Oct 2012 03:44:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:3</guid> <description> <p> The above comment (comment 2) is the reply to comment 1. </p> </description> <category>Ticket</category> </item> <item> <author>philipp.moeller@…</author> <pubDate>Mon, 29 Oct 2012 09:18:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7473#comment:2" title="Comment 2">michel</a>: </p> <blockquote class="citation"> <p> Clang can work with more recent versions of libstdc++ than gcc-4.2's libstdc++ (though sometimes <a class="ext-link" href="http://clang.llvm.org/cxx_status.html"><span class="icon">​</span>patches</a> are needed). With those stdlib, we can use C++11 features. </p> <p> What is needed here is to use <code>__GLIBCXX__</code> to detect the version of libstdc++. </p> </blockquote> <p> It seems the mistake is to use the gcc version to detect the version of the library to begin with. However, I cannot find a good reference for the macros that good be used to detect the libstdc++ version besides <a class="ext-link" href="http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html"><span class="icon">​</span>this page</a>. <code>__GLIBCXX__</code> doesn't seem particularly helpful unless someone is willing to figure out what those values can be and create a table from them. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Tue, 19 Feb 2013 13:23:49 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7473#comment:5 https://svn.boost.org/trac10/ticket/7473#comment:5 <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">wontfix</span> </li> </ul> <blockquote class="citation"> <p> What is needed here is to use <code>__GLIBCXX__</code> to detect the version of libstdc++. </p> </blockquote> <p> That's what we used to do originally. However, it caused a whole bunch of problems and we were specifically advised against doing that by the libstdc++ developers. The issue is that <code>__GLIBCXX__</code> can have a higher value for say gcc-4.4.x than for gcc-4.5.0 but fewer features. I believe the bug here is in clang (or in the way you're using it). As far as I can see the only reliable way to support non-standard configurations like this is to use the supplied configure script to generate a custom configuration: <a href="http://www.boost.org/doc/libs/1_53_0/libs/config/doc/html/index.html#boost_config.configuring_boost_for_your_platform.using_the_configure_script">http://www.boost.org/doc/libs/1_53_0/libs/config/doc/html/index.html#boost_config.configuring_boost_for_your_platform.using_the_configure_script</a> </p> Ticket boost@… Fri, 10 May 2013 10:54:33 GMT <link>https://svn.boost.org/trac10/ticket/7473#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:6</guid> <description> <p> I'm hesitant to reopen because I'm relatively new to boost, but I believe this is still a big issue, and will become even more annoying in the future if nothing is done. It is frustrating that it is such a hurdle to use modern features of the most important C++ library with a modern mature wide spread C++ compiler. </p> <p> Bumping <code>__GNUC_MINOR__</code> has been discussed and discarded by clang-dev <a class="ext-link" href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-May/021510.html"><span class="icon">​</span>http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-May/021510.html</a> </p> <p> So what about an additional check using <code>__clang_major__</code> and <code>__clang_minor__</code>? This seems only consistent if you choose (for good reason) not to use <code>__GLIBCXX__</code>. Blaming this to be a bug in clang doesn't really help anyone either. </p> <p> P.S.: Even Jonathan Wakely advises against using <code>__GXX_EXPERIMENTAL_CXX0X__</code> </p> <p> <a class="ext-link" href="http://gcc.gnu.org/ml/gcc-help/2011-05/msg00354.html"><span class="icon">​</span>http://gcc.gnu.org/ml/gcc-help/2011-05/msg00354.html</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 17 May 2013 08:38:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:7</guid> <description> <p> Another suggestion: the availabilty of C++11 features may also (should) be tested by checking _ _cplusplus <a class="ext-link" href="http://gcc.gnu.org/ml/gcc-help/2011-05/msg00355.html"><span class="icon">​</span>http://gcc.gnu.org/ml/gcc-help/2011-05/msg00355.html</a> </p> <p> This macro is defined in the C++ Standard and independent of the specific compiler, be it GCC or Clang. </p> <p> GCC 4.7 is cheating, however, they set _ _cplusplus to 201103L, but haven't fully implemented the new features. This happened in GCC 4.8.1 only: <a class="ext-link" href="http://gcc.gnu.org/gcc-4.8/cxx0x_status.html"><span class="icon">​</span>http://gcc.gnu.org/gcc-4.8/cxx0x_status.html</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 17 May 2013 10:59:36 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:8</guid> <description> <p> The issue here is that the compiler and std lib are out of synch with each other. Testing the clang or std version doesn't help if the library was actually shipped for an older compiler version as is the case here. </p> <p> I repeat - what's wrong with using the supplied configure script to fix unsupported configurations like this? See <a href="http://www.boost.org/doc/libs/1_53_0/libs/config/doc/html/index.html#boost_config.configuring_boost_for_your_platform.using_the_configure_script">http://www.boost.org/doc/libs/1_53_0/libs/config/doc/html/index.html#boost_config.configuring_boost_for_your_platform.using_the_configure_script</a> </p> </description> <category>Ticket</category> </item> <item> <author>Nicolas.Hoeft@…</author> <pubDate>Sat, 18 May 2013 16:21:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:9</guid> <description> <p> IMHO, the problem is that this configuration (clang + gcc stdlibc++) is not that uncommon on linux and usually work quite well together. libc++ seems not to be in that good shape (for linux) and it's quite a hassle installing it. </p> <p> The problem with user-defined configurations is that if you are writing a library that uses boost, every user of that library will have to configure boost by himself.. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sun, 19 May 2013 11:08:51 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:10</guid> <description> <p> Here's the thing: I'm quite happy to apply a fix for this, but I just don't see how it can possibly be made to work. To recap: </p> <ul><li><code>__GLIBCXX__</code> is useless for this purpose as it reflect release date, not lib version. </li><li><code>__clang_major__</code> tells us nothing about the std lib, only about Clang itself. </li><li><code>__cplusplus</code> tells us nothing about the std lib, only Clang itself. </li><li>I can't see any internal libstdc++ macros can can be used for this purpose. </li><li>There's no way to tell whether the necessary patches (some official some not) have been applied to libstdc++, to pick one example recent versions of &lt;type_traits&gt; don't compile with <code>clang -std=gnu++11</code> because clang lacks <code>___float128</code>. It's trivial to patch, but there's no official clang patch last time I looked. </li><li>Clang only claims to be compatible with GCC-4.2.1, frankly anything else is unsupported as far as I can see... even though use with later versions is very useful and what most of us actually do! </li></ul><p> Finally, if the user has to patch libstdc++, why not patch/configure boost as well? At least Intel's compiler sets the GCC version number to match that of the underlying std lib which avoids all this nonsense. </p> <p> So... I don't see any way to fix this unless someone submits a patch that "works" and avoids the above pitfalls. The only thing I could think of, would be to use <code>__GLIBCXX__</code> to detect libstdc++ features <em>only</em> when the compiler is clang. That would work some of the time, but break boost completely some of the time too, which frankly is not a path I want to take. </p> </description> <category>Ticket</category> </item> <item> <author>boost@…</author> <pubDate>Thu, 23 May 2013 16:00:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:11</guid> <description> <p> Thank you johnmaddock for the detailed and rational description. I do have a few remarks though: </p> <ul><li>Is clangs compatibility with gcc really relevant here? Shoudln't the C++11 compatibility be primary here? </li><li>Yes clang -std=gnu++11 is broken </li></ul><p> Simply trying to compile the following with clang++ -std=gnu++11 fails for me due to said lack of <code>__float128</code>: </p> <pre class="wiki">#include &lt;boost/functional/hash.hpp&gt; </pre><p> (Boost 1.53.0, clang 3.2.6, libstdc++ of gcc 4.8.0 on arch). IMHO it looks to me that clang (with gnu++11 and libstd++) is broken and should be fixed (since it doesn't allow me to include &lt;utility&gt;). Or would you consider that a case of boost being completely broken? </p> <ul><li>So what about allowing all the nice features if all of the following holds: <ul><li>Compiler is clang </li><li><code>__GLIBCXX__</code> is reasonably new: Pick a date where it is safe to assume that all later releases support the features plus maybe a list of release dates of versions known to support the features. </li><li><code>__cplusplus</code> is C++11 </li><li><code>__STRICT_ANSI__</code> is defined indicating that it's not gnu++11. </li></ul></li></ul> </description> <category>Ticket</category> </item> <item> <author>lukester_null@…</author> <pubDate>Fri, 29 Aug 2014 13:04:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:12</guid> <description> <p> I just tripped over this head-scratcher (why can't I construct a shared_ptr from a unique_ptr?!). </p> <p> For what it's worth, I've tried a quick hack commenting out all ACTIV_BOOST_NO_CXX11_* macros in libstdcpp3.hpp for 4.3-4.7 GCC when building with clang 3.4 and libstdc++ 4.8.3. </p> <p> Boost 1.56 with std=c++11 builds successfully, as do all the tests (except 1 that happens with a plain g++ 4.8.3 c++11 build, too). </p> <p> Doesn't help with the GLIBCXX problem, I'm just pointing out that no patches had to be applied (unless Fedora themselves do so, I suppose). </p> <p> Regards </p> <p> Luke Elliott. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sat, 04 Oct 2014 12:28:55 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:13</guid> <description> <p> Update: I looked at this again with a view to making cautious use of <code>__GLIBCXX__</code> when the compiler is clang, but <code>__GLIBCXX__</code> versions are so scrambled up as to be functionally useless, for example looking at <a class="ext-link" href="https://www.gnu.org/software/gcc/releases.html"><span class="icon">​</span>https://www.gnu.org/software/gcc/releases.html</a> I see </p> <pre class="wiki">libstdc++ 4.3.5 later than 4.5 libstdc++ 4.3.6 later than 4.6 libstdc++ 4.5.4 later than 4.7 libstdc++ 4.6.4 later than 4.8 libstdc++ 4.7.4 later than 4.9 </pre><p> And that's just the obvious ones, and doesn't include "unofficial" releases from Apple etc. </p> <p> Back to square 1... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sun, 05 Oct 2014 16:03:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:14</guid> <description> <p> There's a tentative patch for this issue here: <a class="ext-link" href="https://github.com/boostorg/config/commit/b36566fe04a89103b7ef5569c03e3a26eb77af36"><span class="icon">​</span>https://github.com/boostorg/config/commit/b36566fe04a89103b7ef5569c03e3a26eb77af36</a> </p> <p> Replacement header for testing with here: <a class="ext-link" href="https://raw.githubusercontent.com/boostorg/config/b36566fe04a89103b7ef5569c03e3a26eb77af36/include/boost/config/stdlib/libstdcpp3.hpp"><span class="icon">​</span>https://raw.githubusercontent.com/boostorg/config/b36566fe04a89103b7ef5569c03e3a26eb77af36/include/boost/config/stdlib/libstdcpp3.hpp</a> </p> <p> I'd be grateful if as many folks as possible can test this and report back, thanks! </p> </description> <category>Ticket</category> </item> <item> <author>marc.glisse@…</author> <pubDate>Sun, 05 Oct 2014 17:13:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7473#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:15</guid> <description> <p> Sorry for missing this PR, as it was closed a search didn't show it. For 4.8 I can suggest &lt;debug/array&gt; or &lt;ext/random&gt; or &lt;ext/cmath&gt;. For 4.9, maybe &lt;shared_mutex&gt; or &lt;bits/c++14_warning.h&gt;, or &lt;experimental/optional&gt; or &lt;experimental/string_view&gt;. For 5, &lt;experimental/any&gt; for now, maybe something with filesystem soon. </p> </description> <category>Ticket</category> </item> <item> <author>matwey.kornilov@…</author> <pubDate>Sun, 30 Aug 2015 20:08:39 GMT</pubDate> <title>status, version changed; resolution deleted https://svn.boost.org/trac10/ticket/7473#comment:16 https://svn.boost.org/trac10/ticket/7473#comment:16 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.51.0</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> <p> Problem is still present at least in 1.56 </p> Ticket matwey.kornilov@… Sun, 30 Aug 2015 20:33:21 GMT <link>https://svn.boost.org/trac10/ticket/7473#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7473#comment:17</guid> <description> <p> 1.56 is the last broken version </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Tue, 31 Jul 2018 18:29:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7473#comment:18 https://svn.boost.org/trac10/ticket/7473#comment:18 <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">obsolete</span> </li> </ul> Ticket