Hi,
(if you don't care about C++11, you can stop reading now.)
most of our linux bots are on precise now, which was what we believed is what we need for switching to C++11. I looked at this a bit, here's a status update.
Summary:
How do we want to proceed with C++11 support in Chromium?
Enabling C++11 support in our toolchain still requires significant work in order to support all platforms. The toolchain is also less mature and waiting may give us more options to resolve certain quirks (namely by selective disabling C++11 warnings that are limited use).
There are 3 possible paths forward:
Full speed ahead, with gcc 4.6! Work around issues and and turn on C++11 ASAP.
Wait for gcc 4.8. Allows selective disabling of C+111 warnings.
Drop gcc support, require clang. Also allows selective disabling of some C++11 warnings.
We will eventually have to enable C++11. The question is how much do we want the new features, and when do we put the effort into it making things work.
Comments? Opinions? Flames? Please respond to this thread.
Lovingly yours with cinnamon, sugar, and a cherry on top,
Nico (with copy editing help from Albert)
=== Very detailed discussion of current status below. ===
Background: What is C++11?
C++11 is the current revision of the C++ language standard. Enabling it in a code base requires
Compiler support for new language features (eg., auto, rvalue references, etc)
Updated Standard Library to support new features and language strictness.
There were a few threads about C++11 on chromium-dev [1]. The conclusion was that we’d want to wait until all our linux bots are on Ubuntu Precise, which ships with gcc 4.6. This has happened by now, so it’s time to look at things again.
How many Compilers and Standard Libraries do we really have?
Compilers
windows: msvs2010, msvs2012
mac: clang
linux: gcc4.6, clang
chromeos: gcc4.6 (?)
android: gcc4.6, clang
iOS: Xcode’s clang
Standard Libraries:
windows: msvs2010, msvs2012
mac: libstdc++ 4.2 (with clang)
linux: libstdc++4.6 (with both gcc4.6 and clang)
chromeos: libstdc++ 4.6 (?)
android: stlport
iOS: libc++ (?)
You’re kidding right?
no.
Standard Library support
Though most compilers by now support at least some C++11 features, several of the standard libraries do not.
Mac: libc++ is not available on OS X 10.6. We are stuck with libstdc++ 4.2 which does not have C++11 features.
Android: stlport does not have C++11 features. Slow progress is being made towards porting libc++ to android, but there is no timeframe.
Compiler support: MSVS
MSVS’s compiler just builds “C++” and support for newer language features is added over releases.
Both msvs 2010 and msvs2012 have support for basic C++11 language features.
Compiler support: Clang
All clang builds current enable C++11 support is enabled via the --std=gnu++11 flag (which is c++11 plus gnu extensions).
Clang is special because we update it more frequently. We track clang trunk and update our clang binary every ~2 weeks. All platforms except iOS use the same revision. This lets us deploy toolchain fixes much faster than we can with other compilers.
Clang is used for the production build on Mac; on other platforms it is only used by developers.
Compiler support: Gcc
Gcc also enables C++11 support via the --std flag. However, currently, we do NOT enable it.
Enabling --std=gnu++11 on gcc currently has a 4 large adverse effects.
Compile time slows down ~20%
A few cases where C++11-incompatibility with C++98 bite us
Toolchain immaturity seems to be a larger issue
Still gaining experience with C++11 apps
--Compile time slows down ~20% [2]--
This is mostly caused by the standard library including more files increasing parsing time in C++11 mode.
Clang suffers from this problem as well on platforms with libstdc++ >= 4.6 and libc++.
MSVS2012 also is slower than MSVS2010 for this reason.
There is not much we can do about this.
--We hit a few cases where C++11-incompatibility with C++98 bytes us.--
In particular, these two issues cause problems:
Narrowing conversions
User defined literals.
Details below.
Narrowing conversions:
The following lines are errors in C++11 but valid in C++98:
const char kData[] = { 0x05, 0xff, 0xa3 };
struct CGPoint { float x, y; } p;
struct Point { int x, y; } pi = { p.x, p.y };
Details here: http://www.stroustrup.com/C++11FAQ.html#narrowing
While this looks like a useful feature, in practice it has very little impact. In Chromium 5/5 flagged issues were false positives.
MSVS likely won’t enable this warning for a while to preserve backwards compatibility. Clang can selectively disable this warning. However gcc 4.6, and 4.7 treat this as a hard error; it is only a disableable warning as of gcc 4.8.
Fixing errors of this type can be annoying too. For example, CLD has a 700-line initializer, and gcc prints the diagnostic at the initializer's closing '}'.
If we enable C++11 while still using gcc-4.6, we will need to change a bunch of code to be less readable in order to avoid the error.
User-defined literals
C++11 allows you to write some code to have literals that look like `43_chromium`. You can then code what the literal means.
This sadly conflicts with C99’s inttypes.h header, which is offers predefined macros for portable printing of types like size_t:
printf("xyz: %"PRIuS, size); // PRIuS is from inttypes.h
In C++11, “xyz: %”PRIuS is now a user-defined literal. “xyz: %” is the literal and PRIuS the UD-suffix.
This is most notably used in NaCl. The fix is to insert a space as follows:
printf("xyz: %" PRIuS, size); // PRIuS is from inttypes.h
Similar to Narrowing Conversions, MSVS likely won’t support this for a whille, clang allows you to disable it.
In gcc 4.6, this feature is not supported so it is not a problem. However, in gcc-4.7 it becomes a hard error, and in gcc 4.8 it gets degraded back to a disableable warning.
If we turn on C++11 with gcc 4.6, our code will break in gcc 4.7 and we will have to make a bunch of code less readable.
-- The toolchain is immature--
gcc 4.6.0 was released March 25, 2011. C++11 was approved 12 August 2011. The C++11 standard is newer than gcc 4.6, and some things are just buggy.
Example: The compiler-generated move constructor for bitfield enums is not valid, and gcc prints a hard to understand compile-time error about code it itself generated internally (http://pastie.org/8125050).
This happens in angle_dx11. This is again resolved in gcc4.8.
If we turn on C++11 prior to gcc-4.8, we’ll have to change (small amounts of) code to work around toolchain issues.
-- There’s not a lot of experience with C++11 apps--
gcc 4.7.0 and gcc 4.7.1 contained a (mostly accidental) ABI change that made it impossible for so libraries built in C++11 mode to function with other so libraries built in C++98 mode:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49561
System libraries on Linux are usually built in C++98, so if we move Chromium to C++11 we have to make sure to never ship a binary that was built with gcc 4.7.0 or gcc 4.7.1. There might be other issues like this.
I don’t think this is an issue on Android, since that loads no system so libs written in C++ into your app (?).
I’m unsure about ChromeOS. If there are problems, we could in theory make sure the whole system is built in C++11 mode, but that might require some effort to do.
Conclusion
*sigh*
Footnotes
[1]
Apr 23, 2012 "what are the blockers for starting to use C++11" https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/chromium-dev/Pzk7jsrXKVQ
Summary: language vs stdlib; |"asdf"NACL_PRId64"fdsa"|
ABI issues on linux: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49561 (gcc decided on abi stability) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45093 (someone says "won't be abi stable", but that's older than the first bug)
piman doesn't like rval refs
July 11, 2012 "[chromium-dev] C++11 support" https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/6BsXIAs5KIA
Summary: nothing new (android stlport won't get c++11 features)
Oct 12, 2012 "[chromium-dev] C++11 support in Chromium" https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/Ph_YKV-rWFI/AuVa_Ibwv04J
(forked from "[chromium-dev] ANN: VS2008 deprecation happening now")
Summary: Want to use static_assert, override, LL and ULL; auto, for-each, >> in templates
[2]
building chrome on linux in release (components build):
clang: 19m
clang/c++11: 24m10s
(much later revision, from 7/7/13, with gcc4.6)
gcc: 20m42s
gcc/c++11: 25m22s
(gcc4.8)
gcc: 22m4s
gcc/c++11: 28m47s
Hi,
(if you don't care about C++11, you can stop reading now.)
most of our linux bots are on precise now, which was what we believed is what we need for switching to C++11. I looked at this a bit, here's a status update.
Summary:
How do we want to proceed with C++11 support in Chromium?
Enabling C++11 support in our toolchain still requires significant work in order to support all platforms. The toolchain is also less mature and waiting may give us more options to resolve certain quirks (namely by selective disabling C++11 warnings that are limited use).
There are 3 possible paths forward:
Full speed ahead, with gcc 4.6! Work around issues and and turn on C++11 ASAP.
Wait for gcc 4.8. Allows selective disabling of C+111 warnings.
Drop gcc support, require clang. Also allows selective disabling of some C++11 warnings.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
There were a few threads about C++11 on chromium-dev [1]. The conclusion was that we’d want to wait until all our linux bots are on Ubuntu Precise, which ships with gcc 4.6. This has happened by now, so it’s time to look at things again.
Clang is special because we update it more frequently. We track clang trunk and update our clang binary every ~2 weeks. All platforms except iOS use the same revision. This lets us deploy toolchain fixes much faster than we can with other compilers.
MSVS likely won’t enable this warning for a while to preserve backwards compatibility. Clang can selectively disable this warning. However gcc 4.6, and 4.7 treat this as a hard error; it is only a disableable warning as of gcc 4.8.
Fixing errors of this type can be annoying too. For example, CLD has a 700-line initializer, and gcc prints the diagnostic at the initializer's closing '}'.
If we enable C++11 while still using gcc-4.6, we will need to change a bunch of code to be less readable in order to avoid the error.
-- The toolchain is immature--
gcc 4.6.0 was released March 25, 2011. C++11 was approved 12 August 2011. The C++11 standard is newer than gcc 4.6, and some things are just buggy.
Example: The compiler-generated move constructor for bitfield enums is not valid, and gcc prints a hard to understand compile-time error about code it itself generated internally (http://pastie.org/8125050).
This happens in angle_dx11. This is again resolved in gcc4.8.
If we turn on C++11 prior to gcc-4.8, we’ll have to change (small amounts of) code to work around toolchain issues.
-- There’s not a lot of experience with C++11 apps--
gcc 4.7.0 and gcc 4.7.1 contained a (mostly accidental) ABI change that made it impossible for so libraries built in C++11 mode to function with other so libraries built in C++98 mode:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49561
System libraries on Linux are usually built in C++98, so if we move Chromium to C++11 we have to make sure to never ship a binary that was built with gcc 4.7.0 or gcc 4.7.1. There might be other issues like this.
I don’t think this is an issue on Android, since that loads no system so libs written in C++ into your app (?).
I don’t think this is an issue on Android, since that loads no system so libs written in C++ into your app (?).
This is most notably used in NaCl. The fix is to insert a space as follows:
printf("xyz: %" PRIuS, size); // PRIuS is from inttypes.h
[...]
If we turn on C++11 with gcc 4.6, our code will break in gcc 4.7 and we will have to make a bunch of code less readable.
How many Compilers and Standard Libraries do we really have?
Compilers
windows: msvs2010, msvs2012
mac: clang
linux: gcc4.6, clang
chromeos: gcc4.6 (?)
android: gcc4.6, clang
iOS: Xcode’s clang
How many Compilers and Standard Libraries do we really have?
Compilers
windows: msvs2010, msvs2012
mac: clang
linux: gcc4.6, clang
chromeos: gcc4.6 (?)
android: gcc4.6, clang
iOS: Xcode’s clang
Note that portions of the code are also built with the NaCl toolchain. It's based on GCC 4.3 :-(.
That appears to eliminate some niceties like auto: http://gcc.gnu.org/projects/cxx0x.html.
In particular, we build parts of base, ipc, gpu, and ppapi with the NaCl toolchain. It might be possible to transition to using the PNaCl LLVM toolchain, with clang v3.3.
I haven't heard anyone argue for using C++11 with gcc 4.6 so far.Re Stuart & Peter's "let's just fix literals": Sounds good, removes one item. Doing this at https://crbug.com/263960Re khim> This will be change of similar magnitude.
Do you mean it's similarly complicated to a) upgrade nacl gcc to 4.8 b) let nacl use the pnacl toolchain?
If so, the latter sounds like there'd be one compiler less, which is probably good?
In any case, I guess the NaCl compilers will be updated to work with whatever we happen to decide is best.
Re "gcc is faster on arm": Possible, but iOS uses clang on arm, so it's probably not terrible.
Re Pawel> I think this ability to update quickly (and possibly have custom patches at least for a while, right?) is very important.We don't have downstream patches in "our" clang binaries.
Re Adam> How realistic is option (3)? Is there anything standing in our way of dropping gcc support in favor of clang?Not sure. On Linux, it should be doable. On ChromeOS, I think we rely on profile-guided optimization quite a bit, which I believe clang can't do yet. Android apparently sees some bugs with clang (but even if those are compiler bugs and not our bugs, we could fix them in the compiler and then update our compiler on a time span of weeks).
Paweł
On Thu, Jul 25, 2013 at 1:23 AM, Nico Weber <tha...@chromium.org> wrote:
Re khim> This will be change of similar magnitude.
Do you mean it's similarly complicated to a) upgrade nacl gcc to 4.8 b) let nacl use the pnacl toolchain?Yes. GCC and LLVM currently have different native ABIs (GCC uses CPU-native ABI and LLVM uses generic ABI suitable for cross-platform .pexe file) and GCC supports both while LLVM only supports one of these. To build Chrome with LLVM we'll need to add support for cross-platform ABIs to LLVM. It's not too complicated (this support is in native LLVM, it's just not used in PNaCl), mostly we'll just need to add test coverage, but then upgrade for nacl gcc is of similar complexity (and, again, it's mostly testing).
On Thu, Jul 25, 2013 at 1:23 AM, Nico Weber <tha...@chromium.org> wrote:
I haven't heard anyone argue for using C++11 with gcc 4.6 so far.Re Stuart & Peter's "let's just fix literals": Sounds good, removes one item. Doing this at https://crbug.com/263960Re khim> This will be change of similar magnitude.
Do you mean it's similarly complicated to a) upgrade nacl gcc to 4.8 b) let nacl use the pnacl toolchain?Yes. GCC and LLVM currently have different native ABIs (GCC uses CPU-native ABI and LLVM uses generic ABI suitable for cross-platform .pexe file) and GCC supports both while LLVM only supports one of these. To build Chrome with LLVM we'll need to add support for cross-platform ABIs to LLVM. It's not too complicated (this support is in native LLVM, it's just not used in PNaCl), mostly we'll just need to add test coverage, but then upgrade for nacl gcc is of similar complexity (and, again, it's mostly testing).If so, the latter sounds like there'd be one compiler less, which is probably good?No, GCC will still be around because you still can not compile GLibC with clang.
On Wed, Jul 24, 2013 at 4:13 PM, Victor Khimenko <kh...@chromium.org> wrote:
On Thu, Jul 25, 2013 at 1:23 AM, Nico Weber <tha...@chromium.org> wrote:
I haven't heard anyone argue for using C++11 with gcc 4.6 so far.Re Stuart & Peter's "let's just fix literals": Sounds good, removes one item. Doing this at https://crbug.com/263960Re khim> This will be change of similar magnitude.
Do you mean it's similarly complicated to a) upgrade nacl gcc to 4.8 b) let nacl use the pnacl toolchain?Yes. GCC and LLVM currently have different native ABIs (GCC uses CPU-native ABI and LLVM uses generic ABI suitable for cross-platform .pexe file) and GCC supports both while LLVM only supports one of these. To build Chrome with LLVM we'll need to add support for cross-platform ABIs to LLVM. It's not too complicated (this support is in native LLVM, it's just not used in PNaCl), mostly we'll just need to add test coverage, but then upgrade for nacl gcc is of similar complexity (and, again, it's mostly testing).If so, the latter sounds like there'd be one compiler less, which is probably good?No, GCC will still be around because you still can not compile GLibC with clang.The IRT uses newlib, and that's what links in chrome base/, ipc/, ppapi/, and gpu/ code. I think the only portion of code that would still need to be built with GLibC in the chrome tree would be tests. Those are already a little "special", and we could leave out C++11 support for those for a while, I think.
That said, I'm concerned about the performance (mostly compile-time) that we'd lose by using the PNaCl toolchain to build any significant part of chrome. If it was a straight LLVM-based NaCl toolchain, that would probably work great for chrome. But I suspect going to .pexe first and then through the translator would be annoyingly slow.
How many Compilers and Standard Libraries do we really have?
Compilers
windows: msvs2010, msvs2012
mac: clang
linux: gcc4.6, clang
chromeos: gcc4.6 (?)
-- There’s not a lot of experience with C++11 apps--
gcc 4.7.0 and gcc 4.7.1 contained a (mostly accidental) ABI change that made it impossible for so libraries built in C++11 mode to function with other so libraries built in C++98 mode:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49561
System libraries on Linux are usually built in C++98, so if we move Chromium to C++11 we have to make sure to never ship a binary that was built with gcc 4.7.0 or gcc 4.7.1. There might be other issues like this.I don’t think this is an issue on Android, since that loads no system so libs written in C++ into your app (?).
I’m unsure about ChromeOS. If there are problems, we could in theory make sure the whole system is built in C++11 mode, but that might require some effort to do.
On Tue, Jul 23, 2013 at 7:52 PM, Nico Weber <tha...@chromium.org> wrote:
How many Compilers and Standard Libraries do we really have?
Compilers
windows: msvs2010, msvs2012
mac: clang
linux: gcc4.6, clang
chromeos: gcc4.6 (?)
CrOS has been on gcc-4.7 since Nov 2012, so we've been shipping since at least R25 with it. we've hit a few issues (including narrowing warnings you documented later on here) ahead of the Chromium tree due to us moving ahead of the version most Linux devs use.we have clang available, but we only use it for debug/diagnostic builds (like ASAN). and iirc, the cross-compiling behavior is ... buggy. it'll take some time to sort that all out.
-- There’s not a lot of experience with C++11 apps--
gcc 4.7.0 and gcc 4.7.1 contained a (mostly accidental) ABI change that made it impossible for so libraries built in C++11 mode to function with other so libraries built in C++98 mode:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49561
System libraries on Linux are usually built in C++98, so if we move Chromium to C++11 we have to make sure to never ship a binary that was built with gcc 4.7.0 or gcc 4.7.1. There might be other issues like this.I don’t think this is an issue on Android, since that loads no system so libs written in C++ into your app (?).
I’m unsure about ChromeOS. If there are problems, we could in theory make sure the whole system is built in C++11 mode, but that might require some effort to do.
every CrOS release is built from source, so that should be feasible for us to do if needed-mike
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
"I'm planning to switch linux to clang over this weekend to collect some perf data."Any news/updates?