From 948ee5ed727b30e8e577f24887003f711e0bee20 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 1 Aug 2026 22:46:02 +0100 Subject: [PATCH 1/8] Add support for LLVM-based MSVC builds --- toolchain/msvc-toolchain.xml | 42 ++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/toolchain/msvc-toolchain.xml b/toolchain/msvc-toolchain.xml index fc2383848..d07e64a32 100644 --- a/toolchain/msvc-toolchain.xml +++ b/toolchain/msvc-toolchain.xml @@ -3,7 +3,27 @@ + +
+ + + + + + + +
+ +
+ + + + + + + +
@@ -52,8 +72,10 @@ + + @@ -107,18 +129,26 @@ - - + +
+ +
+
+ + +
+ - + - +
+ @@ -142,6 +172,7 @@ + @@ -166,6 +197,7 @@ + @@ -175,6 +207,7 @@ + @@ -197,6 +230,7 @@ + From 20c7388c8e9c28b229b76f7cd80b7cda1bb75901 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 1 Aug 2026 22:46:43 +0100 Subject: [PATCH 2/8] Fix pcre2 std flag check For the clang based MSVC toolchain, MSVC_VER doesn't get set, only isMsvc. --- src/hx/libs/regexp/pcre2_sources.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hx/libs/regexp/pcre2_sources.xml b/src/hx/libs/regexp/pcre2_sources.xml index a70d8fa0e..e91bb83c8 100644 --- a/src/hx/libs/regexp/pcre2_sources.xml +++ b/src/hx/libs/regexp/pcre2_sources.xml @@ -3,7 +3,7 @@ - + @@ -32,4 +32,4 @@ - \ No newline at end of file + From 24392bd1c82dc40bfd21239dd95804ccba30ccf3 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 1 Aug 2026 22:48:08 +0100 Subject: [PATCH 3/8] Keep msvc style pch for msvc llvm --- tools/hxcpp/Compiler.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/hxcpp/Compiler.hx b/tools/hxcpp/Compiler.hx index 8afdc4bbe..8b05c3d13 100644 --- a/tools/hxcpp/Compiler.hx +++ b/tools/hxcpp/Compiler.hx @@ -694,7 +694,7 @@ class Compiler { mPCH = inPCH; createCompilerVersion(); - if (inPCH != null && ~/clang/i.match(mCompilerVersionString)) { + if (inPCH != null && ~/clang/i.match(mCompilerVersionString) && !BuildTool.isMsvcLlvm()) { mPCH = "clang"; } switch (mPCH) { From d610f88ae32b8250cdafbbceca99269f00937d78 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 2 Aug 2026 01:01:29 +0100 Subject: [PATCH 4/8] Avoid -Yl use for msvc llvm pch clang-cl does not handle pchs in the same way, and it gives a warning when this flag is included. --- tools/hxcpp/BuildTool.hx | 5 +++++ tools/hxcpp/Compiler.hx | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/hxcpp/BuildTool.hx b/tools/hxcpp/BuildTool.hx index b20b2f78a..43ccf058a 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -1531,6 +1531,11 @@ class BuildTool return instance.mDefines.get("toolchain")=="msvc"; } + public static function isMsvcLlvm() + { + return isMsvc() && instance.mDefines.exists("HXCPP_MSVC_LLVM"); + } + public static function isMingw() { return instance.mDefines.get("toolchain")=="mingw"; diff --git a/tools/hxcpp/Compiler.hx b/tools/hxcpp/Compiler.hx index 8b05c3d13..4700c6ca5 100644 --- a/tools/hxcpp/Compiler.hx +++ b/tools/hxcpp/Compiler.hx @@ -640,8 +640,10 @@ class Compiler if (mPCH == "msvc") { args.push( mPCHCreate + header + ".h" ); - var symbol = "link" + Md5.encode( PathManager.combine(dir, file + mExt) ); - args.push( "-Yl" + symbol ); + if (!BuildTool.isMsvcLlvm()) { + var symbol = "link" + Md5.encode( PathManager.combine(dir, file + mExt) ); + args.push( "-Yl" + symbol ); + } // Create a temp file for including ... var tmp_cpp = dir + "/" + file + ".cpp"; From 040cd4d64f81f1e9e37ae780913d60a64813c623 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 1 Aug 2026 23:45:41 +0100 Subject: [PATCH 5/8] Skip cl version check for msvc llvm --- tools/hxcpp/Setup.hx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/hxcpp/Setup.hx b/tools/hxcpp/Setup.hx index 9b16ff801..49f576afe 100644 --- a/tools/hxcpp/Setup.hx +++ b/tools/hxcpp/Setup.hx @@ -901,6 +901,8 @@ class Setup } } + if (ioDefines.exists("HXCPP_MSVC_LLVM")) return; + try { var proc = new Process("cl.exe",[]); From b5ac305b7ac0b4a2cb28325c5e6e4aed587af173 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 1 Aug 2026 22:48:40 +0100 Subject: [PATCH 6/8] Support llvm msvc build from linux host --- toolchain/msvc-toolchain.xml | 12 +++++++++++- tools/hxcpp/BuildTool.hx | 11 ++++++++--- tools/hxcpp/Setup.hx | 3 ++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/toolchain/msvc-toolchain.xml b/toolchain/msvc-toolchain.xml index d07e64a32..efc8ca49e 100644 --- a/toolchain/msvc-toolchain.xml +++ b/toolchain/msvc-toolchain.xml @@ -3,7 +3,7 @@ - +
@@ -75,6 +75,11 @@ +
+ + +
+ @@ -150,6 +155,7 @@ + @@ -175,6 +181,7 @@ + @@ -199,6 +206,7 @@ + @@ -210,6 +218,7 @@ + @@ -235,6 +244,7 @@ + diff --git a/tools/hxcpp/BuildTool.hx b/tools/hxcpp/BuildTool.hx index 43ccf058a..bc2193d92 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -2140,9 +2140,14 @@ class BuildTool // Cross-compile? if(defines.exists("windows")) { - defines.set("toolchain","mingw"); - defines.set("mingw", "mingw"); - defines.set("xcompile","1"); + if (defines.exists("HXCPP_MSVC_LLVM")) + defines.set("toolchain", "msvc"); + else + { + defines.set("toolchain","mingw"); + defines.set("mingw", "mingw"); + } + defines.set("xcompile", "1"); defines.set("BINDIR", arm64 ? "WindowsArm64" : m64 ? "Windows64":"Windows"); } else diff --git a/tools/hxcpp/Setup.hx b/tools/hxcpp/Setup.hx index 49f576afe..ed68ae456 100644 --- a/tools/hxcpp/Setup.hx +++ b/tools/hxcpp/Setup.hx @@ -781,7 +781,8 @@ class Setup public static function setupMSVC(ioDefines:Hash, in64:Bool, inArm64, isWinRT:Bool) { var detectMsvc = !ioDefines.exists("NO_AUTO_MSVC") && - !ioDefines.exists("HXCPP_MSVC_CUSTOM"); + !ioDefines.exists("HXCPP_MSVC_CUSTOM") && + !ioDefines.exists("HXCPP_MSVC_ROOT"); if (ioDefines.exists("HXCPP_MSVC_VER")) { From 9a967e1c181e2499b568721a5c3cc2fa52910e84 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sun, 2 Aug 2026 00:15:23 +0100 Subject: [PATCH 7/8] docs: Add HXCPP_MSVC_LLVM and HXCPP_MSVC_ROOT --- docs/build_xml/Defines.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/build_xml/Defines.md b/docs/build_xml/Defines.md index 319c47cca..6d89b214a 100755 --- a/docs/build_xml/Defines.md +++ b/docs/build_xml/Defines.md @@ -91,3 +91,5 @@ Defines affecting target architecture. | *HXCPP_MINGW* | Compile for windows using mingw | | *NO_AUTO_MSVC* | Do not detect msvc location, use the one already in the executable path | | *HXCPP_WINXP_COMPAT* | Remain compatible with Windows XP. Disables condition variables. No effect on ARM. | +| *HXCPP_MSVC_LLVM* | Compile for windows using the LLVM-based MSVC toolchain | +| *HXCPP_MSVC_ROOT* | Set the root for MSVC libraries and headers | From 0d2fe90d4d685c14a56c8df3cb64f40b124754e8 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Fri, 21 Aug 2026 21:44:04 +0100 Subject: [PATCH 8/8] Support arm64 build with MSVC LLVM --- toolchain/msvc-toolchain.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/toolchain/msvc-toolchain.xml b/toolchain/msvc-toolchain.xml index efc8ca49e..0040296ab 100644 --- a/toolchain/msvc-toolchain.xml +++ b/toolchain/msvc-toolchain.xml @@ -80,6 +80,11 @@
+
+ + +
+