You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There were some discussion around upgrading to C++17. It seems to be able to give us library and language features that will simplify future code. For example, for library features, our current optional.h is just a wrapper around boost::optional, and can be replaced with std::optional. Other library features that might be useful include (non-exhaustively): std::variant, the file system library, and std::shared_mutex.@elichai has kindly provided a table summarizing features useful for Bitcoin Core here: #16684 (comment).
I want to apologize for misspeaking about C++17 requiring GCC8, that is untrue, and I believe all of the features we would want will be covered by GCC7, and some by GCC6.
Reacted by Elichai Turkel, practicalswift (Thomas J), James, Jon Layton, l2a5b1, Mara van der Laan, nijynot, Raul Santos, Matheus C. França and Felipe Soares
Reacted by Elichai Turkel, Jon Layton, Mara van der Laan and Raul Santos
Another reason we might want to upgrade:
very powerful const expressions. both c++14 and 17 made constexpr way more powerfull.
such that we could start making a lot of functions constexpr which might maybe result in some performance increase (for functions that might be able to be evaluated at compile time)
@sanjaykdragon It's not that easy, as we need to remain compatible with various stable Linux distributions, which don't update their C++ compilers that frequently (or at all, after release of a particular distro version).
C++20 does not exist yet, so that seems entirely out of scope.
@sanjaykdragon It's not that easy, as we need to remain compatible with various stable Linux distributions, which don't update their C++ compilers that frequently (or at all, after release of a particular distro version).
C++20 does not exist yet, so that seems entirely out of scope.
Are we just waiting for linux distributions to become compatible with C++17 for a migration?
Of the 13 build jobs we have in Travis it looks like three build jobs use compilers without C++17 support: CentOS 7, Ubuntu 16.04 (Xenial) and macOS Sierra (10.12). Sounds correct? :)
I think our recommendation should be to try to avoidstd::string_view in the general case, and use it only in places where it is both a.) needed for performance reasons (as demonstrated by benchmarks), and b.) guaranteed to be safe :)
@MarcoFalke How old do the patched glibc version need to be before it can be assumed present? Glibc 2.30 which contains fixes for bugs 23861 and 23844 was released in August 2019, and backports are available. The bugs only affect users running old distros without updating.
@fanquake Yes, but it received a backported fix as shown in the Launchpad link. All users have -updates enabled by default, so the only way you could miss it is if you didn't run apt upgrade since November. Does Core need to cater to that tiny minority that runs an LTS release but does not keep it updated? You can only use Bitcoin if you are internet-connected anyway, so what is the rationale for being internet-connected, but keeping your system buggy and vulnerable (other fixes could be more severe)?
Activity
practicalswift commentedon Aug 22, 2019
Some C++14 features worth mentioning as well:
std::make_unique, more expressiveconstexprfunctions allowed, return type deduction (auto foo() { … }),[[deprecated]], binary literals (0b10101110) and polymorphic lambdas ([](auto foo) { … }).elichai commentedon Aug 22, 2019
A table on features in C++14/17 which I think would be very useful (feel free to comment if you disagree or think other stuff should be added)
elichai commentedon Oct 3, 2019
Another reason we might want to upgrade:
very powerful const expressions. both c++14 and 17 made
constexprway more powerfull.such that we could start making a lot of functions
constexprwhich might maybe result in some performance increase (for functions that might be able to be evaluated at compile time)maflcko commentedon Oct 3, 2019
Is C++17 supported on Ubuntu Xenial, Debian 9, and the *BSD operating systems?
ysangkok commentedon Oct 3, 2019
Debian 9 ships GCC 6.3 according to the development packages listing. GCC 6 is listed as supporting some features of C++17 experimentally.
Ubuntu Xenial ships with a default GCC 5.3, which is even older. A PPA offers newer GCC versions: ~ubuntu-toolchain-r
laanwj commentedon Dec 9, 2019
Added 0.21 milestone optimistically
sanjaykdragon commentedon Jan 3, 2020
I agree with moving to C++17, but when do we plan to move to the soon coming C++20?
sipa commentedon Jan 3, 2020
@sanjaykdragon It's not that easy, as we need to remain compatible with various stable Linux distributions, which don't update their C++ compilers that frequently (or at all, after release of a particular distro version).
C++20 does not exist yet, so that seems entirely out of scope.
sanjaykdragon commentedon Jan 3, 2020
Are we just waiting for linux distributions to become compatible with C++17 for a migration?
practicalswift commentedon Jan 9, 2020
Of the 13 build jobs we have in Travis it looks like three build jobs use compilers without C++17 support: CentOS 7, Ubuntu 16.04 (Xenial) and macOS Sierra (10.12). Sounds correct? :)
laanwj commentedon Jan 13, 2020
Yes, that's the main factor holding it up.
sanjaykdragon commentedon Jan 30, 2020
Just a comment / improvement to make when we move to C++17:
use std::string_view more.
practicalswift commentedon Jan 30, 2020
@sanjaykdragon
std::string_viewhas really sharp edges with regards to life-time -- some would even claim it encourages use-after-free bugs.I think our recommendation should be to try to avoid
std::string_viewin the general case, and use it only in places where it is both a.) needed for performance reasons (as demonstrated by benchmarks), and b.) guaranteed to be safe :)22 remaining items
ysangkok commentedon Nov 12, 2020
@theuni The bugzilla link you posted is for bug 23861. But the Ubuntu bug you posted links 23844 (a different bug number). I am letting you know since I found it confusing. @MarcoFalke Bug 23844 was deferred from 2.29 according to release notes.
ilyapopov commentedon Nov 12, 2020
@theuni This Ubuntu bug is about Ubuntu 18.04 Bionic.
Newer versions of Ubuntu, such as 20.04 LTS and 20.10 already have had the fixed version from the beginning.
Merge #20413: build: Require C++17 compiler
maflcko commentedon Nov 20, 2020
Closing this for now. If discussions about specific features are needed, they should go to #20419 or #19183 or whatever pull request proposes them.
maflcko commentedon Nov 23, 2020
std::fs discussion here: #20460
Merge #20419: build: set minimum supported macOS to 10.14
ysangkok commentedon Jan 15, 2021
@MarcoFalke How old do the patched glibc version need to be before it can be assumed present? Glibc 2.30 which contains fixes for bugs 23861 and 23844 was released in August 2019, and backports are available. The bugs only affect users running old distros without updating.
fanquake commentedon Jan 15, 2021
Ubuntu Bionic (18.04LTS) ships with glibc 2.27 and will remain supported until April 2023.
ysangkok commentedon Jan 15, 2021
@fanquake Yes, but it received a backported fix as shown in the Launchpad link. All users have
-updatesenabled by default, so the only way you could miss it is if you didn't runapt upgradesince November. Does Core need to cater to that tiny minority that runs an LTS release but does not keep it updated? You can only use Bitcoin if you are internet-connected anyway, so what is the rationale for being internet-connected, but keeping your system buggy and vulnerable (other fixes could be more severe)?Merge #21016: refactor: remove boost::thread_group usage
Merge #21064: refactor: use std::shared_mutex & remove Boost Thread
Replace boost::shared_mutex and shared_lock with their std:: equivale…
refactor: remove boost::thread_group usage