Skip to content

Commit 8d7355c

Browse files
committed
Use -Xclang -fopenmp with clang
1 parent 8f35ad0 commit 8d7355c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

setup.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,17 @@ def build_extensions(self):
246246
for flag in ext.extra_compile_args:
247247
if compiler_has_flag(self.compiler, flag):
248248
extra_compile_args.append(flag)
249+
elif "clang" in self.compiler.compiler[0] and flag == "-fopenmp":
250+
# clang does not support -fopenmp, but does support -Xclang -fopenmp
251+
extra_compile_args.append("-Xclang")
252+
extra_compile_args.append("-fopenmp")
253+
# Also adjust libraries as needed
254+
libraries.remove("gomp")
255+
libraries.append("omp")
249256
elif flag == "-fopenmp" and "gomp" in libraries:
250257
libraries.remove("gomp")
251258
ext.extra_compile_args = extra_compile_args
252259
ext.libraries = libraries
253-
# if the compiler/linker is clang, replace the gomp library with omp
254-
if ct == "unix" and "clang" in self.compiler.compiler[0]:
255-
for ext in self.extensions:
256-
libraries = ext.libraries
257-
if "gomp" in libraries:
258-
libraries.remove("gomp")
259-
libraries.append("omp")
260-
ext.libraries = libraries
261260
build_ext.build_extensions(self)
262261

263262

0 commit comments

Comments
 (0)