From c11c86c098ad905eac5cf2d35b3308c61516041d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Apr 2025 16:12:52 -0400 Subject: cmcmd: Clarify comment explaining vs_link_{exe,dll} output encoding Revise the comment from commit 7e359823c9 (MSVC: Preserve linker output encoding, 2018-08-03, v3.13.0-rc1~223^2) to more clearly explain why we need to write output using a `cmConsoleBuf` without `SetUTF8Pipes`. --- Source/cmcmd.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 9ebeba3..326718e 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -2221,10 +2221,16 @@ private: // still works. int cmcmd::VisualStudioLink(std::vector const& args, int type) { - // Replace streambuf so we output in the system codepage. CMake is set up - // to output in Unicode (see SetUTF8Pipes) but the Visual Studio linker - // outputs using the system codepage so we need to change behavior when - // we run the link command. + // MSVC tools print output in the language specified by the VSLANG + // environment variable, and encoded in the console output code page. + // RunCommand captures and converts it to our internal UTF-8 encoding. + // Then we print it as output through cmConsoleBuf: + // - NMake: Our output goes to a real console. cmConsoleBuf writes + // with WriteConsoleW, so no narrow encoding code page is needed. + // - Ninja: Our output goes to a pipe that ninja buffers and prints again. + // It does not convert encoding, so we must print in the console output + // code page even though it goes to a pipe. + // Both cases can be handled using a cmConsoleBuf without SetUTF8Pipes. cmConsoleBuf consoleBuf; if (args.size() < 2) { -- cgit v0.12