Skip to content

Commit

Permalink
Tweaks to clang flag handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Jul 2, 2024
1 parent 3243d82 commit 2a9c413
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,18 @@ def build_extensions(self):
# only add flags which pass the flag_filter
extra_compile_args = []
libraries = ext.libraries
for flag in ext.extra_compile_args:
for flag in set(ext.extra_compile_args):
if compiler_has_flag(self.compiler, flag):
extra_compile_args.append(flag)
elif compiler_is_clang(self.compiler) 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")
if "gomp" in libraries:
libraries.remove("gomp")
if "omp" not in libraries:
libraries.append("omp")
elif flag == "-fopenmp" and "gomp" in libraries:
libraries.remove("gomp")
ext.extra_compile_args = extra_compile_args
Expand Down

0 comments on commit 2a9c413

Please sign in to comment.