8000 Fix torch.utils.cpp_extension parser for clang version 20.1.7+libcxx by AngryLoki · Pull Request #157666 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@AngryLoki
Copy link
Contributor

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.

Fixes #157665

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 pytorch#157665
Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
@pytorch-bot
Copy link
pytorch-bot bot commented Jul 5, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/157666

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 6bc290a with merge base 3e56a9c (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@AngryLoki
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Jul 5, 2025
@msaroufim
Copy link
Member

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jul 5, 2025
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

8000

@msaroufim msaroufim added topic: bug fixes topic category and removed topic: not user facing topic category labels Jul 5, 2025
@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: Check Labels / Check labels

Details for Dev Infra team Raised by workflow job

@AngryLoki
Copy link
Contributor Author

@pytorchbot label "topic: not user facing"

@pytorch-bot pytorch-bot bot added the topic: not user facing topic category label Jul 5, 2025
@msaroufim
Copy link
Member

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@malfet malfet added release notes: cpp release notes category and removed topic: not user facing topic category labels Jul 6, 2025
@malfet
Copy link
Contributor
malfet commented Jul 6, 2025

@msaroufim In general, when one accepts a PR it's customary to ask for regression test, which can go from an extreme of setting up a new docker to a more docile uinttest in test_utils that just mocks the exec output. Also, please be mindful of release notes and if this is a regression than it might be a good time to cherry-pick the fix into the release branch (but then again, there is a question of testing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: cpp release notes category topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch.utils.cpp_extension fails to parse clang version 20.1.7+libcxx

5 participants

0