8000 Fix torch.utils.cpp_extension parser for clang version 20.1.7+libcxx · pytorch/pytorch@6bc290a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bc290a

Browse files
committed
Fix torch.utils.cpp_extension parser for clang version 20.1.7+libcxx
When CC and CXX compiler is set to clang, and clang was compiled with libc++, compilation of torchvision fails with: ``` File "/usr/lib/python3.12/site-packages/torch/utils/cpp_extension.py", line 585, in build_extensions compiler_name, compiler_version = self._check_abi() ^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/torch/utils/cpp_extension.py", line 1034, in _check_abi _, version = get_compiler_abi_compatibility_and_version(compiler) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/torch/utils/cpp_extension.py", line 449, in get_compiler_abi_compatibility_and_version if tuple(map(int, version)) >= minimum_required_version: ^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: '7+libcxx' ``` Compiler identification is a valid semantic version: ``` $ clang -dumpfullversion -dumpversion 20.1.7+libcxx ``` After adjusting parser of version, clang is able to compile extensions successfully. Closes #157665 Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
1 parent 3e56a9c commit 6bc290a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

torch/utils/cpp_extension.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,12 @@ def get_compiler_abi_compatibility_and_version(compiler) -> tuple[bool, TorchVer
454454
try:
455455
if IS_LINUX:
456456
minimum_required_version = MINIMUM_GCC_VERSION
457-
versionstr = subprocess.check_output([compiler, '-dumpfullversion', '-dumpversion'])
458-
version = versionstr.decode(*SUBPROCESS_DECODE_ARGS).strip().split('.')
457+
compiler_info = subprocess.check_output([compiler, '-dumpfullversion', '-dumpversion'])
459458
else:
460459
minimum_required_version = MINIMUM_MSVC_VERSION
461460
compiler_info = subprocess.check_output(compiler, stderr=subprocess.STDOUT)
462-
match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode(*SUBPROCESS_DECODE_ARGS).strip())
463-
version = ['0', '0', '0'] if match is None else list(match.groups())
461+
match = re.search(r'(\d+)\.(\d+)\.(\d+)', compiler_info.decode(*SUBPROCESS_DECODE_ARGS).strip())
462+
version = ['0', '0', '0'] if match is None else list(match.groups())
464463
except E 441C xception:
465464
_, error, _ = sys.exc_info()
466465
logger.warning('Error checking compiler version for %s: %s', compiler, error)

0 commit comments

Comments
 (0)
0