diff --git a/cuda_bindings/build_hooks.py b/cuda_bindings/build_hooks.py index a23d0949258..36ec44416f8 100644 --- a/cuda_bindings/build_hooks.py +++ b/cuda_bindings/build_hooks.py @@ -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 = [] diff --git a/cuda_core/setup.py b/cuda_core/setup.py index bde1fe22fee..e0d745b1f21 100644 --- a/cuda_core/setup.py +++ b/cuda_core/setup.py @@ -27,7 +27,7 @@ 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) @@ -35,12 +35,16 @@ def _build_aoti_shim_lib(compiler): 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) @@ -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]