Skip to content

VS: 32-bit MSBuild causes relink every time in some non-English locales

I've been driven crazy why our projects always got relinked when building from command line but I think I was able to nail it down. Given the following self-contained CMake project that builds an executable:

cmake_minimum_required(VERSION 3.25)
project(Test LANGUAGES C CXX)
message("using msbuild: ${CMAKE_VS_MSBUILD_COMMAND}")
file(WRITE app.cpp "int main(){}")
add_executable(app app.cpp)

Configure it with: cmake -B build -G "Visual Studio 16 2019"
Build it with: cmake --build build -v
Invoking the build the exe is re-linked every time, which can be seen in the output log under "Link:" This happens for DLLs too (which is what causes issues for us, since everything depending always got re-linked).

Running detailed msbuild logs with: cmake --build build -- /v:d examining the build log this is what causes it:

Task "Link"
  Write Tracking Logs:
  	app.dir\Debug\app.tlog\link.write.1.tlog
  Read Tracking Logs:
  	app.dir\Debug\app.tlog\link.read.1.tlog
  Outputs for D:\DEV\_MSBUILD_TEST\BUILD19\APP.DIR\DEBUG\APP.OBJ:
  	D:\DEV\_MSBUILD_TEST\BUILD19\DEBUG\APP.EXE
  	D:\DEV\_MSBUILD_TEST\BUILD19\APP.DIR\DEBUG\APP.ILK
  	D:\DEV\_MSBUILD_TEST\BUILD19\DEBUG\APP.PDB
  C:\WINDOWS\SYSTEM32\C_1250.NLS does not exist; source compilation required.
  Inputs for D:\DEV\_MSBUILD_TEST\BUILD19\APP.DIR\DEBUG\APP.OBJ:
  	C:\WINDOWS\SYSTEM32\C_1250.NLS
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\KERNEL32.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\USER32.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\GDI32.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\WINSPOOL.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\SHELL32.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\OLE32.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\OLEAUT32.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\UUID.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\COMDLG32.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UM\X64\ADVAPI32.LIB
  	D:\DEV\_MSBUILD_TEST\BUILD19\APP.DIR\DEBUG\APP.OBJ
  	C:\WINDOWS\SYSTEM32\TZRES.DLL
  	C:\WINDOWS\GLOBALIZATION\SORTING\SORTDEFAULT.NLS
  	C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\VC\TOOLS\MSVC\14.29.30133\LIB\X64\MSVCRTD.LIB
  	C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\VC\TOOLS\MSVC\14.29.30133\LIB\X64\OLDNAMES.LIB
  	C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PROFESSIONAL\VC\TOOLS\MSVC\14.29.30133\LIB\X64\VCRUNTIMED.LIB
  	C:\PROGRAM FILES (X86)\WINDOWS KITS\10\LIB\10.0.19041.0\UCRT\X64\UCRTD.LIB
  Source compilation required: input  is newer than output .

This in particular: C:\WINDOWS\SYSTEM32\C_1250.NLS does not exist; source compilation required.
Now that file IS there, however msbuild.exe cannot see it, since it is a 32-bit process, so what it actually sees is c:\windows\SysWOW64\ and C_1250.NLS is not in that folder (at least not for me, and this is a recent Windows 10 install).
And so it relinks the executable.

Using 64-bit msbuild to manually build the generated .sln file the issue does not show up.

Is this a CMake issue, an MSBuild issue or a Windows OS installation issue?
Any help would be appreciated.

Also, to fix this for us for the time being, how can we tell CMake to use the 64-bit version of MSBuild.exe without hard-coding the path for it?

EDIT: It is whole different question where on Earth does this C_1250.NLS dependency comes from, if anyone knows the answer to that, also please let us know.

Edited by Balázs Oroszi
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information