runtime: CLR msbuild builds fail with unresolved external symbol RedirectedHandledJITCaseForGCStress_Stub

Description

Building from the commandline (presumably with cmake) works. Building from the commandline with -msbuild fails. Attempting to build the CoreCLR solution using in visual studio fails, errors as below. Current git head is fb69200870cfa03d48d2e2dfee95a51a7d21d838 log files nicluding binlog

Reproduction Steps

git clean -xdf build -s clr -msbuild

Expected behavior

Build should succeed.

Actual behavior

       Creating library E:/Programming/csharp7/runtime/artifacts/obj/coreclr/windows.x64.Debug/ide/dlls/mscoree/coreclr/Debug/coreclr.lib and object E:/Programming/csharp7/runtime/artifacts/obj/coreclr/windows.x64.Debug/ide/dlls/mscoree/coreclr/Debug/coreclr.exp
  threadsuspend.obj : error LNK2019: unresolved external symbol RedirectedHandledJITCaseForGCStress_Stub referenced in function "public: int __cdecl Thread::CheckForAndDoRedirectForGCStress(struct _CONTEXT *)" (?CheckForAndDoRedirectForGCStress@Thread@@QEAAHPEAU_CONTEXT@@@Z) [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]
  debugger.obj : error LNK2001: unresolved external symbol RedirectedHandledJITCaseForGCStress_Stub [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]
  debugger.obj : error LNK2019: unresolved external symbol RedirectedHandledJITCaseForGCStress_StubEnd referenced in function "void __cdecl `dynamic initializer for 'private: static class MemoryRange * Debugger::s_hijackFunction''(void)" (??__E?s_hijackFunction@Debugger@@0PAVMemoryRange@@A@@YAXXZ) [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]
  E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\Debug\coreclr.dll : fatal error LNK1120: 2 unresolved externals [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]
    coreclr_static.vcxproj -> E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\Debug\coreclr_static.lib

  Build FAILED.

  LINK : fatal error LNK1181: cannot open input file 'E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\debug\daccess\RelWithDebInfo\daccess.lib' [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscordac\mscordaccore_exp.vcxproj]
  C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(245,5): error MSB8066: Custom build for 'E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\CMakeFiles\9e60c9b9cb41a192f91d1a3c78fd4d5f\mscordaccore.exp.rule;E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\CMakeFiles\1bf752c3a000341abc180bcf8eaadcbb\mscordaccore_exp.rule;E:\Programming\csharp7\runtime\src\coreclr\dlls\mscordac\CMakeLists.txt' exited with code 1181. [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscordac\mscordaccore_exp.vcxproj]
  threadsuspend.obj : error LNK2019: unresolved external symbol RedirectedHandledJITCaseForGCStress_Stub referenced in function "public: int __cdecl Thread::CheckForAndDoRedirectForGCStress(struct _CONTEXT *)" (?CheckForAndDoRedirectForGCStress@Thread@@QEAAHPEAU_CONTEXT@@@Z) [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]
  debugger.obj : error LNK2001: unresolved external symbol RedirectedHandledJITCaseForGCStress_Stub [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]
  debugger.obj : error LNK2019: unresolved external symbol RedirectedHandledJITCaseForGCStress_StubEnd referenced in function "void __cdecl `dynamic initializer for 'private: static class MemoryRange * Debugger::s_hijackFunction''(void)" (??__E?s_hijackFunction@Debugger@@0PAVMemoryRange@@A@@YAXXZ) [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]
  E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\Debug\coreclr.dll : fatal error LNK1120: 2 unresolved externals [E:\Programming\csharp7\runtime\artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscoree\coreclr\coreclr.vcxproj]

Regression?

No response

Known Workarounds

No response

Configuration

Windows 10, x64. VS2022 latest stable. dotnet sdk 6.0.102

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

@L2 looking at the internal ticket, the fix was verified in “17.1.1 [32222.245.d17.1]”. @marcpopMSFT do you know how to translate that roughly into a timeframe?

I see newer builds, but I’m not on a public channel myself.

@danmoseley Build 17.1.1 of VS released on March 8th per the release notes.

Yes, much appreciated.

BTW thanks @L2 for root causing this.

@L2 looking at the internal ticket, the fix was verified in “17.1.1 [32222.245.d17.1]”. @marcpopMSFT do you know how to translate that roughly into a timeframe?

I see newer builds, but I’m not on a public channel myself.

Experiencing the same trying to get a debug build working in VS 2022. Dug around a little and the root cause is cmake generating an incorrect mscordaccore_exp.vcxproj file.

Identical to this issue: https://developercommunity.visualstudio.com/t/CMake-vcxproj-regression-in-1710-when/1670541

The visual studio team says they have a fix pending for release as of Feb.23.2022. @danmoseley , any chance you know when the fix might roll out as it affects development on .NET? (ie. anyone using VS 2022 attempting to develop coreclr via a debug build will run into this).

@Wraith2 , opening the generated artifacts\obj\coreclr\windows.x64.Debug\ide\dlls\mscordac\mscordaccore_exp.vcxproj and looking under the CustomBuild tags shows the problem. cmake is duplicating condition checks / other weird behavior.