Skip to content

Commit 8279577

Browse files
committed
[MNT] fix openmp flag on apple clang
1 parent b6dc417 commit 8279577

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

setup_cext.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,18 @@ def find_lib(names):
427427
flag = '-fopenmp=libgomp'
428428
return [flag], [flag], [], None
429429

430-
# Else, opnemp is no different than any other dependency
430+
# Else, openmp is no different than any other dependency
431431

432432
# First, check if omp/iomp5 has been installed (e.g., using homebrew)
433433
lib_name, lib_dir = find_lib([torch_omp_lib(), 'iomp5', 'omp'])
434434

435435
if lib_name is None:
436436
# OpenMP not found.
437437
# Let's just hope that the compiler knows what it's doing.
438-
return ['-fopenmp'], ['-fopenmp'], [], None
438+
flags = ['-fopenmp']
439+
if CC_type == 'apple_clang':
440+
flags.insert(0, '-Xpreprocessor')
441+
return flags, flags, [], None
439442
else:
440443
return ['-Xpreprocessor', '-fopenmp'], [], [], lib_dir
441444
# return ['-Xpreprocessor', '-fopenmp'], [lib_name], [], lib_dir
@@ -457,6 +460,7 @@ def omp_flags():
457460
if is_windows():
458461
return ['/openmp']
459462
elif is_darwin():
463+
print(find_omp_darwin())
460464
return find_omp_darwin()[0]
461465
else:
462466
return ['-fopenmp']

0 commit comments

Comments
 (0)