Fix LLVM/MinGW build on Windows.

This commit is contained in:
bruvzg
2024-06-20 14:32:32 +03:00
committed by Rémi Verschelde
parent 0843d80b31
commit f91c4a9b59
2 changed files with 28 additions and 6 deletions

View File

@@ -226,3 +226,15 @@ index aec331a76c..be98814486 100644
#include <dispatcherqueue.h>
#include <windows.foundation.metadata.h>
#include <windows.ui.composition.h>
diff --git a/third_party/zlib/cpu_features.c b/third_party/zlib/cpu_features.c
index 64e0428..1332971 100644
--- a/third_party/zlib/cpu_features.c
+++ b/third_party/zlib/cpu_features.c
@@ -11,7 +11,7 @@
#include <stdint.h>
#if defined(_MSC_VER)
#include <intrin.h>
-#elif defined(ADLER32_SIMD_SSSE3)
+#elif defined(ADLER32_SIMD_SSSE3) || (defined(__clang__) && (defined(__i386__) || defined(__x86_64__)))
#include <cpuid.h>
#endif

View File

@@ -1,3 +1,4 @@
import os
import sys
import my_spawn
@@ -7,12 +8,14 @@ from SCons.Variables import *
def options(opts):
mingw = os.getenv("MINGW_PREFIX", "")
opts.Add(BoolVariable("use_mingw", "Use the MinGW compiler instead of MSVC - only effective on Windows", False))
opts.Add(BoolVariable("use_clang_cl", "Use the clang driver instead of MSVC - only effective on Windows", False))
opts.Add(BoolVariable("use_static_cpp", "Link MinGW/MSVC C++ runtime libraries statically", True))
opts.Add(BoolVariable("debug_crt", "Compile with MSVC's debug CRT (/MDd)", False))
opts.Add(BoolVariable("use_llvm", "Use the LLVM compiler", False))
opts.Add("mingw_prefix", "MinGW prefix", mingw)
def exists(env):
return True
@@ -48,7 +51,7 @@ def generate(env):
env["CC"] = "clang-cl"
env["CXX"] = "clang-cl"
elif sys.platform == "win32" or sys.platform == "msys":
elif (sys.platform == "win32" or sys.platform == "msys") and not env["mingw_prefix"]:
env["use_mingw"] = True
mingw.generate(env)
env.Append(CPPDEFINES=["MINGW_ENABLED"])
@@ -63,14 +66,18 @@ def generate(env):
else:
env["use_mingw"] = True
# Cross-compilation using MinGW
prefix = ""
if env["mingw_prefix"]:
prefix = env["mingw_prefix"] + "/bin/"
if env["arch"] == "x86_64":
prefix = "x86_64"
prefix += "x86_64"
elif env["arch"] == "arm64":
prefix = "aarch64"
prefix += "aarch64"
elif env["arch"] == "arm32":
prefix = "armv7"
prefix += "armv7"
elif env["arch"] == "x86_32":
prefix = "i686"
prefix += "i686"
if env["use_llvm"]:
env["CXX"] = prefix + "-w64-mingw32-clang++"
@@ -100,3 +107,6 @@ def generate(env):
"-Wl,--no-undefined",
]
)
if (sys.platform == "win32" or sys.platform == "msys"):
my_spawn.configure(env)