-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Enable /clr C++20 support
#3194
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
Merged
Merged
Conversation
This file contains hidden or 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
Member
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
/clrcompiler bugs: #3193Summary
The compiler team is working on adding support for C++20 to the
/clrcompiler 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
/clrcompiler 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/clrsupport 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:purewill not be changed at all.alignas__clrcallvirtual function call thunks (affectsP0896R4_ranges_algorithm_machinery)/clrat this time.I've structured this PR as a series of fine-grained commits for easier reviewing.
Commits
/clr._M_CEE(i.e./clror/clr:pure) are now blocked for_M_CEE_PUREonly._EmptyLockitfor/clr:pureonly._Locinfo::_Lockcould have been correct, so let's enable it for/clr./clr:pureperforms the "metadata merge" that rejects such data member changes._EmptyLockitfor/clr:pureonly 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./clrdislikes 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_totherwise):STL/stl/inc/execution
Lines 32 to 44 in c873cf0
extern "C"._RELIABILITY_CONTRACTfor_CRTBLDonly.xlock.cppandxmtx.cpp, but nowhere else.native_matrix.lstwithimpure_matrix.lst.native_17_matrix.lstwithusual_17_matrix.lst(which has/clrbut not/clr:pure).env_threads.lstwithenv_minus_pure.lst./clrcoverage in tests.__cpp_lib_executioninstead of manually definingHAS_PARALLEL_ALGORITHMS.P0433R2_deduction_guidescan use things unconditionally because it usesusual_17_matrix.lst, which doesn't test/clr:pure./clrsilent bad codegen withstd::_Signed128multiplication".<__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./clratomicandthreademit error C2711 "this function cannot be compiled as managed" instead of falling back to native codegen'./clralignasemits error C2711 "this function cannot be compiled as managed" instead of falling back to native codegen'.P0040R3_extending_memory_management_toolshas always worked around this bug; now it can be properly commented.range_algorithm_support.hpp, I'm extracting the often-repeatedholdertype, and applying a similar workaround.P0660R10_stop_tokenandP1135R6_atomic_flag_testneed to be skipped./clremits bogus error C2079 "uses undefined struct 'Incomplete'" despitestd::variant's ADL defenses"._STD-qualify_Uglynon-member function calls in<variant>#3148./clrruntime hang when callingstd::asyncin a global variable's constructor"./clrSystem.AccessViolationException with parallelstd::mismatch"./clrx86 runtime assertions/crashes with parallel algorithms"./clrrejects the__ceilf/__floorfintrinsics with error LNK2020/LNK2001 instead of accepting or falling back to native codegen"./clr /std:c++17to/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/clrwe 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.)/EHscfrom C++20 matrices./clr /std:c++20 /d1clrcxxstdto C++20 and coroutine matrices./clrC++20 rejects<coroutine>with error C3861 "'__builtin_coro_done': identifier not found" instead of falling back to native codegen"./clrC++20 rejects P0428R2 Familiar template syntax for generic lambdas"./clrC++20 chk assertion failed:rhs.is_lvalue()inconstexpr.cpp"./clrC++20 System.NullReferenceException when calling ranges algorithms with PMD projections"./clrC++20 emits bogus error C2127 "illegal initialization of 'constinit' entity with a non-constant expression""./clrC++20alignasemits error C3821 'managed type or function cannot be used in an unmanaged function' instead of falling back to native codegen"./clrC++20 configurations entirely (no targeted workaround was possible)./clrC++20 silent bad codegen forcomplex<float>division"./clrC++20 backend ICE withcounted_iterator's_Same_sequence"./clr._Same_sequencewithIDL != 0(as it is otherwise unused)./clrC++20 System.AccessViolationException withatomic<shared_ptr>"./clrC++20source_locationhas incorrect column information within a lambda"./clrC++20 incorrectly reportsinput_iteratoretc. concepts as being true for 'bad' iterators"./clrC++20 has incorrect results for various ranges concepts inP0896R4_ranges_iterator_machinery"./clrC++20 silent bad codegen forbit_cast<float>(nan_uint)"./clrC++20 x64/O2backend assertionSY_ISUSERVAR(sym) || SY_ISARGUMENT(sym)"./clrC++20 x64 System.AccessViolationException withviews::iotaandviews::transform"./clrC++20 emits bogus error C2131 'expression did not evaluate to a constant' when a lambda tests aconstexprvariable defined outside"._Is_ymdto be an indoor kitty.__fastcalland__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_variantwith/clrC++20.P0088R3_variantcompiler memory consumptionThis test is already extremely stressful for native C++20.
/clrpushes 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