File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -864,5 +864,13 @@ def test_external_module_register(self):
864
864
torch ._register_device_module ('xpu' , DummyXPUModule )
865
865
866
866
867
+ class TestCppExtensionUtils (TestCase ):
868
+ def test_cpp_compiler_is_ok (self ):
869
+ self .assertTrue (torch .utils .cpp_extension .check_compiler_ok_for_platform ('c++' ))
870
+
871
+ def test_cc_compiler_is_ok (self ):
872
+ self .assertTrue (torch .utils .cpp_extension .check_compiler_ok_for_platform ('cc' ))
873
+
874
+
867
875
if __name__ == '__main__' :
868
876
run_tests ()
Original file line number Diff line number Diff line change @@ -260,15 +260,18 @@ def check_compiler_ok_for_platform(compiler: str) -> bool:
260
260
# Check the compiler name
261
261
if any (name in compiler_path for name in _accepted_compilers_for_platform ()):
262
262
return True
263
- # If ccache is used the compiler path is /usr/bin/ccache. Check by -v flag.
263
+ # If compiler wrapper is used try to infer the actual compiler by invoking it with -v flag
264
264
version_string = subprocess .check_output ([compiler , '-v' ], stderr = subprocess .STDOUT ).decode (* SUBPROCESS_DECODE_ARGS )
265
265
if IS_LINUX :
266
- # Check for 'gcc' or 'g++'
266
+ # Check for 'gcc' or 'g++' for sccache warpper
267
267
pattern = re .compile ("^COLLECT_GCC=(.*)$" , re .MULTILINE )
268
268
results = re .findall (pattern , version_string )
269
269
if len (results ) != 1 :
270
270
return False
271
271
compiler_path = os .path .realpath (results [0 ].strip ())
272
+ # On RHEL/CentOS c++ is a gcc compiler wrapper
273
+ if os .path .basename (compiler_path ) == 'c++' and 'gcc version' in version_string :
274
+ return True
272
275
return any (name in compiler_path for name in _accepted_compilers_for_platform ())
273
276
if IS_MACOS :
274
277
# Check for 'clang' or 'clang++'
You can’t perform that action at this time.
0 commit comments