WL#8896: Enable use of C++11 in MySQL server
Affects: Server-8.0 — Status: Complete — Priority: Medium
The aim of this worklog is to enable the use of C++11 in the 8.0 version of MySQL server. C++11 has a number of new features, especially related to concurrency, that are of interest. For arguments of why using standard C++ library features is a good idea. GCC support for C++11: https://gcc.gnu.org/projects/cxx0x.html Clang support for C++11: http://clang.llvm.org/cxx_status.html Visual Studio support for C++11: https://msdn.microsoft.com/en-us/library/hh567368.aspx Solaris Studio support for C++11: https://docs.oracle.com/cd/E37069_01/html/E37071/gndfg.html Here is what you need to know: 1) New compiler version requirements ==================================== After the WL push, the minimum version requirements of different compilers will be raised as follows: GCC: 4.8 or above Clang: 3.4 or above (XCode 7 on OS X) Solaris Studio: 12.4 or above (Solaris client build only) This is done to get a good level of C++11 support across all supported platforms. Minimum version of Visual Studio is still at 2013, but will be raised to 2015 soon. If you use older compilers than this, please upgrade ASAP. 2) Trunk Pushbuild trees will have to be updated ================================================ Once this WL is pushed, existing trunk-based pushbuild trees will have to be reconfigured due to changes to supported platforms. mysql-trunk, daily-trunk and weekly-trunk will be updated by RE right away. Other trunk branches will be updated by RE in the following days. Expect some red columns until all trunk branches have been synced. 3) Which C++11 feature can I use? ================================= The supported C++11 features for our compilers are documented here: https://gcc.gnu.org/projects/cxx0x.html http://clang.llvm.org/cxx_status.html https://msdn.microsoft.com/en-us/library/hh567368.aspx https://docs.oracle.com/cd/E37069_01/html/E37071/gndfg.html GCC and Clang claim full support. We know from our testing that there are some small holes (e.g. not all type traits are implemented in GCC 4.8), but I don't expect this to be an issue in practice. Visual Studio 2013 misses a few important things (e.g. constexpr), but this is fixed in Visual Studio 2015. Solaris Studio does not document C++11 support in detail. Note that Solaris Studio in C++11 mode uses the g++ 4.8.2 runtime library, so C++11 library support is as for GCC.
NF-1: No changes in behavior or performance regressions should be introduced by this WL.
Steps needed to enable C++11 ============================ Development changes required: - Write patch which turns on C++11 support when building and fixes new compilation errors [DONE] - Write patch which uses C++11 features (including library) for testing purposes [DONE] - Fix build issues on Solaris (OOM compiling GIS) [DONE] - Figure out how the client library should be handled. Solaris Studio 12.4 supports C++11, so this should not be a problem [DONE] Packaging changes required: - Adapt RPMS spec to use non-standard GCC location on EL6 [DONE] - Remove platforms (EL5) which becomes unsupported in RPMS spec files [DONE] Release engineering changes required: - Update pushbuild based on new supported platforms list. Includes using Software Collections for RH6/EL6. [DONE] - Move Generic Linux builds to EL6. [DONE] Testing required: - Identify problematic platforms from the current list of 5.7 supported platforms [DONE - EL5+Ubuntu 12.04] - Test using Software Collections for EL6 to get new enough GCC [DONE] - Verify mysql_config, pkg-config and client library still works for non C++11 applications [DONE] - Check than no new runtime dependencies are introduced [DONE] Documentation required: - Update "Installing MySQL from Source" (2.8) in ref. manual The issue of GCC C++ ABI version ================================ Currently the server hardcodes the use of version 2 of the GCC C++ ABI. This is done in cmake/build_configurations/compiler_options.cmake GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html The problem is that this version is quite old and that newer versions contains several bug fixes that are relevant for C++11. Two alternative approaches for moving to a newer version: 1) Hardcode the newest version of the GCC C++ ABI that is supported by the oldest version of GCC we will be using. Currently this looks like 4.8 => ver 7. + Similar to the current approach. - Ties us to version 7 even if we move to newer compilers. - What if Linux distros want to use an older/newer version? 2) Remove hardcoding of ABI version from server sources. Leave it up to Linux distros to decide which version to use. For our own packages, use whatever is the default version for the given distro. + Linux distros will be more free to use the version they want. + Easier to start using newer versions. + In line with other applications on that platform - Different builds can use different versions. Implications for test coverage? Based on the above +/- points, we have chosen approach 2)
The patch for this WL should: - Turn on the -std=c++11 compiler flag for G++, Clang++ and Solaris Studio - Remove -std=c++11 from the mysql_config output except for Solaris Studio where it is needed to get the correct C++ libraries. - Add "-lstdc++ -lgcc_s -lCrunG3" to mysql_config output when using Solaris Studio as required by the Solaris Studio documentation. - Remove all usage and references to stlport for Solaris. With C++11 Solaris Studio will automatically use the g++ runtime library. - Update compiler version checks to the following minium versions: GCC 4.8, Clang 3.4, Solaris Studio 12.4. As per 5.8 platform draft linked in HLD. - Remove preparatory C++11 compiler warnings (-Wc++11-compat-reserved-user-defined-literal and -Wc++11-extra-semi) - Downgrade new compilation errors about deprecated features to warnings (e.g. std::auto_ptr). It should be up to individual teams to fix this later. - Add an unit test using new C++11 library features. - Add an UDF using new C++11 library features. - Remove explicit setting of GCC ABI version (see above)
Copyright (c) 2000, 2018, Oracle Corporation and/or its affiliates. All rights reserved.