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

Fix compilation under and enable C++20 #12658

Merged
1 commit merged into from
Mar 10, 2022
Merged

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Mar 10, 2022

This commit enables /std:c++20 for local development under VS17.
Our CIs will continue to use VS16 and C++17 for now in order to reduce
the likelihood of regressions during the current development cycle.
It's expected that we'll migrate to VS17 soon, as this
is what conhost is already being built with anyways.

PR Checklist

Validation Steps Performed

  • Everything compiles under /std:c++20

@ghost ghost added Area-Build Issues pertaining to the build system, CI, infrastructure, meta Issue-Task It's a feature request, but it doesn't really need a major design. Priority-1 A description (P1) Product-Meta The product is the management of the products. labels Mar 10, 2022
Comment on lines +3 to +4
Taken from [release v1.9.1](https://github.com/CLIUtils/CLI11/releases/tag/v1.9.1), source commit
[5cb3efa](https://github.com/CLIUtils/CLI11/commit/5cb3efabce007c3a0230e4cc2e27da491c646b6c)
Copy link
Member Author

@lhecker lhecker Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI In order to keep this PR compact I manually modified CLI11.hpp.
First I reformatted it with clang-format and then went through the file, reverting all irrelevant whitespace changes.

Without this basically the entire CLI11.hpp file would've been rewritten, since the original v1.9.0 uses a vastly different code format than the version we got.

@@ -12,7 +12,7 @@
#include <sddl.h>
#include <wil/token_helpers.h>

static constexpr std::string_view Utf8Bom{ u8"\uFEFF" };
static constexpr std::string_view Utf8Bom{ "\xEF\xBB\xBF", 3 };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we lose support for u8 literals? was that not a real c++ feature?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea what's the deal here? was this just a happy accident that the compiler would translate \uFEFF to the utf8 \xEF\xBB\xBF, and now we're just being more explicit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fallout from a breaking change in C++20 (source):

u8"s-char-sequence(optional)"
UTF-8 string literal. The type of a u8"..." string literal is const char[N] (until C++20) const char8_t[N] (since C++20), where N is the size of the string in UTF-8 code units including the null terminator.

Breaking changes in the language; still no breaking ABI change in the STL. 🥲

#ifdef __cpp_lib_bit_cast
#warning "Replace til::bit_cast and __builtin_bit_cast with std::bit_cast"
#endif
// TODO: Replace til::bit_cast and __builtin_bit_cast with std::bit_cast
Copy link
Member Author

@lhecker lhecker Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you'd like me to I can create an issue for this. I left it as a code-TODO since I personally consider this not particularly noteworthy. (I considered doing it as part of this PR, but I didn't want to burden us any more than necessary.)

src/terminal/parser/ft_fuzzer/fuzzing_directed.h Outdated Show resolved Hide resolved
@lhecker lhecker force-pushed the dev/lhecker/issue-12510-cpp20 branch from 4f9861c to e4003ae Compare March 10, 2022 17:12
[dd0d8e4](https://github.com/CLIUtils/CLI11/commit/dd0d8e4fe729e5b1110232c7a5c9566dad884686)

Taken from [release v1.9.1](https://github.com/CLIUtils/CLI11/releases/tag/v1.9.1), source commit
[5cb3efa](https://github.com/CLIUtils/CLI11/commit/5cb3efabce007c3a0230e4cc2e27da491c646b6c)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is a cgmanifest.json in the cli11 folder plz update it to match this commit

@@ -12,7 +12,7 @@
#include <sddl.h>
#include <wil/token_helpers.h>

static constexpr std::string_view Utf8Bom{ u8"\uFEFF" };
static constexpr std::string_view Utf8Bom{ "\xEF\xBB\xBF", 3 };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did we lose support for u8 literals? was that not a real c++ feature?

@@ -12,7 +12,7 @@
#include <sddl.h>
#include <wil/token_helpers.h>

static constexpr std::string_view Utf8Bom{ u8"\uFEFF" };
static constexpr std::string_view Utf8Bom{ "\xEF\xBB\xBF", 3 };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea what's the deal here? was this just a happy accident that the compiler would translate \uFEFF to the utf8 \xEF\xBB\xBF, and now we're just being more explicit?

@lhecker lhecker added the AutoMerge Marked for automatic merge by the bot when requirements are met label Mar 10, 2022
@ghost
Copy link

ghost commented Mar 10, 2022

Hello @lhecker!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 18 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit cfaa315 into main Mar 10, 2022
@ghost ghost deleted the dev/lhecker/issue-12510-cpp20 branch March 10, 2022 23:47
DHowett added a commit that referenced this pull request Sep 8, 2022
When Leonard updated CLI11 in #12658, he imported a version that no
longer requires RTTI. Since CLI11 was the only reason we had enabled
RTTI in any of our projects, we're finally able to turn it off.

|        | TerminalApp.dll | MSIX Package |
| ------ | ---------------:| ------------:|
| Before |         3180KiB |      6545KiB |
| After  |         1970KiB |      6426KiB |
| Delta  |    **-1210KiB** |  **-119KiB** |
DHowett added a commit that referenced this pull request Sep 9, 2022
When Leonard updated CLI11 in #12658, he imported a version that no
longer requires RTTI. Since CLI11 was the only reason we had enabled
RTTI in any of our projects, we're finally able to turn it off.

|        | TerminalApp.dll | MSIX Package |
| ------ | ---------------:| ------------:|
| Before |         3180KiB |      6545KiB |
| After  |         1970KiB |      6426KiB |
| Delta  |    **-1210KiB** |  **-119KiB** |

(cherry picked from commit e682cda)
Service-Card-Id: 85546966
Service-Version: 1.15
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Build Issues pertaining to the build system, CI, infrastructure, meta AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Task It's a feature request, but it doesn't really need a major design. Priority-1 A description (P1) Product-Meta The product is the management of the products.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[MSVC][std:c++latest] terminal failed to build with /std:c++latest on MSVC
3 participants