Re: Using C++11



On Mon, 29 Jun 2015 08:18:12 +0200
Murray Cumming <murrayc murrayc com> wrote:
On Sun, 2015-06-28 at 20:30 +0100, Chris Vine wrote:
On Sun, 28 Jun 2015 20:17:28 +0200
Murray Cumming <murrayc murrayc com> wrote:
Given that --std=c+11 breaks ABI compatibility (at least in the
standard library), I wonder if/when distros would ever build
glibmm with C++11 support.

gcc-3.4 and gcc-4.* do not provide libstdc++ with a C++11 compliant
ABI (this is mainly concerned with gcc's copy on write string
implementation) and gcc-5.1 does by default do so,
[snip]

So do you think any apps have been built with C++11 on mainstream
distros so far?

Yes, if only because mozilla now requires c++11.  I occasionally see
other things I compile which test for C++11, although don't ask me what
they were. However, far more will link with C++11 code dynamically
without knowing it.  I noticed that llvm-3.6 now uses C++11 (I filed a
bug when mesa-10.4 failed to compile with llvm-3.6 because llvm-3.6
switched to std::unique_ptr - mesa 10.5 now does compile with llvm-3.6).

Some form of C++11 support has been available in gcc for ages - gcc-4.4
for example provided some support (smart pointers, variadic templates,
move semantics, the additional wide character types and some of C++11
threads). gcc-4.5 supported lambdas and most of C++11 threads (but not
the memory model).  gcc-4.6 supported range-for and an improved template
implementation.  gcc-4.7 was nearly C++11 complete (including template
aliasing) except that it did not support the full C++11 memory model
nor regular expressions and some of its tuple implementation was not
fully conforming.  gcc-4.8 seems to be pretty much completely
conforming (including the C++ memory model) except for regular
expressions. gcc-4.9 I think is pretty well c++11 complete (including
regular expressions) except for the string implementation which needed
ABI breakage to fix, and a few other things in the standard library
(including a O(1) std::list::size() function - see
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html).

To see what mozilla requires by way of gcc
see https://developer.mozilla.org/en-US/docs/Using_CXX_in_Mozilla_code
(latest releases require gcc-4.7).

The thing to do is to decide what the earliest version of gcc you want
gtkmm to compile with and test with that (and with gcc-5).  I would
suggest possibly gcc-4.6 or gcc-4.7.

The other point about the -std=c++0x, -std=c++11 and -std=c++14 flags
is that they do not change the ABI from the gcc-3.4 ABI to the gcc-5.1
ABI.  Only defining _GLIBCXX_USE_CXX11_ABI does that. Instead the flags
make some additional API available (or not available) and make some
minor other changes to the API.  Code compiled with the -std=c++11 flag
can link quite happily with a C++98/03 library such as gtkmm, provided
the same libstdc++ ABI is used for both.  The best way a distribution
can do that is to recompile all its C++ libraries with the same
_GLIBCXX_USE_CXX11_ABI setting and make that the default for the
compilation of user programs.

You might also want to read this, for an explanation about how Fedora
is dealing with gcc-5:
http://developerblog.redhat.com/2015/02/10/gcc-5-in-fedora/

Chris


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]