Skip to content

Commit 69e4aec

Browse files
committed
Clang does not support -fPIC on Windows
1 parent a4693df commit 69e4aec

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

python/triton/runtime/build.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ def is_msvc(cc):
3535
return cc == "cl" or cc == "cl.exe"
3636

3737

38+
def is_clang(cc):
39+
cc = os.path.basename(cc).lower()
40+
return cc == "clang" or cc == "clang.exe"
41+
42+
3843
def _cc_cmd(cc, src, out, include_dirs, library_dirs, libraries):
3944
if is_msvc(cc):
4045
out_base = os.path.splitext(out)[0]
@@ -49,7 +54,10 @@ def _cc_cmd(cc, src, out, include_dirs, library_dirs, libraries):
4954
cc_cmd += [f"/PDB:{out_base + '.pdb'}"]
5055
else:
5156
# for -Wno-psabi, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111047
52-
cc_cmd = [cc, src, "-O3", "-shared", "-fPIC", "-Wno-psabi", "-o", out]
57+
cc_cmd = [cc, src, "-O3", "-shared", "-Wno-psabi", "-o", out]
58+
if not (os.name == "nt" and is_clang(cc)):
59+
# Clang does not support -fPIC on Windows
60+
cc_cmd += ["-fPIC"]
5361
cc_cmd += [f'-l{lib}' for lib in libraries]
5462
cc_cmd += [f"-L{dir}" for dir in library_dirs]
5563
cc_cmd += [f"-I{dir}" for dir in include_dirs if dir is not None]

0 commit comments

Comments
 (0)