From 794c932ca93aa23d7ad92b84ec6b6db722903288 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 32848deeaa251503d3e30d267d688a058093840d Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 1 Aug 2026 22:46:43 +0100 Subject: [PATCH 2/8] Fix msvc builds without MSVC_VER set For the clang-based MSVC toolchain, MSVC_VER doesn't get set, only isMsvc. --- project/thirdparty/mbedtls-files.xml | 2 +- src/hx/libs/regexp/pcre2_sources.xml | 4 ++-- toolchain/finish-setup.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/project/thirdparty/mbedtls-files.xml b/project/thirdparty/mbedtls-files.xml index 92dc763c7..2534f9185 100644 --- a/project/thirdparty/mbedtls-files.xml +++ b/project/thirdparty/mbedtls-files.xml @@ -8,7 +8,7 @@ - + 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 + diff --git a/toolchain/finish-setup.xml b/toolchain/finish-setup.xml index 1e814ade3..468f2ed1c 100644 --- a/toolchain/finish-setup.xml +++ b/toolchain/finish-setup.xml @@ -95,7 +95,7 @@
- +
From cdf953622881f72d7b9b5f8d395daf77c9a8c8e8 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 3e29ab6a3daac2dca02afec1212429c286aeeb6c 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 cd5a48f5b..a73f60cda 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -1535,6 +1535,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 cb39e74543bfdde3a3efac70804fc7345ff47a97 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 62da55930478aeae099d1f5577458d42e1e71243 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 a73f60cda..80132cf6e 100644 --- a/tools/hxcpp/BuildTool.hx +++ b/tools/hxcpp/BuildTool.hx @@ -2144,9 +2144,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 5cf8a2926992108f8bd876e0b0933cd184b0dbc5 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 f7826e27964fbd12d5ea579db584377f5ea7ab55 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 @@
+
+ + +
+