Skip to content

Conversation

@jlaanstra
Copy link
Contributor

@jlaanstra jlaanstra commented Sep 10, 2021

/await:strict is binary compatible with c++20 coroutines. Instead of adding new logic to the C++/WinRT build targets, allow opt-out of the current default so users can set this manually.

For details, see: https://docs.microsoft.com/en-us/cpp/build/reference/await-enable-coroutine-support?view=msvc-160 and https://devblogs.microsoft.com/cppblog/cpp20-coroutine-improvements-in-visual-studio-2019-version-16-11/

Fixes #1014

@oldnewthing
Copy link
Member

oldnewthing commented Sep 10, 2021

The downside is that it means two libraries both compiled for C++17 with the same version of cppwinrt.exe but different versions of the NuGet package (or one compiled with the NuGet package and one without)[1] are now no longer ABI compatible. I think we need to make this opt-in rather than a change in default. (Or at least, if it's a change in default, a way to opt out.)

[1] Example: A module that contains both C++/WinRT code (in C++17 mode and /await:strict) and C+/CX code (which uses C++17 and plain /await). We have a lot of modules like this internally inside Windows.

@jlaanstra
Copy link
Contributor Author

jlaanstra commented Sep 10, 2021

My understanding is that CX code can also use /await:strict, My primary motivation for this is that without it you can't mix a static C++/WinRT library compiled with stdcpp20 within a dll project that uses C++/CX and therefore always uses stdcpp17.

@jlaanstra
Copy link
Contributor Author

I am a fan of having opt-outs though so let me add that.

@sylveon
Copy link
Contributor

sylveon commented Sep 10, 2021

Yeah, I am generally not a fan of things like NuGet packages forcing command line arguments on the project - if I was involved in the original design, I would have had the templates include /await and never touch the command line args in the NuGet package, as it now causes issues such as this (and the fact you couldn't compile C++20 until cppwinrt was updated, as well)

@jlaanstra
Copy link
Contributor Author

Yeah, I am generally not a fan of things like NuGet packages forcing command line arguments on the project - if I was involved in the original design, I would have had the templates include /await and never touch the command line args in the NuGet package, as it now causes issues such as this (and the fact you couldn't compile C++20 until cppwinrt was updated, as well)

Agreed, instead of adding /await:strict, I'm instead adding the option to opt-out of the current /await, so project maintainers can disable it and pass their own option.

@jlaanstra jlaanstra changed the title Switch to using /await:strict which is binary compatible with c++20 coroutines. Enable /await opt-out so users can manually enable /await:strict. Sep 10, 2021
<ClCompile>
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
<AdditionalOptions Condition="'%(ClCompile.LanguageStandard)' == 'stdcpp17'">%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalOptions Condition="'%(ClCompile.LanguageStandard)' == 'stdcpp17' And '$(CppWinRTEnableLegacyCoroutines)' != 'false'">%(AdditionalOptions) /await</AdditionalOptions>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just remove this, or does this affect existing projects?

Copy link
Contributor

Choose a reason for hiding this comment

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

Removing it entirely could affect projects which relied on the implicit addition of /await.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense, the logic is just throwing me but then msbuild has never made sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to /await:strict when compiling with /stdcpp17

5 participants