Fixes parsing of Clang versions like 20.1.7+libcxx Upstream bug: https://github.com/pytorch/pytorch/issues/157665 --- a/torch/utils/cpp_extension.py +++ b/torch/utils/cpp_extension.py @@ -434,13 +434,12 @@ def get_compiler_abi_compatibility_and_version(compiler) -> tuple[bool, TorchVer try: if IS_LINUX: minimum_required_version = MINIMUM_GCC_VERSION - versionstr = subprocess.check_output([compiler, '-dumpfullversion', '-dumpversion']) - version = versionstr.decode(*SUBPROCESS_DECODE_ARGS).strip().split('.') + compiler_info = subprocess.check_output([compiler, '-dumpfullversion', '-dumpversion']) else: minimum_required_version = MINIMUM_MSVC_VERSION compiler_info = subprocess.check_output(compiler, stderr=subprocess.STDOUT) - match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode(*SUBPROCESS_DECODE_ARGS).strip()) - version = ['0', '0', '0'] if match is None else list(match.groups()) + match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode(*SUBPROCESS_DECODE_ARGS).strip()) + version = ['0', '0', '0'] if match is None else list(match.groups()) except Exception: _, error, _ = sys.exc_info() warnings.warn(f'Error checking compiler version for {compiler}: {error}')