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

Add CI test with LLVM 15 clang-cl #1203

Merged
merged 15 commits into from
Oct 18, 2022

Conversation

alvinhochun
Copy link
Contributor

Some fixes and workarounds are needed to get Clang to build some of the tests. There are still some outstanding issues:

  • For both test\test\GetMany.cpp and test\test_win7\GetMany.cpp, we get a recursive template instantiation:
  In file included from GetMany.cpp:1:
  In file included from D:\a\cppwinrt\cppwinrt\test\test\pch.cpp:1:
  In file included from ./pch.h:7:
  In file included from D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\Windows.Foundation.Collections.h:6:
  In file included from D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h:10:
  In file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\include\algorithm:11:
  In file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\include\xmemory:14:
  In file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\include\new:11:
  In file included from C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\include\exception:12:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\include\type_traits(135,1): fatal  error : recursive template instantiation exceeded maximum depth of 1024 [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(7699,55): message : while substituting explicitly-specified template arguments into function template 'declval' [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(7699,114): message : in instantiation of default argument for 'get_value<generator>' required here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(7704,43): message : while substituting deduced template arguments into function template 'get_value' [with U = generator, $1 = (no value)] [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(7543,50): message : in instantiation of static data member 'winrt::impl::root_implements<generator, winrt::Windows::Foundation::Collections::IIterable<int>>::has_final_release::value' requested here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(7434,20): message : in instantiation of member function 'winrt::impl::root_implements<generator, winrt::Windows::Foundation::Collections::IIterable<int>>::NonDelegatingRelease' requested here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(8066,42): message : (skipping 1015 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all) [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\Windows.Foundation.Collections.h(965,20): message : in instantiation of function template specialization 'winrt::make<winrt::iterable_base<generator, int>::iterator, generator *>' requested here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\Windows.Foundation.Collections.h(279,114): message : in instantiation of member function 'winrt::iterable_base<generator, int>::First' requested here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(7077,12): message : in instantiation of member function 'winrt::impl::produce<generator, winrt::Windows::Foundation::Collections::IIterable<int>>::First' requested here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
GetMany.cpp(41,16): message : in instantiation of member function '(anonymous namespace)::single_threaded_generator(std::vector<int> &&)::generator::generator' requested here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
GetMany.cpp(262,28): message : in instantiation of function template specialization '(anonymous namespace)::single_threaded_generator<int>' requested here [D:\a\cppwinrt\cppwinrt\test\test\test.vcxproj]
  • For test\old_tests\UnitTests\weak.cpp, there is an incomplete type error:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.33.31629\include\type_traits(1152,71): error : incomplete type '(anonymous namespace)::WeakWithSelfReference' used in type trait expression [D:\a\cppwinrt\cppwinrt\test\old_tests\UnitTests\Tests.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(2025,45): message : in instantiation of variable template specialization 'std::is_base_of_v<winrt::Windows::Foundation::IUnknown, (anonymous namespace)::WeakWithSelfReference>' requested here [D:\a\cppwinrt\cppwinrt\test\old_tests\UnitTests\Tests.vcxproj]
D:\a\cppwinrt\cppwinrt\_build\x64\Release\winrt\base.h(4184,37): message : in instantiation of template type alias 'com_ref' requested here [D:\a\cppwinrt\cppwinrt\test\old_tests\UnitTests\Tests.vcxproj]
weak.cpp(55,48): message : in instantiation of template class 'winrt::weak_ref<(anonymous namespace)::WeakWithSelfReference>' requested here [D:\a\cppwinrt\cppwinrt\test\old_tests\UnitTests\Tests.vcxproj]
weak.cpp(53,12): message : definition of '(anonymous namespace)::WeakWithSelfReference' is not complete until the closing '}' [D:\a\cppwinrt\cppwinrt\test\old_tests\UnitTests\Tests.vcxproj]
  • test_cpp20:
-------------------------------------------------------------------------------
custom_error_logger
-------------------------------------------------------------------------------
custom_error.cpp(35)
...............................................................................

custom_error.cpp(21): FAILED:
  REQUIRE( lineNumber == 15 )
with expansion:
  0 == 15

I will probably need some help figuring these out.

@alvinhochun
Copy link
Contributor Author

alvinhochun commented Oct 15, 2022

  • test_cpp20:
-------------------------------------------------------------------------------
custom_error_logger
-------------------------------------------------------------------------------
custom_error.cpp(35)
...............................................................................

custom_error.cpp(21): FAILED:
  REQUIRE( lineNumber == 15 )
with expansion:
  0 == 15

This seems to be blocked on llvm/llvm-project#57094 (__cpp_lib_source_location in MSVC's STL depends on __cpp_consteval)

@alvinhochun
Copy link
Contributor Author

More failures:

-------------------------------------------------------------------------------
async_auto_cancel
-------------------------------------------------------------------------------
async_auto_cancel.cpp(73)
...............................................................................

async_auto_cancel.cpp(73): FAILED:
  {Unknown expression after the reported line}
due to a fatal error condition:
  SIGSEGV - Segmentation violation signal
 -------------------------------------------------------------------------------
async, Throw_IAsyncAction
async.cpp(400)
-------------------------------------------------------------------------------
...............................................................................

async.cppasync.cpp(400): (400)
...............................................................................

FAILED:
async.cpp(400): FAILED:
  {Unknown expression after the reported line}
due to a fatal error condition:
  SIGSEGV - Segmentation violation signal

@kennykerr
Copy link
Collaborator

C++/WinRT pushes C++ pretty hard in some areas and Clang may not be up to it in all cases. We may need to disable certain tests under Clang...

sylveon
sylveon previously approved these changes Oct 15, 2022
Copy link
Contributor

@sylveon sylveon left a comment

Choose a reason for hiding this comment

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

LGTM. The async test segmentation violations would need a debugger to investigate.

@sylveon
Copy link
Contributor

sylveon commented Oct 15, 2022

We might also want to report bugs to clang (resume_after, GetMany and weak). Ideally the whole suite would compile and run on both.

Copy link
Contributor Author

@alvinhochun alvinhochun left a comment

Choose a reason for hiding this comment

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

Okay, if you agree that disabling specific tests is fine for now then I'll go ahead and do that.

@alvinhochun
Copy link
Contributor Author

For test_win7 (async_auto_cancel), this is what I got locally:

(7210.1ca8): Access violation - code c0000005 (!!! second chance !!!)
test_win7!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::unconditional_release_ref+0x4c:
00007ff7`359bb0dc ff5010          call    qword ptr [rax+10h] ds:00000000`00000010=????????????????
0:004> k
 # Child-SP          RetAddr           Call Site
00 0000004d`4c0fcb30 00007ff7`359baffd test_win7!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::unconditional_release_ref+0x4c [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 2609] 
01 0000004d`4c0fcb80 00007ff7`359badc9 test_win7!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::release_ref+0x3d [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 2605] 
02 0000004d`4c0fcbc0 00007ff7`359b7ab2 test_win7!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::~com_ptr+0x29 [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 2436] 
03 0000004d`4c0fcc00 00007ff7`359bdf89 test_win7!winrt::hresult_error::~hresult_error+0x32 [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 4705] 
04 0000004d`4c0fcc40 00007ff7`35df22ab test_win7!winrt::hresult_canceled::~hresult_canceled+0x29 [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 4958] 
05 0000004d`4c0fcc80 00007ff7`35df2780 test_win7!_CallMemberFunction0+0x2b [D:\a\_work\1\s\src\vctools\crt\vcruntime\inc\trnsctrl.h @ 170] 
06 0000004d`4c0fccc0 00007ff7`35c662e9 test_win7!`anonymous namespace'::_ExceptionPtr_normal::_Destroy+0x100 [D:\a\_work\1\s\src\vctools\crt\github\stl\src\excptptr.cpp @ 280] 
07 0000004d`4c0fcd30 00007ff7`35df2603 test_win7!std::_Ref_count_base::_Decref+0x49 [C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\memory @ 1106] 
08 0000004d`4c0fcd70 00007ff7`35df1ca3 test_win7!std::_Ptr_base<_EXCEPTION_RECORD const >::_Decref+0x23 [D:\a\_work\1\s\src\vctools\crt\github\stl\inc\memory @ 1333] 
09 0000004d`4c0fcda0 00007ff7`35df1dc0 test_win7!std::shared_ptr<_EXCEPTION_RECORD const >::~shared_ptr<_EXCEPTION_RECORD const >+0x13 [D:\a\_work\1\s\src\vctools\crt\github\stl\inc\memory @ 1615] 
0a 0000004d`4c0fcdd0 00007ff7`35df2bcd test_win7!std::shared_ptr<_EXCEPTION_RECORD const >::operator=+0x50 [D:\a\_work\1\s\src\vctools\crt\github\stl\inc\memory @ 1619] 
0b 0000004d`4c0fce30 00007ff7`359f89d2 test_win7!__ExceptionPtrAssign+0x1d [D:\a\_work\1\s\src\vctools\crt\github\stl\src\excptptr.cpp @ 442] 
0c 0000004d`4c0fce60 00007ff7`359f335c test_win7!std::exception_ptr::operator=+0x42 [C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\exception @ 229] 
0d 0000004d`4c0fceb0 00007ff7`359e3c7a test_win7!winrt::impl::promise_base<std::coroutine_traits<winrt::Windows::Foundation::IAsyncAction,void *>::promise_type,winrt::Windows::Foundation::IAsyncAction,void>::unhandled_exception+0xdc [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\Windows.Foundation.h @ 3815] 
0e 0000004d`4c0fcf50 00007ff7`35e5f040 test_win7!`anonymous namespace'::Action+0x60a [D:\dev\mingw-winrt\cppwinrt\test\test_win7\async_auto_cancel.cpp @ 18] 
0f 0000004d`4c0fcf90 00007ff7`35e4816a test_win7!_CallSettingFrame+0x20 [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\amd64\handlers.asm @ 50] 
10 0000004d`4c0fcfc0 00007ffb`2f651456 test_win7!__FrameHandler3::CxxCallCatchBlock+0x15a [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 1521] 
11 0000004d`4c0fd060 00007ff7`359e3877 ntdll!RcConsolidateFrames+0x6
12 0000004d`4c0ff240 00007ff7`359fb01c test_win7!`anonymous namespace'::Action+0x207 [D:\dev\mingw-winrt\cppwinrt\test\test_win7\async_auto_cancel.cpp @ 21] 
13 0000004d`4c0ff3c0 00007ff7`359fabed test_win7!std::coroutine_handle<void>::operator()+0x2c [C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\coroutine @ 82] 
14 0000004d`4c0ff400 00007ffb`2f5c0ebc test_win7!winrt::resume_on_signal::awaitable::callback+0x6d [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 9405] 
15 0000004d`4c0ff480 00007ffb`2f602f26 ntdll!TppExecuteWaitCallback+0xa4
16 0000004d`4c0ff4d0 00007ffb`2eb47034 ntdll!TppWorkerThread+0x456
17 0000004d`4c0ff7d0 00007ffb`2f602651 KERNEL32!BaseThreadInitThunk+0x14
18 0000004d`4c0ff800 00000000`00000000 ntdll!RtlUserThreadStart+0x21

For test_old (async, Throw_IAsyncAction):

Debug Assertion Failed!

Program: D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\test_old.exe
File: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\vector
Line: 1385

Expression: vector empty before pop

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)
(5f74.517c): Access violation - code c0000005 (!!! second chance !!!)
test_old!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::unconditional_release_ref+0x4c:
00007ff6`fe7b8e2c ff5010          call    qword ptr [rax+10h] ds:000002e6`b7a429f0=0000000000000000
0:009> k
 # Child-SP          RetAddr           Call Site
00 000000ec`d59fd320 00007ff6`fe7b8d4d test_old!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::unconditional_release_ref+0x4c [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 2609] 
01 000000ec`d59fd370 00007ff6`fe7b8b19 test_old!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::release_ref+0x3d [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 2605] 
02 000000ec`d59fd3b0 00007ff6`fe7b5802 test_old!winrt::com_ptr<winrt::impl::IRestrictedErrorInfo>::~com_ptr+0x29 [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 2436] 
03 000000ec`d59fd3f0 00007ff6`fe7b58f9 test_old!winrt::hresult_error::~hresult_error+0x32 [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 4705] 
04 000000ec`d59fd430 00007ff6`ff2c1dbb test_old!winrt::hresult_invalid_argument::~hresult_invalid_argument+0x29 [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 4895] 
05 000000ec`d59fd470 00007ff6`ff310972 test_old!_CallMemberFunction0+0x2b [D:\a\_work\1\s\src\vctools\crt\vcruntime\inc\trnsctrl.h @ 170] 
06 000000ec`d59fd4b0 00007ff6`ff318530 test_old!__DestructExceptionObject+0xa2 [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\ehhelpers.cpp @ 249] 
07 000000ec`d59fd500 00007ffb`2f651456 test_old!__FrameHandler3::CxxCallCatchBlock+0x210 [D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\frame.cpp @ 1553] 
08 000000ec`d59fd5a0 00007ff6`fe8e6ca7 ntdll!RcConsolidateFrames+0x6
09 000000ec`d59ff6d0 00007ff6`fe7d0b8c test_old!`anonymous namespace'::Throw_IAsyncAction+0x1e7 [D:\dev\mingw-winrt\cppwinrt\test\old_tests\UnitTests\async.cpp @ 372] 
0a 000000ec`d59ff7c0 00007ff6`fe9287cd test_old!std::coroutine_handle<void>::operator()+0x2c [C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\coroutine @ 82] 
0b 000000ec`d59ff800 00007ffb`2f5c0ebc test_old!winrt::resume_on_signal::awaitable::callback+0x6d [D:\dev\mingw-winrt\cppwinrt\_build\x64\Debug\winrt\base.h @ 9405] 
0c 000000ec`d59ff880 00007ffb`2f602f26 ntdll!TppExecuteWaitCallback+0xa4
0d 000000ec`d59ff8d0 00007ffb`2eb47034 ntdll!TppWorkerThread+0x456
0e 000000ec`d59ffbd0 00007ffb`2f602651 KERNEL32!BaseThreadInitThunk+0x14
0f 000000ec`d59ffc00 00000000`00000000 ntdll!RtlUserThreadStart+0x21

(Couldn't dig any deeper)

@alvinhochun
Copy link
Contributor Author

@kennykerr Can you also allow the action actions/download-artifact@v3? I want to break up the tests into jobs to allow them to run in parallel, but I need this action to pass files between jobs.

@kennykerr
Copy link
Collaborator

@alvinhochun done!

@alvinhochun alvinhochun changed the title Add CI test with LLVM 15 clang-cl (x64) Add CI test with LLVM 15 clang-cl Oct 18, 2022
@alvinhochun alvinhochun marked this pull request as ready for review October 18, 2022 17:22
@alvinhochun
Copy link
Contributor Author

I have excluded all code that fails to build with Clang and I believe I have marked every flaky/crashing tests for the Clang build. When building with Clang, all these tests have the [clang-crash] tag and excluded by default. When running locally, you can do test.exe --list-tests [clang-crash] to list these tests.

@kennykerr
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Comment on lines -262 to -264
<Manifest>
<AdditionalManifestFiles>app.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did this get dropped? This was to enable long path support.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The manifest is already included in the project as a "Manifest file" type (

<Manifest Include="app.manifest" />
), which from what I can tell means it's automatically used when linking. This can be verified in the build log as the /manifestinput:app.manifest flag passed to link.exe.

This extra AdditionalManifestFiles attribute is in a conditional "Debug|x64" block so it doesn't apply to other configurations anyway. It also makes lld-link produce a broken binary (filed llvm/llvm-project#58444), which is the main reason for removing this. (Though I ended up not switching to lld-link anyway due to llvm/llvm-project#58445. I guess this may be fixable in the project file but there's no rush to enable this.)

@kennykerr
Copy link
Collaborator

I really appreciate the way you've staged the changes in a series of manageable PRs. 👍

@kennykerr kennykerr merged commit 5390dc8 into microsoft:master Oct 18, 2022
@alvinhochun alvinhochun deleted the alvin/test-clang-cl branch December 11, 2022 16:45
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.

3 participants