Skip to content

Commit 45d3226

Browse files
authored
Windows related cleanup in runtime/build.py (#2964)
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent 090e8b2 commit 45d3226

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

python/triton/runtime/build.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import shutil
77
import subprocess
88
import setuptools
9-
import platform
109

1110

1211
def is_xpu():
@@ -25,7 +24,7 @@ def quiet():
2524

2625

2726
def _cc_cmd(cc, src, out, include_dirs, library_dirs, libraries):
28-
if cc in ["cl", "clang-cl"]:
27+
if os.name == "nt":
2928
cc_cmd = [cc, src, "/nologo", "/O2", "/LD"]
3029
cc_cmd += [f"/I{dir}" for dir in include_dirs]
3130
cc_cmd += [f"/Fo{os.path.join(os.path.dirname(out), 'main.obj')}"]
@@ -36,9 +35,7 @@ def _cc_cmd(cc, src, out, include_dirs, library_dirs, libraries):
3635
cc_cmd += [f"/LIBPATH:{dir}" for dir in library_dirs]
3736
cc_cmd += [f'{lib}.lib' for lib in libraries]
3837
else:
39-
cc_cmd = [cc, src, "-O3", "-shared", "-Wno-psabi"]
40-
if os.name != "nt":
41-
cc_cmd += ["-fPIC"]
38+
cc_cmd = [cc, src, "-O3", "-shared", "-fPIC", "-Wno-psabi"]
4239
cc_cmd += [f'-l{lib}' for lib in libraries]
4340
cc_cmd += [f"-L{dir}" for dir in library_dirs]
4441
cc_cmd += [f"-I{dir}" for dir in include_dirs]
@@ -57,8 +54,8 @@ def _build(name, src, srcdir, library_dirs, include_dirs, libraries, extra_compi
5754
clang = shutil.which("clang")
5855
gcc = shutil.which("gcc")
5956
cc = gcc if gcc is not None else clang
60-
if platform.system() == "Windows":
61-
cc = "cl"
57+
if os.name == "nt":
58+
cc = shutil.which("cl")
6259
if cc is None:
6360
raise RuntimeError("Failed to find C compiler. Please specify via CC environment variable.")
6461
# This function was renamed and made public in Python 3.10
@@ -115,7 +112,7 @@ def _build(name, src, srcdir, library_dirs, include_dirs, libraries, extra_compi
115112
language='c',
116113
sources=[src],
117114
include_dirs=include_dirs,
118-
extra_compile_args=extra_compile_args + ['-O3' if "-O3" in cc_cmd else "/O2"],
115+
extra_compile_args=extra_compile_args + ['-O3' if os.name != "nt" else "/O2"],
119116
extra_link_args=extra_link_args,
120117
library_dirs=library_dirs,
121118
libraries=libraries,

0 commit comments

Comments
 (0)