Skip to content

Commit feb593a

Browse files
committed
python/src/moocore/_ffi_build.py: Use LLVM for Windows ARM64.
1 parent d634aab commit feb593a

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

python/src/moocore/_ffi_build.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
import os
1212
import platform
13+
from distutils.core import Distribution
14+
from distutils import sysconfig
1315
from cffi import FFI
1416

1517
# Compile in debug mode.
@@ -51,10 +53,7 @@
5153

5254

5355
def get_config():
54-
from distutils.core import Distribution
55-
from distutils.sysconfig import get_config_vars
56-
57-
get_config_vars() # workaround for a bug of distutils, e.g. on OS/X
56+
sysconfig.get_config_vars() # workaround for a bug of distutils, e.g. on OS/X
5857
config = Distribution().get_command_obj("config")
5958
return config
6059

@@ -73,15 +72,28 @@ def _get_target_platform():
7372
except ValueError:
7473
pass
7574

76-
return platform.machine()
75+
arch = os.environ.get("CIBW_ARCH", platform.machine())
76+
return arch
7777

7878

7979
is_windows = platform.system() == "Windows"
8080
is_macos = platform.system() == "Darwin"
81-
8281
target_platform = _get_target_platform()
8382
is_x86_64 = target_platform in ("i686", "x86", "x86_64", "AMD64")
8483

84+
if is_windows and target_platform == "ARM64":
85+
os.environ["CC"] = "clang-cl"
86+
os.environ["CXX"] = "clang-cl"
87+
os.environ["LD"] = "lld-link"
88+
# Prevent setuptools from re-enabling MSVC
89+
os.environ["DISTUTILS_USE_SDK"] = "1"
90+
os.environ["MSSdk"] = "1"
91+
print("Using LLVM/clang-cl for Windows ARM64")
92+
else:
93+
print(
94+
f"Using default compiler {sysconfig.get_config_var('CC')} for arch={target_platform}"
95+
)
96+
8597
# Compiler flags.
8698
MSVC_CFLAGS = [
8799
"/O2", # Maximize speed

0 commit comments

Comments
 (0)