-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Enable /clr
C++20 support
#3194
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I don't see any exports in msvcp, or symbols in msvcm, presumably because this class was trivial.
Same technique as <execution>; the affected separately compiled signatures are extern "C". Also, avoid elaborated-type-specifiers.
…ock.cpp and xmtx.cpp.)
P0433R2_deduction_guides uses usual_17_matrix.lst, which doesn't test /clr:pure.
…unction cannot be compiled as managed" instead of falling back to native codegen'.
…annot be compiled as managed" instead of falling back to native codegen'.
…ruct 'Incomplete'" despite std::variant's ADL defenses".
…global variable's constructor".
…lel std::mismatch".
…th error LNK2020/LNK2001 instead of accepting or falling back to native codegen".
… "'__builtin_coro_done': identifier not found" instead of falling back to native codegen".
…ntax for generic lambdas".
…) in constexpr.cpp".
…alling ranges algorithms with PMD projections".
…tialization of 'constinit' entity with a non-constant expression"".
…ype or function cannot be used in an unmanaged function' instead of falling back to native codegen".
…_Same_sequence". ALSO guard _Same_sequence with `IDL != 0`.
… atomic<shared_ptr>".
… information within a lambda".
…tc. concepts as being true for 'bad' iterators". ALSO silence C4793 for test code.
…nges concepts in P0896R4_ranges_iterator_machinery".
…AR(sym) || SY_ISARGUMENT(sym)".
…with views::iota and views::transform".
…ression did not evaluate to a constant' when a lambda tests a constexpr variable defined outside".
| Mode | Std | EXE (bytes) | OBJ (bytes) | Peak working set (bytes) | |:------:|:-----:|------------:|------------:|------------------------: | | Native | C++17 | 594,944 | 9,113,398 | 948,101,120 | | Native | C++20 | 2,481,664 | 33,528,885 | 3,033,104,384 | | /clr | C++17 | 12,517,888 | 53,675,003 | 1,111,109,632 | | /clr | C++20 | 41,550,336 | 198,202,365 | 3,107,594,240 |
zacklj89
approved these changes
Nov 7, 2022
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.
Nice! I looked at all the changes, and nothing jumped out at me, but it might be a good idea to get a review from someone who understands /clr:pure
nuances better.
CaseyCarter
approved these changes
Nov 8, 2022
This was referenced Nov 10, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues
Fixes #838, fixes #955, fixes #980.
Tracking issue for
/clr
compiler bugs: #3193Summary
The compiler team is working on adding support for C++20 to the
/clr
compiler option, with @tgani-msft leading this effort. While this is not yet supported for production use (and requires an undocumented/unsupported compiler front-end option), we need to add test coverage to the STL now, in order to prevent regressions during the ongoing compiler work and as we continue to change the library.Additionally, because we're going to receive
/clr
compiler bugfixes, and because a lot has changed since we added C++11 multithreading and C++17 parallel algorithms (notably, the removal of our ConcRT dependencies), I'm enabling/clr
support for headers and classes where we previously blocked it. Ultimately, this should result in a significant simplification of our codebase, as we'll need far fewer special cases for/clr
. (The original idea was "it just works".) In the near term, the simplification is partial - we can drop some product code workarounds but need to add others, and we can drop 3 "native matrices" completely but need to add numerous test workarounds.A few notes:
/clr:pure
will not be changed at all.alignas
__clrcall
virtual function call thunks (affectsP0896R4_ranges_algorithm_machinery
)/clr
at this time.I've structured this PR as a series of fine-grained commits for easier reviewing.
Commits
/clr
._M_CEE
(i.e./clr
or/clr:pure
) are now blocked for_M_CEE_PURE
only._EmptyLockit
for/clr:pure
only._Locinfo::_Lock
could have been correct, so let's enable it for/clr
./clr:pure
performs the "metadata merge" that rejects such data member changes._EmptyLockit
for/clr:pure
only shouldn't affect the export surface - I don't see any exports inmsvcp
, or symbols inmsvcm
, presumably because this class was trivial._Mtx_t
/_Cnd_t
./clr
dislikes pointers to forward-declared classes. We can usevoid*
, similar to what<execution>
already does (but we don't need to exactly imitate it, since we don't mention_Mtx_internal_imp_t
/_Cnd_internal_imp_t
otherwise):STL/stl/inc/execution
Lines 32 to 44 in c873cf0
extern "C"
._RELIABILITY_CONTRACT
for_CRTBLD
only.xlock.cpp
andxmtx.cpp
, but nowhere else.native_matrix.lst
withimpure_matrix.lst
.native_17_matrix.lst
withusual_17_matrix.lst
(which has/clr
but not/clr:pure
).env_threads.lst
withenv_minus_pure.lst
./clr
coverage in tests.__cpp_lib_execution
instead of manually definingHAS_PARALLEL_ALGORITHMS
.P0433R2_deduction_guides
can use things unconditionally because it usesusual_17_matrix.lst
, which doesn't test/clr:pure
./clr
silent bad codegen withstd::_Signed128
multiplication".<__msvc_int128.hpp>
: Backport 128-bit integer-class types to C++14 mode #3036, I was a bad kitty and worked around this without reporting it. Now we can properly comment the test workaround./clr
atomic
andthread
emit error C2711 "this function cannot be compiled as managed" instead of falling back to native codegen'./clr
alignas
emits error C2711 "this function cannot be compiled as managed" instead of falling back to native codegen'.P0040R3_extending_memory_management_tools
has always worked around this bug; now it can be properly commented.range_algorithm_support.hpp
, I'm extracting the often-repeatedholder
type, and applying a similar workaround.P0660R10_stop_token
andP1135R6_atomic_flag_test
need to be skipped./clr
emits bogus error C2079 "uses undefined struct 'Incomplete
'" despitestd::variant
's ADL defenses"._STD
-qualify_Ugly
non-member function calls in<variant>
#3148./clr
runtime hang when callingstd::async
in a global variable's constructor"./clr
System.AccessViolationException with parallelstd::mismatch
"./clr
x86 runtime assertions/crashes with parallel algorithms"./clr
rejects the__ceilf
/__floorf
intrinsics with error LNK2020/LNK2001 instead of accepting or falling back to native codegen"./clr /std:c++17
to/clr /std:c++20 /d1clrcxxstd
./clr
. The idea is that we already have extensive test coverage of 14/17/20/23 modes for native code, so for/clr
we can just use the highest mode where the most stuff is enabled. (This is fine because very little code changes meaning under different Standard modes.)/EHsc
from C++20 matrices./clr /std:c++20 /d1clrcxxstd
to C++20 and coroutine matrices./clr
C++20 rejects<coroutine>
with error C3861 "'__builtin_coro_done
': identifier not found" instead of falling back to native codegen"./clr
C++20 rejects P0428R2 Familiar template syntax for generic lambdas"./clr
C++20 chk assertion failed:rhs.is_lvalue()
inconstexpr.cpp
"./clr
C++20 System.NullReferenceException when calling ranges algorithms with PMD projections"./clr
C++20 emits bogus error C2127 "illegal initialization of 'constinit
' entity with a non-constant expression""./clr
C++20alignas
emits error C3821 'managed type or function cannot be used in an unmanaged function' instead of falling back to native codegen"./clr
C++20 configurations entirely (no targeted workaround was possible)./clr
C++20 silent bad codegen forcomplex<float>
division"./clr
C++20 backend ICE withcounted_iterator
's_Same_sequence
"./clr
._Same_sequence
withIDL != 0
(as it is otherwise unused)./clr
C++20 System.AccessViolationException withatomic<shared_ptr>
"./clr
C++20source_location
has incorrect column information within a lambda"./clr
C++20 incorrectly reportsinput_iterator
etc. concepts as being true for 'bad' iterators"./clr
C++20 has incorrect results for various ranges concepts inP0896R4_ranges_iterator_machinery
"./clr
C++20 silent bad codegen forbit_cast<float>(nan_uint)
"./clr
C++20 x64/O2
backend assertionSY_ISUSERVAR(sym) || SY_ISARGUMENT(sym)
"./clr
C++20 x64 System.AccessViolationException withviews::iota
andviews::transform
"./clr
C++20 emits bogus error C2131 'expression did not evaluate to a constant' when a lambda tests aconstexpr
variable defined outside"._Is_ymd
to be an indoor kitty.__fastcall
and__vectorcall
.<cfenv>
macros when they aren't available for/clr
.<cfenv>
usage is guarded by_M_FP_STRICT
(which this test isn't activating for/clr
), so just a bit more restructuring is necessary.P0088R3_variant
with/clr
C++20.P0088R3_variant
compiler memory consumptionThis test is already extremely stressful for native C++20.
/clr
pushes it over the edge and causes obnoxious test timeouts that the internal test harness doesn't recover from (they also wipe out the results for unrelated tests that happen to be running at the same time).I have not yet filed an issue about decomposing this test, which probably makes me a bad kitty yet again. However, the reason is at least commented here.
My measurements with the internal x86chk compiler (peak working set is reported by the undocumented/unsupported option
/d1reportMemorySummary
):/clr
/clr