Skip to content

Commit

Permalink
Use -Xclang -fopenmp with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Jul 2, 2024
1 parent 8f35ad0 commit 8d7355c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,17 @@ def build_extensions(self):
for flag in ext.extra_compile_args:
if compiler_has_flag(self.compiler, flag):
extra_compile_args.append(flag)
elif "clang" in self.compiler.compiler[0] and flag == "-fopenmp":
# clang does not support -fopenmp, but does support -Xclang -fopenmp
extra_compile_args.append("-Xclang")
extra_compile_args.append("-fopenmp")
# Also adjust libraries as needed
libraries.remove("gomp")
libraries.append("omp")
elif flag == "-fopenmp" and "gomp" in libraries:
libraries.remove("gomp")
ext.extra_compile_args = extra_compile_args
ext.libraries = libraries
# if the compiler/linker is clang, replace the gomp library with omp
if ct == "unix" and "clang" in self.compiler.compiler[0]:
for ext in self.extensions:
libraries = ext.libraries
if "gomp" in libraries:
libraries.remove("gomp")
libraries.append("omp")
ext.libraries = libraries
build_ext.build_extensions(self)


Expand Down

0 comments on commit 8d7355c

Please sign in to comment.