Add support for C++ frontend wrapper on Linux (#69094)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/69094

Partially addresses https://github.com/pytorch/pytorch/issues/68768

Test Plan: Imported from OSS

Reviewed By: seemethere

Differential Revision: D32730079

Pulled By: malfet

fbshipit-source-id: 854e4215ff66e087bdf354fed7a17e87f2649c87
This commit is contained in:
Nikita Shulga
2021-12-02 16:45:20 -08:00
committed by Facebook GitHub Bot
parent 33c3c539b6
commit bede18b061
2 changed files with 13 additions and 2 deletions

View File

@ -260,15 +260,18 @@ def check_compiler_ok_for_platform(compiler: str) -> bool:
# Check the compiler name
if any(name in compiler_path for name in _accepted_compilers_for_platform()):
return True
# If ccache is used the compiler path is /usr/bin/ccache. Check by -v flag.
# If compiler wrapper is used try to infer the actual compiler by invoking it with -v flag
version_string = subprocess.check_output([compiler, '-v'], stderr=subprocess.STDOUT).decode(*SUBPROCESS_DECODE_ARGS)
if IS_LINUX:
# Check for 'gcc' or 'g++'
# Check for 'gcc' or 'g++' for sccache warpper
pattern = re.compile("^COLLECT_GCC=(.*)$", re.MULTILINE)
results = re.findall(pattern, version_string)
if len(results) != 1:
return False
compiler_path = os.path.realpath(results[0].strip())
# On RHEL/CentOS c++ is a gcc compiler wrapper
if os.path.basename(compiler_path) == 'c++' and 'gcc version' in version_string:
return True
return any(name in compiler_path for name in _accepted_compilers_for_platform())
if IS_MACOS:
# Check for 'clang' or 'clang++'