GeezerVison is showing github.com — bpo-33351: (WIP) Patches to build on clang-cl by emmatyping · Pull Request #7680 · python/cpython
Conversation
emmatyping
commented
Jun 13, 2018
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
I've been a bit busy so I haven't had time to prepare this, but I wanted to post something people can try, so here's something.
So far I have made changes to:
- forward declare struct timeval in pytime (it should have been anyway)
- move some struct packing in the correct place
- Using a more portable stringize macro
- defining compiler names
This builds and passes tests with MSVC, and clang-cl on x64.
If you would like to test this:
- Grab a Windows snapshot build of clang trunk from here: http://llvm.org/builds/ or build clang from source (not recommended, this is quite time, processor, and memory intensive).
then
- Change project files to build with the LLVM-2014 toolset (I haven't figured out a good way to do this automatically yet).
Everything builds except:
- _decimal (clang-cl doesn't like linking mpd it seems)
- _distutils_findvs (unsurprisingly)
- pyshellext (it doesn't like the idl file)
The good news is that clang generates MSVC ABI compatible binaries, so linking clang/msvc binaries together is fine.
The following tests fail under clang-cl:
test_compile test_compileall test_ctypes test_exceptions
test_fileio test_io test_json test_os test_pickle test_pickletools
test_richcmp test_runpy test_script_helper test_sys test_traceback
test_userdict test_userlist test_xml_etree
It seems many of them are failing with a stack overflow, so it seems clang is miscompiling something.
There is however a subset that can compile under clang while still passing the tests.
https://bugs.python.org/issue33351
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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
|
Should this PR also add clang-cl compiler option for distutils?
clang-cl could basically use a copy of the MSVCCompiler class in _msvccompiler.py
It would only need to change line 245: self.cc = _find_exe("cl.exe", paths) to self.cc = _find_exe("clang-cl.exe", paths). Also some of the compiler arguments are unnecessary.
Also line 960 compiler_class in ccompiler.py needs updating.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Should this PR also add clang-cl compiler option for distutils?
@ahartikainen I think that is likely the next todo I have. I'll get back to this soon hopefully.
|
ahartikainen reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@ethanhs Are you still interested in pushing this forward? If so, can you merge against master and run CI again.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@zooba, yes! I have been working on other things recently, but it would be helpful to know what a mergable PR should look like. Since clang-cl can fallback to cl, there may be a few modules I will need to use that for, as mentioned in the PR comment there seems to be an issue with how it compiles things (however I should test this with a newer clang to be sure).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Of the three modules that didn't build, distutils_findvs has been removed and pyshellext is probably optional (it's part of the py.exe launcher, not Python itself). So that will get you closer.
You should be able to pass /p:PlatformToolset="whatever" on the command line (or set it as an environment variable) to override the toolset when building outside of VS. The "right" way to do in within VS is to add a new configuration, but that's far more intrusive (going to have to touch every project file and test it extensively).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ahartikainen reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
emmatyping reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|