Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/build_xml/Defines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
4 changes: 2 additions & 2 deletions src/hx/libs/regexp/pcre2_sources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<compilerflag value="-DPCRE2_STATIC" />
<compilerflag value="-DSUPPORT_UNICODE" />
<compilerflag value="-I${PCRE_DIR}" />
<compilerflag value="-std=c99" unless="MSVC_VER" />
<compilerflag value="-std=c99" unless="isMsvc" />

<file name="${PCRE_DIR}/pcre2_auto_possess.c" />
<file name="${PCRE_DIR}/pcre2_chartables.c" />
Expand Down Expand Up @@ -32,4 +32,4 @@
<file name="${PCRE_DIR}/pcre2_ucd.c" />
<file name="${PCRE_DIR}/pcre2_valid_utf.c" />
<file name="${PCRE_DIR}/pcre2_xclass.c" />
</xml>
</xml>
52 changes: 48 additions & 4 deletions toolchain/msvc-toolchain.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,27 @@

<!-- WINDOWS TOOLS -->

<set name="TOOLS_EXE_SUFFIX" value=".exe" unless="linux_host" />

<section if="HXCPP_MSVC_LLVM" >

<set name="CL_EXE" value="clang-cl${TOOLS_EXE_SUFFIX}" />
<set name="LINK_EXE" value="lld-link${TOOLS_EXE_SUFFIX}" />
<set name="LIB_EXE" value="llvm-lib${TOOLS_EXE_SUFFIX}" />
<set name="RC_EXE" value="llvm-rc${TOOLS_EXE_SUFFIX}" />
<set name="MT_EXE" value="llvm-mt${TOOLS_EXE_SUFFIX}" />

</section>

<section unless="HXCPP_MSVC_LLVM">

<set name="CL_EXE" value="cl${TOOLS_EXE_SUFFIX}" />
<set name="LINK_EXE" value="link${TOOLS_EXE_SUFFIX}" />
<set name="LIB_EXE" value="lib${TOOLS_EXE_SUFFIX}" />
<set name="RC_EXE" value="rc${TOOLS_EXE_SUFFIX}" />
<set name="MT_EXE" value="mt${TOOLS_EXE_SUFFIX}" />

</section>

<set name="USE_PRECOMPILED_HEADERS" value="msvc" unless="NO_PRECOMPILED_HEADERS" />

Expand Down Expand Up @@ -52,8 +72,15 @@
<unset name="HXCPP_FAST_LINK" if="HXCPP_FAST_LINK" unless="MSVC19"/>

<compiler id="MSVC" exe="cl.exe" if="windows">
<exe name="${CL_EXE}" />
<flag value="-nologo"/>

<section if="HXCPP_MSVC_LLVM HXCPP_MSVC_ROOT">
<flag value="-winsysroot" />
<flag value="${HXCPP_MSVC_ROOT}" />
</section>

<pchflag value="/TP" />

<!-- Newer options -->
<!-- <flag value = "/analyze-" if="MSVC17+" /> -->
Expand Down Expand Up @@ -107,19 +134,28 @@
<flag value="-wd4996"/>
<outflag value="-Fo"/>
<ext value=".obj"/>
<asmExe value="ml64.exe" if="HXCPP_M64" />
<asmExe value="ml.exe" unless="HXCPP_M64" />

<section if="HXCPP_MSVC_LLVM">
<asmExe value="llvm-ml${TOOLS_EXE_SUFFIX}" />
</section>
<section unless="HXCPP_MSVC_LLVM">
<asmExe value="ml64.exe" if="HXCPP_M64" />
<asmExe value="ml.exe" unless="HXCPP_M64" />
</section>

<objdir value="${MSVC_OBJ_DIR}" />

<rcexe name="rc.exe" />
<rcexe name="${RC_EXE}" />
<rcext value=".res" />
<rcflag value="-nologo" />

<getversion value="cl.exe"/>
<getversion value="${CL_EXE}" unless="HXCPP_MSVC_LLVM"/>
</compiler>

<linker id="dll" exe="link.exe" if="windows">
<exe name="${LINK_EXE}" />
<flag value="-nologo"/>
<flag value="-winsysroot:${HXCPP_MSVC_ROOT}" if="HXCPP_MSVC_LLVM HXCPP_MSVC_ROOT" />
<flag value="-machine:${MACHINE}"/>
<flag value="-dll"/>
<flag value="-debug:full" if="HXCPP_DEBUG_LINK" unless="HXCPP_FAST_LINK"/>
Expand All @@ -142,8 +178,10 @@
</linker>

<linker id="exe" exe="link.exe" unless="winrt">
<exe name="${LINK_EXE}" />
<fromfile value="@"/>
<flag value="-nologo"/>
<flag value="-winsysroot:${HXCPP_MSVC_ROOT}" if="HXCPP_MSVC_LLVM HXCPP_MSVC_ROOT" />
<flag value="-machine:${MACHINE}"/>
<flag value="-debug" if="HXCPP_DEBUG_LINK||HXCPP_PDB_FILE" unless="HXCPP_FAST_LINK"/>
<flag value="-debug:fastlink" if="HXCPP_FAST_LINK HXCPP_DEBUG_LINK"/>
Expand All @@ -166,7 +204,9 @@


<manifest exe="mt.exe" >
<exe name="${MT_EXE}" />
<flag value="-nologo"/>
<flag value="-winsysroot:${HXCPP_MSVC_ROOT}" if="HXCPP_MSVC_LLVM HXCPP_MSVC_ROOT" />
<flag value="-manifest"/>
<outPre value="-outputresource:" />
<outPost value=";1" />
Expand All @@ -175,8 +215,10 @@


<linker id="exe" exe="link.exe" if="winrt">
<exe name="${LINK_EXE}" />
<fromfile value="@"/>
<flag value="-nologo"/>
<flag value="-winsysroot:${HXCPP_MSVC_ROOT}" if="HXCPP_MSVC_LLVM HXCPP_MSVC_ROOT" />
<flag value="-machine:${MACHINE}"/>
<flag value="-debug" if="HXCPP_DEBUG_LINK" unless="HXCPP_FAST_LINK"/>
<flag value="-debug:fastlink" if="HXCPP_FAST_LINK HXCPP_DEBUG_LINK"/>
Expand All @@ -197,10 +239,12 @@
</linker>

<linker id="static_link" exe="lib.exe" if="windows">
<exe name="${LIB_EXE}" />
<flag value="-LTCG" if="HXCPP_OPTIMIZE_LINK" unless="debug || HXCPP_LTCG_INCREMENTAL"/>
<flag value="-LTCG:INCREMENTAL" if="HXCPP_LTCG_INCREMENTAL" unless="debug"/>
<fromfile value="@"/>
<flag value="-nologo"/>
<flag value="-winsysroot:${HXCPP_MSVC_ROOT}" if="HXCPP_MSVC_LLVM HXCPP_MSVC_ROOT" />
<flag value="-IGNORE:4264" if="winrt" />
<ext value="${LIBEXT}"/>
<outflag value="-out:"/>
Expand Down
16 changes: 13 additions & 3 deletions tools/hxcpp/BuildTool.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,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";
Expand Down Expand Up @@ -2129,9 +2134,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
Expand Down
8 changes: 5 additions & 3 deletions tools/hxcpp/Compiler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -695,7 +697,7 @@ class Compiler
mPCH = inPCH;
createCompilerVersion();
final regex = ~/clang/i;
if (inPCH != null && regex.match(mCompilerVersionString)) {
if (inPCH != null && regex.match(mCompilerVersionString) && !BuildTool.isMsvcLlvm()) {
mPCH = "clang";
}
switch (mPCH) {
Expand Down
5 changes: 4 additions & 1 deletion tools/hxcpp/Setup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,8 @@ class Setup
public static function setupMSVC(ioDefines:Hash<String>, 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"))
{
Expand Down Expand Up @@ -901,6 +902,8 @@ class Setup
}
}

if (ioDefines.exists("HXCPP_MSVC_LLVM")) return;

try
{
var proc = new Process("cl.exe",[]);
Expand Down
Loading