Skip to content

MSVC header dependencies are not recorded on non-English MSVC (missing msvc_deps_prefix); GBK diagnostics crash mcpp #970

Closed

Description

@dreamyloong2005

Version: mcpp 2026.11.18.1, Windows 11 x64, toolchain msvc@system
(VS 2022 BuildTools, MSVC 14.44.35207, Chinese (zh-CN, LCID 2052) language
resources only).

1. Header changes do not trigger rebuilds

Localized cl.exe prints the /showIncludes lines in the installed UI language.
On a Chinese installation the prefix is 注意: 包含文件: instead of
Note: including file:. The ninja rule mcpp generates uses deps = msvc
without msvc_deps_prefix, so ninja recognises no lines and records no
dependencies.

Reproduction:

  1. mcpp new hello, add include/hello.hpp included from src/main.cpp,
    set [build] include_dirs = ["include"].
  2. mcpp build (succeeds).
  3. Add static_assert(false); to include/hello.hpp.
  4. mcpp build reports success; nothing is recompiled.

ninja -t deps in the build directory shows #deps 0 for every object.
On Linux (gcc 16.2.1) the same project records 52 dependencies and step 4 fails
as expected.

Setting VSLANG=1033 does not help when only the Chinese resources are
installed. After installing the English language pack, VSLANG=1033 works
around it: ninja records the header and the edit fails the build as expected.
Users who do not have, or cannot install, the English pack still get no
header tracking.

Suggested fix: detect the prefix once per toolchain (compile a tiny file with
/showIncludes that includes a known header and take the text before the
path), and emit it as msvc_deps_prefix in the rule. CMake does the same
(CMAKE_CL_SHOWINCLUDES_PREFIX).

2. mcpp crashes on non-UTF-8 compiler output

When a compile fails on the same machine, mcpp ends with:

internal: unhandled exception: [json.exception.type_error.316] invalid UTF-8 byte

cl.exe writes its diagnostics in the console code page (GBK / CP936 here);
/utf-8 changes only the source and execution character sets, not the
diagnostic output. The exit code is
non-zero, but the diagnostics are lost or garbled. Decoding compiler output
with the console/OEM code page (or replacing invalid bytes) before putting it
into JSON would avoid the crash.

Activity

  1. self-assigned this
    on Nov 19, 2026
  2. speak-agent commented on Nov 19, 2026

    @speak-agent
    Member

    Released in mcpp 2026.11.19.1 (#966). A cl.exe compile's inputs come from its /sourceDependencies record, the same in every language and code page, and the text of cl.exe, link.exe, lib.exe and rc.exe is decoded in the console's code page and written on as UTF-8 (mcpplibs.os 0.4.6); every JSON record replaces bytes that are not UTF-8. mcpp no longer sets VSLANG. Thank you for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions