[llvm] Use CreateProcessW explicitly to improve compatibility (PR #160096)

Yuriy Chernyshov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 22 06:19:19 PDT 2025


https://github.com/georgthegreat created https://github.com/llvm/llvm-project/pull/160096

We compile our monorepo with `/D_MBCS` and flang-rt compilation breaks as it explicitly uses `wchar_t` (i. e. not TCHAR).

Use STARTUPINFOW / CreateProcessW method explicitly to make the code work disregarding global settings.

>From ec9078d051178837e6d6a082ee165cece89b0aa1 Mon Sep 17 00:00:00 2001
From: Yuriy Chernyshov <thegeorg at yandex-team.com>
Date: Mon, 22 Sep 2025 16:15:44 +0300
Subject: [PATCH] Use CreateProcessW explicitly to improve compatibility

---
 flang-rt/lib/runtime/execute.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/flang-rt/lib/runtime/execute.cpp b/flang-rt/lib/runtime/execute.cpp
index f180da846a32c..779e040bebebc 100644
--- a/flang-rt/lib/runtime/execute.cpp
+++ b/flang-rt/lib/runtime/execute.cpp
@@ -212,7 +212,7 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
   } else {
 // Asynchronous mode
 #ifdef _WIN32
-    STARTUPINFO si;
+    STARTUPINFOW si;
     PROCESS_INFORMATION pi;
     ZeroMemory(&si, sizeof(si));
     si.cb = sizeof(si);
@@ -234,7 +234,7 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
     }
     FreeMemory(newCmdWin);
 
-    if (CreateProcess(nullptr, wcmd, nullptr, nullptr, FALSE, 0, nullptr,
+    if (CreateProcessW(nullptr, wcmd, nullptr, nullptr, FALSE, 0, nullptr,
             nullptr, &si, &pi)) {
       // Close handles so it will be removed when terminated
       CloseHandle(pi.hProcess);



More information about the llvm-commits mailing list