Skip to content

Commit

Permalink
Coordinated fix for capturing continuation context for tasks in Deskt…
Browse files Browse the repository at this point in the history
…op apps (microsoft#2654)

Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
Scottj1s and StephanTLavavej authored Apr 15, 2022
1 parent 52505b9 commit 80ebe87
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
2 changes: 1 addition & 1 deletion stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ function(add_stl_dlls D_SUFFIX THIS_CONFIG_DEFINITIONS THIS_CONFIG_COMPILE_OPTIO
target_compile_options(msvcp${D_SUFFIX}_eha_objects PRIVATE "${THIS_CONFIG_COMPILE_OPTIONS};${GL_FLAG};/EHa")

add_library(msvcp${D_SUFFIX} SHARED)
target_link_libraries(msvcp${D_SUFFIX} PRIVATE msvcp${D_SUFFIX}_eha_objects msvcp${D_SUFFIX}_objects msvcp${D_SUFFIX}_init_objects "${TOOLSET_LIB}/vcruntime${D_SUFFIX}.lib" "${TOOLSET_LIB}/msvcrt${D_SUFFIX}.lib" "ucrt${D_SUFFIX}.lib")
target_link_libraries(msvcp${D_SUFFIX} PRIVATE msvcp${D_SUFFIX}_eha_objects msvcp${D_SUFFIX}_objects msvcp${D_SUFFIX}_init_objects "${TOOLSET_LIB}/vcruntime${D_SUFFIX}.lib" "${TOOLSET_LIB}/msvcrt${D_SUFFIX}.lib" "ucrt${D_SUFFIX}.lib" "ole32.lib")
set_target_properties(msvcp${D_SUFFIX} PROPERTIES ARCHIVE_OUTPUT_NAME "msvcp140_base${D_SUFFIX}${VCLIBS_SUFFIX}")
set_target_properties(msvcp${D_SUFFIX} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
set_target_properties(msvcp${D_SUFFIX} PROPERTIES OUTPUT_NAME "msvcp140${D_SUFFIX}${VCLIBS_SUFFIX}")
Expand Down
2 changes: 2 additions & 0 deletions stl/msbuild/stl_base/msvcp.settings.targets
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
<LinkAdditionalOptions Condition="$(DebugBuild) == 'true'">-opt:ref,noicf $(LinkAdditionalOptions)</LinkAdditionalOptions>
<LinkAdditionalOptions>-nodefaultlib:libcpmt$(BuildSuffix).lib $(LinkAdditionalOptions)</LinkAdditionalOptions>
<LinkAdditionalOptions>-nodefaultlib:$(LibOutputFile) $(LinkAdditionalOptions)</LinkAdditionalOptions>
<LinkingWithMinCore Condition="'$(MsvcpFlavor)' == 'app' or '$(MsvcpFlavor)' == 'onecore'">true</LinkingWithMinCore>
<LinkAdditionalOptions Condition="'$(LinkingWithMinCore)' != 'true'">ole32.lib $(LinkAdditionalOptions)</LinkAdditionalOptions>

<LinkGenerateMapFile>true</LinkGenerateMapFile>
<LinkRelease>true</LinkRelease>
Expand Down
25 changes: 2 additions & 23 deletions stl/src/ppltasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <Windows.h>

#if defined(_CRT_APP) || defined(UNDOCKED_WINDOWS_UCRT)
#ifndef UNDOCKED_WINDOWS_UCRT
#pragma warning(push)
#pragma warning(disable : 4265) // non-virtual destructor in base class
Expand All @@ -19,7 +18,8 @@
#include <ctxtcall.h>
#include <mutex>
#include <windows.foundation.diagnostics.h>
#endif

#pragma comment(lib, "ole32")

// This IID is exported by ole32.dll; we cannot depend on ole32.dll on OneCore.
static GUID const Local_IID_ICallbackWithNoReentrancyToApplicationSTA = {
Expand Down Expand Up @@ -217,7 +217,6 @@ namespace Concurrency {
_CRTIMP2 void __thiscall _TaskEventLogger::_LogWorkItemCompleted() {}
#endif

#if defined(_CRT_APP) || defined(UNDOCKED_WINDOWS_UCRT)
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Diagnostics;
using namespace Microsoft::WRL;
Expand Down Expand Up @@ -317,26 +316,6 @@ namespace Concurrency {
}
return false;
}

#else
_CRTIMP2 void __thiscall _ContextCallback::_CallInContext(_CallbackFunction _Func, bool) const {
_Func();
}

_CRTIMP2 void __thiscall _ContextCallback::_Capture() {}

_CRTIMP2 void __thiscall _ContextCallback::_Reset() {}

_CRTIMP2 void __thiscall _ContextCallback::_Assign(void*) {}

_CRTIMP2 bool __cdecl _ContextCallback::_IsCurrentOriginSTA() {
return false;
}

_CRTIMP2 bool __cdecl _Task_impl_base::_IsNonBlockingThread() {
return false;
}
#endif
} // namespace details

#ifdef _CRT_APP
Expand Down

0 comments on commit 80ebe87

Please sign in to comment.