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
5 changes: 4 additions & 1 deletion cuda_bindings/build_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,10 @@ def _build_cuda_bindings(debug=False):
os.path.dirname(sysconfig.get_path("include")),
] + include_path_list
library_dirs = [sysconfig.get_path("platlib"), os.path.join(os.sys.prefix, "lib")]
cudalib_subdirs = [r"lib\x64"] if sys.platform == "win32" else ["lib64", "lib"]
if sys.platform == "win32":
cudalib_subdirs = [r"lib\arm64"] if sysconfig.get_platform() == "win-arm64" else [r"lib\x64"]
else:
cudalib_subdirs = ["lib64", "lib"]
library_dirs.extend(os.path.join(cuda_path, subdir) for subdir in cudalib_subdirs)

extra_compile_args = []
Expand Down
10 changes: 7 additions & 3 deletions cuda_core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,24 @@ def _ensure_compiler_initialized(compiler, plat_name):
initialize(plat_name)


def _build_aoti_shim_lib(compiler):
def _build_aoti_shim_lib(compiler, plat_name):
# Reuse setuptools' initialized MSVC compiler instead of rediscovering
# lib.exe separately in the build backend.
lib_exe = getattr(compiler, "lib", None)
if not lib_exe:
raise RuntimeError("MSVC compiler did not expose lib.exe after initialization.")

_AOTI_SHIM_LIB_FILE.parent.mkdir(exist_ok=True)
machine = {
"win-amd64": "X64",
"win-arm64": "ARM64",
}.get(plat_name, "X64")
compiler.spawn(
[
lib_exe,
f"/DEF:{_AOTI_SHIM_DEF_FILE}",
f"/OUT:{_AOTI_SHIM_LIB_FILE}",
"/MACHINE:X64",
f"/MACHINE:{machine}",
]
)
return str(_AOTI_SHIM_LIB_FILE)
Expand All @@ -58,7 +62,7 @@ def _configure_windows_tensor_bridge(self):
continue

_ensure_compiler_initialized(self.compiler, self.plat_name)
shim_lib = _build_aoti_shim_lib(self.compiler)
shim_lib = _build_aoti_shim_lib(self.compiler, self.plat_name)
link_args = list(ext.extra_link_args or [])
if shim_lib not in link_args:
ext.extra_link_args = [*link_args, shim_lib]
Expand Down
Loading