Using C++14 code in LLVM

Hi folks!

Six more months have come and gone, and maybe we could move LLVM to C++14 now?

The issues I picked out from the last discussion:

  1. Some folks want an official policy about compiler support before updating the standard version we use.
  2. Worries about which GCC version is available in which distro.
  3. Worries about MSVC.

Instead of rehashing the compiler per distro surveys from previous discussion, and instead of talking bootstrap, let me offer three data points:

What I get from this data: if your distro bundles a modern web browser, it already builds some C++14, somehow.

The LLVM community has been talking about this for a while now, and I’m not aware of a policy coming to light. I don’t think we need a policy given the above data. So how about we… just kinda… move LLVM to C++14?

Thanks!

JF

† the move to C++17 is very painful, but 14 has been working great in WebKit for quite a long time.

Once again, I’m totally down for this and think we should do it. I worry about windows, but …

Zach: How’s windows c++14 support looking?

-eric

Windows has never been the issue. Honestly, MSVC on Windows is “fully C++17 conformant” [1].

The issue has and always will be GCC. Given that a bump in any version of GCC has been (and will remain) difficult for some time, I propose that we skip C++14 and move to 17. We don’t want to have a multi-year disccusion about this again any time soon, and from what I gather, nobody has any more reservations about moving to C++17 than they do about moving to C++14. They only have reservations about moving to anything at all. So if we’re gonna move, we should go all the way.

Just my 2c.

[1] https://blogs.msdn.microsoft.com/vcblog/2018/05/07/announcing-msvc-conforms-to-the-c-standard/

Windows has never been the issue. Honestly, MSVC on Windows is “fully C++17 conformant” [1].

The issue has and always will be GCC. Given that a bump in any version of GCC has been (and will remain) difficult for some time, I propose that we skip C++14 and move to 17. We don’t want to have a multi-year disccusion about this again any time soon, and from what I gather, nobody has any more reservations about moving to C++17 than they do about moving to C++14. They only have reservations about moving to anything at all. So if we’re gonna move, we should go all the way.

WebKit’s move to C++17 hasn’t been super smooth because of GCC / libstdc++ issues in both GCC 6 and GCC 7. It’s all fixable, but given LLVM’s slow move out of C++11 I’d rather get C++14 now rather than a painful transition to C++17 that drags on as we discover issues.

If it’s the only thing we can agree then I’ll take it, but I just worry that 3 years from now we’re going to start another 3 year discussion, so that any actual move to C++17 would end up taking double the time.

Are the issues specific to C++17 additions to the standard library? What if you allow C++17 language features but not C++17 library features? I’m guessing this is too simple though and isn’t sufficient to avoid the problems (which I don’t know anything about, so you’ll have to enlighten me)?

Windows has never been the issue. Honestly, MSVC on Windows is “fully C++17 conformant” [1].

My worries were mostly “I don’t know” :slight_smile:

The easy way not to have a three year discussion is to not worry about it for another three years. :slight_smile:

So, I think we should take the easy things on the table and just move to C++14 in the near future. It’s just a matter of dropping support for building on distros that only have GCC <5 (aka Trusty, which is from 2014 itself). Let’s do that and call it a day.

If it’s the only thing we can agree then I’ll take it, but I just worry that 3 years from now we’re going to start another 3 year discussion, so that any actual move to C++17 would end up taking double the time.

Such a fatalistic view, let’s trust ourselves to be better next time :wink:
But seriously: we can learn from moving to C++14, and use what we’ve learned to move to C++17 faster next time. Also consider the code churn we’ll encounter as we fix incompatibilities with C++11 / C++14, drop unnecessary code, upgrade various uses, that will happen regardless of moving to C++17 and will take a little while to occur. There would be more of that type of churn if we went straight to C++17.

Are the issues specific to C++17 additions to the standard library? What if you allow C++17 language features but not C++17 library features? I’m guessing this is too simple though and isn’t sufficient to avoid the problems (which I don’t know anything about, so you’ll have to enlighten me)?

Mostly library so far, yes, but the GCC 6 support for C++17 language isn’t great either:

  • New auto rules for direct-list-initialization
  • static_assert with no message
  • typename in a template template parameter
  • Nested namespace definition
  • Attributes for namespaces and enumerators
  • u8 character literals
  • Allow constant evaluation for all non-type template arguments
  • Fold Expressions
  • Unary fold expressions and empty parameter packs
  • __has_include in preprocessor conditional
  • Differing begin and end types in range-based for\

The only thing that’s really nice are fold expressions, and I hope they’re not buggy in GCC 6.

Otherwise the list is missing a good amount for C++17 language features, and brings up the discussion of which GCC version is the minimum we mandate. I’d rather avoid that discussion. Let’s assume GCC 6, if we get 7 then great, but it doesn’t matter if we stick to C++14.

Consider me on board with the highest version we can come to an agreement on :slight_smile:

Well… Ubuntu 16.04 came with gcc 5, and deploying Visual Studio 2015 should be a done deal in Windows shops, which suggests moving to C++14 should be no problem.

It’s nice to see this week’s version of MSVC supports C++17 but deploying through corporate IT can take a while. (“This week’s version” because the blog post is dated Monday.)

–paulr

Hi,

IMHO, it’s a good idea to move to C++14 first.

What do you think about doing this by two phases:

Phase1: require GCC >= 5 but build in C++11 mode (this will give time to adapt build infrastructure to a new gcc)

Phase2: switch to C++14

Thanks,

Evgeny

Firefox's experience is that GCC 5 isn't going to cut it, especially
if you move to MSVC 2017, because people are going to be quickly
annoyed at the lack of relaxed constexpr function support, which is
GCC 6+.

You can get GCC 6 for Ubuntu 16.04; I have it on my machine, though
it's strangely not listed on packages.ubuntu.com for 16.04.

-Nathan

+1 to C++14.

Firefox's experience is that GCC 5 isn't going to cut it, especially
if you move to MSVC 2017, because people are going to be quickly
annoyed at the lack of relaxed constexpr function support, which is
GCC 6+.

Are you sure? I think you meant GCC 4.9 isn't going to cut it, ...
...
annoyed at the lack of relaxed constexpr function support, which is
GCC 5.

https://gcc.gnu.org/projects/cxx-status.html.

Relaxing requirements on constexpr functionsN36525__cpp_constexpr >= 201304

Roman.

My fault! You are correct; I got mixed up. I cannot speak much to
GCC 5, since we went from GCC 4.9 to GCC 6.

MSVC 2015 and its (lack of) relaxed constexpr function support was a
pain point. Some of that pain was because of external dependencies,
though, which is less of an issue for LLVM.

-Nathan

Hi,

IMHO, it’s a good idea to move to C++14 first.

What do you think about doing this by two phases:

Phase1: require GCC >= 5 but build in C++11 mode (this will give time to adapt build infrastructure to a new gcc)
Phase2: switch to C++14

Sounds reasonable, here’s a patch:
https://reviews.llvm.org/D46723

Last time this came up, there were a lot of people that were stuck on GCC 4.9 due to ABI reasons. I think forcing that upgrade is going to be the most disruptive part of this, and I think that will really need a decent amount of time. =[

Last time this came up, there were a lot of people that were stuck on GCC 4.9 due to ABI reasons. I think forcing that upgrade is going to be the most disruptive part of this, and I think that will really need a decent amount of time. =[

Those people don’t build a browser? Because if they build any one of the 3 major ones they’re not using GCC 4.9 AFAICT.

“a decent amount of time” is very vague though, and is a good way of stalling forward progress. How much time? And when can we start the clock?

Last time this came up, there were a lot of people that were stuck on GCC 4.9 due to ABI reasons. I think forcing that upgrade is going to be the most disruptive part of this, and I think that will really need a decent amount of time. =[

“a decent amount of time” is very vague though, and is a good way of stalling forward progress.

Let’s try to avoid implying bad intent. =/

How much time? And when can we start the clock?

I don’t know. I can only speak to the use cases I’m aware of and care about. Whoever wants to drive this change needs to get a lot more feedback than just from me (IMO) about different users and whether a particular schedule will work.

And I already mentioned my schedule, but maybe not explicitly enough: the primary platform I care about is planning to be off of libstdc++4.9 (the tall poll of the tent for us) by the end of 2018. So it seems like right after the branch in January 2019 would be fine for us to bump things up. Anything earlier than this will be somewhere between extremely hard to infeasible for us.

At that point, we could probably go for C++17 as easily as C++14.

But maybe my group is unique in that timing so we should really ask others for input as well.

Last time this came up, there were a lot of people that were stuck on GCC 4.9 due to ABI reasons. I think forcing that upgrade is going to be the most disruptive part of this, and I think that will really need a decent amount of time. =[

Those people don’t build a browser? Because if they build any one of the 3 major ones they’re not using GCC 4.9 AFAICT.

Probably not anywhere near the “trunk” of any of these browsers.

But while I know that browsers are pretty big, they are not primarily libraries. So their users very often don’t need to compile them.

LLVM on the other hand is a library primarily, and so users of LLVM actually rely on being able to compile LLVM.

LLVM also has users on embedded platforms and other environments where browsers may not be prominent.

Anyways, my point is just that the browsers moving to C++14 is a good sign, but I don’t think it is sufficient to say that we can just flip the switch.

-Chandler