-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-33351: Patches to build on clang-cl #18371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This was mostly: - forward declare struct timeval in pytime (it should have been anyway) - moving struct packing in the correct place - Using a more portable, standard garunteed stringize macro - defining compiler names
compared to https://github.com/zufuliu/llvm-utils/blob/master/clang/clang-cl-py3.diff, the change to _msvccompiler.py seems outdated, specifically, PLAT_TO_LLVM_TARGETS = {
'win32': '-m32',
'win-amd64': '-m64',
'win-arm64': '--target=aarch64-pc-windows-msvc',
} |
Neat! Thank you for pushing this forward, I've been working on the implementation for PEP 585 recently and haven't had time to complete things. I believe the CPython CI is going to moving off of Azure pipelines and use Github actions if I am not mistaken, so perhaps using that would be better. (Though I'd wait for Steve to comment before making changes). |
@zufuliu, I specifically used |
@isuruf OK. I don't use clang-cl from mingw-w64 LLVM (from msys2 or https://github.com/mstorsjo/llvm-mingw) there is bug in _msvccompiler.py (it's may be better to fallback to cl.exe when clang-cl.exe isn't found): if self.use_clang_cl:
self.cc = _find_exe("clang-cl.exe")
self.cc = _find_exe("cl.exe", paths) and I added |
Thanks to Zufu Liu (@zufuliu) for the code
Thanks @zufuliu, fixed it. I didn't add the registry lookup, because I usually use clang-cl from a different source and I wanted to have a way to use the one from PATH even if there's a compiler installed from official sources with the registry key. So, how about checking in PATH and then falling back to the registry? Note that some visual studio installations also have a clang.exe inside. |
Codecov Report
@@ Coverage Diff @@
## master #18371 +/- ##
==========================================
- Coverage 82.19% 82.12% -0.07%
==========================================
Files 1957 1955 -2
Lines 589224 584483 -4741
Branches 44428 44477 +49
==========================================
- Hits 484334 480029 -4305
+ Misses 95222 94807 -415
+ Partials 9668 9647 -21
Continue to review full report at Codecov.
|
I think |
…from i386-pc-windows-msvc to i686-pc-windows-msvc. Apply some changes by Isuru Fernando from python/cpython#18371 to clang-cl for Python3 distutils.
There is a mistake in I changed PLAT_TO_LLVM_TARGETS = {
'win32': 'i686-pc-windows-msvc',
'win-amd64': 'x86_64-pc-windows-msvc',
'win-arm32' : 'arm-pc-windows-msvc',
'win-arm64': 'aarch64-pc-windows-msvc',
} so target flag can be written as |
Also use the full target triple in the map
Thanks @zufuliu |
Fixed merge conflicts. Ready for a review again. |
Any progress on this? |
If it is any encouragement, numpy/numpy#13816 builds NumPy and passes all tests using clang-cl. |
@@ -262,6 +275,16 @@ def initialize(self, plat_name=None): | |||
ldflags_debug = [ | |||
'/nologo', '/INCREMENTAL:NO', '/LTCG', '/DEBUG:FULL' | |||
] | |||
if self.use_clang_cl: | |||
# Add target for clang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if CPython makes use of any intrinsic or built-ins, but I had problems with both.
Intrinsics required removing some of the include directories that are used with MSVC since clang doesn't need the .h
files.
Correct builtin support (on 32 bit Windows) required linking agsint the builtin .lib file.
@isuruf It seems this PR need to be submitted to https://github.com/pypa/distutils, distutils in stdlib is going to be removed. |
…from i386-pc-windows-msvc to i686-pc-windows-msvc. Apply some changes by Isuru Fernando from python/cpython#18371 to clang-cl for Python3 distutils.
@isuruf Can you rebase your PR on main branch ? |
I've already done that multiple times. I'll rebase after I get a review from someone who is interested in merging this. |
Thanks for the PR, but I think some of this was done in #101352 and distutils has been removed from CPython main |
Replaces #7680
This PR also adds an azure job for testing the build with clang-cl
Also adds a distutils patch modified from the one by @zufuliu.
https://bugs.python.org/issue33351