Skip to content

Commit 552efd2

Browse files
committed
fix(windows): resolve CRT DLLs via Sysnative to survive WOW64 redirection
Flutter may drive the CMake install step with the 32-bit cmake.exe bundled in VS Build Tools. Under WOW64 file-system redirection that process sees C:\Windows\System32 rewritten to SysWOW64, which holds x86 CRT DLLs and has no vcruntime140_1.dll, so the x64 build copies wrong-arch DLLs and then fails with "file INSTALL cannot find vcruntime140_1.dll". Prefer the Sysnative pseudo-folder (visible only to 32-bit processes, maps to the real 64-bit System32) when present, falling back to System32 for native 64-bit cmake. Fixes flet-dev/flet#6436
1 parent 33d0293 commit 552efd2

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src/serious_python_windows/windows/CMakeLists.txt

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,31 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin)
190190
# This list could contain prebuilt libraries, or libraries created by an
191191
# external build triggered from this build file.
192192
string(REPLACE "\\" "/" SERIOUS_PYTHON_WINDIR "$ENV{WINDIR}")
193+
194+
# CRT runtime DLLs (msvcp140 / vcruntime140 / vcruntime140_1) are harvested from
195+
# the OS's 64-bit System32. Flutter may drive the CMake install step with the
196+
# 32-bit cmake.exe bundled in VS Build Tools (users without full Visual Studio).
197+
# Under WOW64 file-system redirection a 32-bit process sees C:\Windows\System32
198+
# transparently rewritten to SysWOW64, which holds the x86 CRT and doesn't
199+
# contain vcruntime140_1.dll at all — so the x64 build copies wrong-arch DLLs and
200+
# then fails with "cannot find vcruntime140_1.dll" (flet-dev/flet#6436).
201+
# "Sysnative" is the documented pseudo-folder that maps a 32-bit process back to
202+
# the real 64-bit System32; it's visible only to 32-bit processes, so a native
203+
# 64-bit cmake has no Sysnative and keeps using System32. Configure- and
204+
# install-time cmake are the same binary under Flutter, so the path resolved here
205+
# stays valid when cmake_install.cmake later runs.
206+
set(_sp_crt_dir "${SERIOUS_PYTHON_WINDIR}/System32")
207+
if(EXISTS "${SERIOUS_PYTHON_WINDIR}/Sysnative")
208+
set(_sp_crt_dir "${SERIOUS_PYTHON_WINDIR}/Sysnative")
209+
endif()
210+
193211
set(serious_python_windows_bundled_libraries
194212
"${PYTHON_PACKAGE}/python${PYTHON_VERSION_NODOT}$<$<CONFIG:Debug>:_d>.dll"
195213
"${PYTHON_PACKAGE}/python3$<$<CONFIG:Debug>:_d>.dll"
196214
"$<IF:$<CONFIG:Debug>,${DART_BRIDGE_DEBUG_DLL},${DART_BRIDGE_RELEASE_DLL}>"
197-
"${SERIOUS_PYTHON_WINDIR}/System32/msvcp140.dll"
198-
"${SERIOUS_PYTHON_WINDIR}/System32/vcruntime140.dll"
199-
"${SERIOUS_PYTHON_WINDIR}/System32/vcruntime140_1.dll"
215+
"${_sp_crt_dir}/msvcp140.dll"
216+
"${_sp_crt_dir}/vcruntime140.dll"
217+
"${_sp_crt_dir}/vcruntime140_1.dll"
200218
PARENT_SCOPE
201219
)
202220

0 commit comments

Comments
 (0)