Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to C++20 #27

Closed
wanderingbort opened this issue Feb 24, 2023 · 15 comments
Closed

Upgrade to C++20 #27

wanderingbort opened this issue Feb 24, 2023 · 15 comments
Labels
decision 🤔 An internal decision to made for eng team

Comments

@wanderingbort
Copy link
Contributor

[Transferred from legacy agenda on behalf of @greg7mdp and @ScottBailey]

(Should we) consider switching to -std=c++20 for leap and appbase? (@greg7mdp)

It’s 2023, can we have FULL C++20 support? If now isn’t the right time, when is? (@ScottBailey)

@wanderingbort wanderingbort added the decision 🤔 An internal decision to made for eng team label Feb 24, 2023
@wanderingbort
Copy link
Contributor Author

[Transferred from legacy agenda on behalf of @ericpassmore ]

Hmm I'm running /lib32/libstdc++.so.6 today. What version should I be targeting for leap build from main?

@wanderingbort
Copy link
Contributor Author

[Transferred from legacy agenda on behalf of @spoonincode ]

neither gcc nor clang have released FULL c++20 support

@ScottBailey
Copy link

Maybe it is more appropriate to talk about the C++20 features we'd like to use, Matt is correct, full support for C++20 doesn't exist yet.

I think this list might be fairly up to date.

I'd like to use std::span and 3 way comparison operator (<=>).

@spoonincode
Copy link
Member

With ubuntu 18 being dropped, I def think we should go ahead and move up to 20 (well, maybe until after the release is cut). But with no compiler fully supporting 20, we need to decide on the minimum compiler we'll target. gcc10 seems reasonable as at least there is a ubuntu20 package and it has most of the good stuff.

@greg7mdp
Copy link

greg7mdp commented Feb 25, 2023

Yes, it would be great to move to C++20, and indeed most of the good c++20 stuff is in gcc 10.

Newer compilers can be installed if we add the following repository:

sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test

I have been building with g++-12 for a while.

Also, it is very easy to install any clang version with:

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh <version number> all

@ScottBailey
Copy link

Yes, it would be great to move to C++20, and indeed most of the good c++20 stuff is in gcc 10.

Newer compilers can be installed if we add the following repository:

I am a little uncomfortable asking users to install packages outside their basic distro. BUT I'm also interested in using newer tools. Ubuntu 20 is near 3 years old, so I suppose it's a reasonable trade off to ask a user to upgrade either their compiler or OS.

It would be nice to target g++-12 as our "supported" complier.

@wanderingbort
Copy link
Contributor Author

2.28 meeting notes:

Open Questions:

  • does enabling c++20 in compilers have any effect on consensus (even with using the c++20 features)?
  • how do we handle patches and backports? (policy needed?)
  • what c++20 features are actually supported in our compilers?

Decisions to vote on:

  • After 4.0? ✔️
  • dependent on "chicken test" ? ❔

@greg7mdp
Copy link

greg7mdp commented Mar 28, 2023

So we are now After 4.0.
Decision was made to add the -std=c++20 switch.
I believe gcc-9 and gcc-10 are available by default on ubuntu20. So I think it would be reasonable to specify gcc-10 as the minimum version supported.

install gcc-10 on ubuntu 20.04.1

apt update -y
apt upgrade -y
apt install -y build-essential
apt install -y gcc-10 g++-10 cpp-10

@spoonincode
Copy link
Member

The way I read the 2.28 notes above was that the vote was only to defer this decision until post 4.0 branch. There appears to be outstanding questions still? For example

dependent on "chicken test" ? ❔

@greg7mdp
Copy link

Isn't main now post 4.0?

dependent on "chicken test" ?

Apologies, I don't know what that means.

@kj4ezj
Copy link
Contributor

kj4ezj commented Mar 28, 2023

We talked about this briefly on the engineering weekly meeting video call, but the "chickens test" is a colloquialism for a test that takes the entire chain, breaks it down into segments that were collected with a known-good version of code, replays those chain segments with a piece of software under test, verifies that the replayed chain segments link correctly, and then passes or fails based on whether the chain state is equivalent with the software under test and the known-good software. This test is very good at catching consensus deviations where the software under test deviates from the behavior of the known-good software in ways that we do not have unit or integration tests for. People do weird things on-chain.

The colloquialism for the test comes from the 🐓 🐓 🐓 emoji in the test name.

@wanderingbort
Copy link
Contributor Author

Upon further reflection the group is unconvinced that compiler flags would be a material risk for the semantics and therefore chicken testing shouldn't be considered a pre-requisite.

Open Question

  • for product: are BPs largely using pinned builds? May be more of a concern for compilers/boost changes rather than c++ std.
  • Confidence over consensus semantics, is the "chicken test" enough?
  • Does any undefined behavior become defined in c++20?

@greg7mdp
Copy link

We talked about this briefly on the engineering weekly meeting video call, but the "chickens test" is a colloquialism

Thanks Zach, this seems like an excellent test indeed!

@greg7mdp
Copy link

the "chickens test" is a colloquialism for a test that takes the entire chain, breaks it down into segments ...

I'm glad it isn't this chicken test.

@greg7mdp
Copy link

This Leap Issue was created to track the C++20 upgrade effort. Please direct further comments there. Closing this discussion issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
decision 🤔 An internal decision to made for eng team
Projects
None yet
Development

No branches or pull requests

5 participants