Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some improvements for MinGW and LLVM build on Windows #94747

Merged
merged 5 commits into from
Aug 28, 2024
Merged
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 methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ def mySubProcess(cmdline, env):
rv = proc.wait()
if rv:
print_error(err)
elif len(err) > 0 and not err.isspace():
print(err)
return rv

def mySpawn(sh, escape, cmd, args, env):
Expand Down
35 changes: 18 additions & 17 deletions platform/windows/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,26 @@ def get_name():
return "Windows"


def try_cmd(test, prefix, arch):
def try_cmd(test, prefix, arch, check_clang=False):
archs = ["x86_64", "x86_32", "arm64", "arm32"]
if arch:
archs = [arch]

for a in archs:
try:
out = subprocess.Popen(
get_mingw_bin_prefix(prefix, arch) + test,
get_mingw_bin_prefix(prefix, a) + test,
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
out.communicate()
outs, errs = out.communicate()
if out.returncode == 0:
if check_clang and not outs.startswith(b"clang"):
return False
return True
except Exception:
pass
else:
for a in ["x86_64", "x86_32", "arm64", "arm32"]:
try:
out = subprocess.Popen(
get_mingw_bin_prefix(prefix, a) + test,
shell=True,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
out.communicate()
if out.returncode == 0:
return True
except Exception:
pass

return False

Expand Down Expand Up @@ -651,6 +643,10 @@ def configure_mingw(env: "SConsEnvironment"):
if env["use_llvm"] and not try_cmd("clang --version", env["mingw_prefix"], env["arch"]):
env["use_llvm"] = False

if not env["use_llvm"] and try_cmd("gcc --version", env["mingw_prefix"], env["arch"], True):
print("Detected GCC to be a wrapper for Clang.")
env["use_llvm"] = True

# TODO: Re-evaluate the need for this / streamline with common config.
if env["target"] == "template_release":
if env["arch"] != "arm64":
Expand Down Expand Up @@ -763,6 +759,11 @@ def configure_mingw(env: "SConsEnvironment"):
env.Append(CCFLAGS=san_flags)
env.Append(LINKFLAGS=san_flags)

if env["use_llvm"] and os.name == "nt" and methods._colorize:
env.Append(CCFLAGS=["$(-fansi-escape-codes$)", "$(-fcolor-diagnostics$)"])

env.Append(ARFLAGS=["--thin"])

env.Append(CPPDEFINES=["WINDOWS_ENABLED", "WASAPI_ENABLED", "WINMIDI_ENABLED"])
env.Append(
CPPDEFINES=[
Expand Down
Loading