-
-
Notifications
You must be signed in to change notification settings - Fork 855
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
[core] update to c++20 #7299
base: master
Are you sure you want to change the base?
[core] update to c++20 #7299
Conversation
Ah, need to update the github runners. upd: |
fixed capitalisation in docs |
I've added the label |
After starting using any XCode 15 feature we break the option to build and run XCode 14 with iOS 12 simulator. |
GCC 13.1 was released last April, so its super new, e.g. its not the default in the current Ubuntu 22.04 LTS. There are custom backports of GCC 12 to my very dated system, but not 13 (though maybe I didn't search thoroughly enough). Anyway its very likely there will be building issues on many older systems. My understanding is that its better to find some alternative to |
hmm yeah it's sounding like an update to c++20 might be more trouble than it's worth |
I don't observe any correlation between C++20 and If the intention is to update to C++20, please proceed with the update. |
Let's make a safe list of C++20 features that are already available on most of our operating systems, that we can benefit from, and save our development time. Enabling C++20 compilation doesn't mean that we are forced to use its features. We can choose only some convenient one/important one that help us to write cleaner code. |
@RedAuburn is snprintf enough for your task? |
@biodranik please, do not overcomplicate. We have github runners to do this work for us:
If some of our regular contributors use outdated gcc/libs, then I suggest them to use our "official" supported gcc/libs from runners. Btw, there is already such list: https://en.cppreference.com/w/cpp/20 |
✔️ I have checked it is also available for your
✔️ So far I haven't found any extra build issues, that would be tied to older systems. @RedAuburn would it be an option to keep this PR branch on top of the current upstream |
@AndrewShkrob did you see the table for iOS? Just build error is not enough, there are also some runtime OS dependencies in some cases. |
Many thanks, I'll give it a go later when I have time! |
(rebased) |
This change is needed for organicmaps#7299. C++20 deletes a number of operators including `operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;`. And consequentely the compilation with `--std=c++20` fails with `error: use of deleted function` on `out << t;`. Hence the generic `template <typename T> inline std::string DebugPrint(T const & t)` needs to be specialized for `char16_t`. For our purposes, we reuse the built-in `formatter` for `char` in this change. Note, that simply initializing a string like `{1, t}` would emmit: `warning: narrowing conversion of ‘t’ from ‘char16_t’ to ‘char’` Signed-off-by: Ferenc Géczi <ferenc.gm@gmail.com>
This change is needed for organicmaps#7299. C++20 deletes a number of operators including `operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;`. And consequentely the compilation with `--std=c++20` fails with `error: use of deleted function` on `out << t;`. Hence the generic `template <typename T> inline std::string DebugPrint(T const & t)` needs to be specialized for `char16_t`. Signed-off-by: Ferenc Géczi <ferenc.gm@gmail.com>
@RedAuburn please rebase again to upstream |
There is also android/ndk#1981 And this note: C++ locale class, for example, was not supported from the beginning on Android. What else is missing? Note that there's no static runtime on iOS, so that looks like the weakest spot now with iOS 12. |
Please rebase, and let's alpha-test it, need to make sure that iOS 12/13 and Android 5+ work on the current code. Important iOS limitations: https://developer.apple.com/xcode/cpp/ |
I've tested this PR on ios 12.5 and didn't encounter any issues. |
fixing coverage check in #8308 (unrelated to this pr) |
working fine on Android 5.1 (Oneplus One) |
7455342
to
b387840
Compare
gcc 10 works |
9.0 failed, going with minversion of 10 |
Should be good to test/merge finally :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added info that |
accidentally messed up dco signature, fixed |
Signed-off-by: Harry Bond <me@hbond.xyz>
message(FATAL_ERROR "Minimum supported g++ version is 8.1 yours is ${CMAKE_CXX_COMPILER_VERSION}") | ||
# GCC 8.1 is required to support <charconv> header inclusion in base/string_utils.hpp | ||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) | ||
message(FATAL_ERROR "Minimum supported g++ version is 10.0, yours is ${CMAKE_CXX_COMPILER_VERSION}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we expect to maintain this minimum 10.0
, if we don't even test in the CI with 10.0
?
Next PR going in after this, can add something, which suddenly needs 14.0
and nobody even notices, because that still passes the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: remove this check altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check will save us and other contributors time debugging build issues when older compilers are used.
We can switch from clang-18 to gcc-10 in the Linux check Linux no unity build
job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can express your usage requirements in CMake using target_compile_features together with things from CMAKE_CXX_KNOWN_FEATURES.
That way you don't need to check anything - CMake will do it for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly do you propose to add?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't propose to add anything, I just don't think this check solves any real problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waste of time is a real problem, especially at scale.
Seems to be all that's needed to upgrade.
Using g++13 because it's the first version with support for std::format (and close to full support for c++20 generally afaik) https://stackoverflow.com/a/69156536
building android & desktop works
Important limitations on different iOS and XCode versions for some C++17 and above features support
https://developer.apple.com/xcode/cpp/