Skip to content

Commit

Permalink
Merge pull request #6 from bruvzg/llvm-mingw-win
Browse files Browse the repository at this point in the history
Fix LLVM/MinGW build on Windows.
  • Loading branch information
akien-mga authored Jul 18, 2024
2 parents fb769d3 + f91c4a9 commit 43c0ee8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
12 changes: 12 additions & 0 deletions godot-patches/patch_mingw_build.diff
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 16 additions & 6 deletions godot-tools/windows.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys

import my_spawn
Expand All @@ -7,12 +8,14 @@


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
Expand Down Expand Up @@ -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"])
Expand All @@ -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++"
Expand Down Expand Up @@ -100,3 +107,6 @@ def generate(env):
"-Wl,--no-undefined",
]
)

if (sys.platform == "win32" or sys.platform == "msys"):
my_spawn.configure(env)

0 comments on commit 43c0ee8

Please sign in to comment.