Decide on toolchain requirements (C++14 vs C++17)
As discussed here, we need to make a decision as to the oldest toolchain we support for building host tools (such as spiflash). This in turn dictates whether we can use C++14, C++17 features and so on.
RHEL7 users will need to install a newer toolchain for C++14, but the standard versions of gcc for Ubuntu 16.04 and Debian 9 are new enough. I understand you want at least GCC 7 for C++17 (Ubuntu 16.04 ships 5.3.1).
Copying my comment from the other thread: I think allowing at least C++14 features would be nice and I'd be cautiously supportive of allowing C++17 on the basis that it's typically not too painful to install custom compilers and we already support pre-built cross compilers anyway. We also anticipate there may be Rust dependencies in the future as well.
Arguably, given the limitations of C++ we should use every tool at our disposal to maximise its readability and safety. I'd rather we require C++17 than use boost::optional or adopt LLVM's Optional
CC @achernya @moidx @imphil.
- C++14 features are available since GCC 5 and clang 3.4.
- C++17 features are available since GCC7 and clang 5.
Users running EDA tools are typically on older platforms, often RHEL/CentOS or (to a lesser extend) Ubuntu 16.04 at the moment. If we can help those users to compile our software without installing a new compiler first that would reduce friction.
- RHEL7/CentOS7: GCC 4.8.5 and clang 5 (strangely named llvm-toolset-7)
- Debian oldstable (stretch): GCC 6.3, stable (buster): GCC 8.3
- Ubuntu 16.04: GCC 5.3.1 and clang 3.8; Ubuntu 18.04: GCC 7.4, clang 6.0
RHEL7/Centos7 users can make use of the a RedHat-supported software collections (SCL) to get GCC 8.2 (docs). Doing so is actually a pretty common thing when developing on RHEL/CentOS.
For Ubuntu/Debian, there are PPAs with newer compiler versions exist, but not an "officially supported" one.
So:
- If we want to support often used versions of RHEL, Ubuntu and Debian, we need to restrict ourselves to C++11.
- If we want to support Ubuntu and Debian out of the box, and have RHEL users install an add-on pack, we can use C++14.
- If we want to use C++17, users of Ubuntu 16.04, debian oldstable, and RHEL/CentOS need to install an add-on repository.
Looking at this list, I'd go for
- Stay with C++14 for now if it results in "reasonable" code. @moidx already removed the C++17 features from the code and it looked reasonable, so we should be good for now.
- Move to C++17 once Ubuntu 18.04 and debian buster become more widely used and compatible with EDA tools (my gut feeling says early 2020)
Of course, revisit this once we have a pressing need for C++17 features. Nothing is set in stone.
I don't disagree with the reasoning, I mainly created this topic to ensure we had an explicit discussion about it rather than just being a side conversation in a PR.
C++14 seems a reasonable baseline to me, but I'd like further feedback from people likely to be writing the C++ host code.
The LLVM codebase only just moved to allowing C++14 in the last week so for me that's still shiny and new :)
@asb or @imphil any movement on this one?
Current in-tree code is C++14. @gkelly, @mcy: are you happy with this as a baseline requirement rather than C++17?
@asb I don't expect to write much C++ for this project, so I don't feel strongly about 14 vs 17. I am more familiar with 17, but I don't really think there's much benefit if we think it imposes some slight dependency pain.
Edit: I suspect the only thing a project like ours could realistically want is std::launder, and even then I really hope we don't... especially because some versions of GCC get it wrong.
C++14 as baseline is fine by me, looking at the differences document there's nothing too important we're missing out on. And as @mcy says, not much C++.