Commit 999a98e 1 parent 8d7355c commit 999a98e Copy full SHA for 999a98e
File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,18 @@ def compiler_has_flag(compiler, flagname):
234
234
return True
235
235
236
236
237
+ # Test whether the compiler is clang, allowing for the fact that it's name might be gcc...
238
+ def compiler_is_clang (compiler ):
239
+ # Test whether the compiler is clang by running the compiler with the --version flag and checking whether the output contains "clang"
240
+ try :
241
+ output = subprocess .check_output (
242
+ [compiler .compiler [0 ], "--version" ], stderr = subprocess .STDOUT
243
+ )
244
+ except (OSError , subprocess .CalledProcessError ):
245
+ return False
246
+ return b"clang" in output
247
+
248
+
237
249
# Now need to subclass BuildExt to access the compiler used and check flags
238
250
class BuildExt (build_ext ):
239
251
def build_extensions (self ):
@@ -246,7 +258,8 @@ def build_extensions(self):
246
258
for flag in ext .extra_compile_args :
247
259
if compiler_has_flag (self .compiler , flag ):
248
260
extra_compile_args .append (flag )
249
- elif "clang" in self .compiler .compiler [0 ] and flag == "-fopenmp" :
261
+ elif compiler_is_clang (self .compiler ) and flag == "-fopenmp" :
262
+ print ("Here" )
250
263
# clang does not support -fopenmp, but does support -Xclang -fopenmp
251
264
extra_compile_args .append ("-Xclang" )
252
265
extra_compile_args .append ("-fopenmp" )
You can’t perform that action at this time.
0 commit comments