-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-35920: Windows 10 ARM32 platform support #11774
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
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for your contribution, we look forward to reviewing it! |
Lib/distutils/util.py
Outdated
@@ -92,6 +94,23 @@ def get_platform (): | |||
|
|||
# get_platform () | |||
|
|||
def get_target_platform (): |
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.
If this needs to replace most uses of get_platform
except when detecting whether we are cross-compiling, can we just update get_platform
(and avoid all the renames above) and provide a new API for generating the tag?
On second reading, we probably aren't properly handling the --plat-name
option in build_ext
properly already, and that would be the better way to specify that "arm" is the target. It can select a default based on the environment variable, but it should also work when passed -p win-arm
and going via the vcvarsall.bat
path.
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.
get_target_platform returns the target platform when cross-compiling.
get_platform returns the host platform.
ARM32 binaries can only be cross-compiled using the MSVC toolset.
Also when a module like numpy overrides the build files --target-plat doesn't get always passed through in the attributes like it should
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.
According to the docs, it already returns the target platform on macOS, as well as already being wrong for Windows ("non-POSIX platforms … return sys.platform
"), so I think changing it on Windows to also return the distutils target is fine.
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'll start a post on python-dev to clarify and see what people think.
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 updated the PR to use get_platform and get_host_platform. Testing is still needed
Lib/platform.py
Outdated
return True | ||
return False | ||
|
||
def win32_editionId(editionId=''): |
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.
This will need documentation (Doc/library/platform.rst
)
To help make the reviews simpler, I'm inclined to say it's okay to merge most of the
Obviously the impactful ctypes and OpenSSL changes should not be included yet, and I mentioned a few things that I would like to see reverted, but most of the project changes are mechanical and otherwise unused unless explicitly enabled through |
On Wed, Feb 06, 2019 at 01:47:14PM -0800, Paul Monson wrote:
> @@ -145,7 +145,7 @@ mpd_bsf(mpd_size_t a)
}
/* END ASM */
-#elif defined(MASM)
+#elif defined(MASM) || defined (_M_ARM)
#include <intrin.h>
That makes sense I think. Do you consider armasm.exe to be the same as masm.exe?
GitHub is confusing, do you mean my comment makes sense or the diff makes sense?
If it's the former, please ignore the following:
Libmpdec (of which I am the author) uses -DASM or /DMASM mainly to enable
the optimizations in typearith.h. It is only used in this place because
intrinsics and ASM should be switched on/off together.
Only enabling on this one intrinsic is pointless since it is only moderately
time critical and completely eclipsed by the inline functions in typearith.h,
which are very much time critical.
Moreover, I want to see *which* build is enabled on the buildbots in the
command line and for my own testing in libmpdec. So I don't want macros
from headers enabling or disabling features.
I don't understand the question about armasm.exe, which has nothing to do with
the section in the diff. masm.exe is used to compile vcdiv64.asm.
Any changes to libmpdec should go to upstream first. I'm pretty sure that
the ANSI build is sufficient for ARM devices.
|
@skrah I was agreeing that your comment made sense. |
@zooba I also think anything under |
@paulmon Yes, I should have used /DMASM_AND_INTRINSICS; I agree that the use of |
I didn't look at the mountains of XML-like stuff in PCBuild, looks like gobblygook to me. However, I briefly looked over the rest and it looks relatively sensible to me. One style note, I generally don't like portability code like this:
You are testing for specific versions or platform identifiers, etc. It is better to test for "capabilities". I don't know where it would make sense to put the code (perhaps not in platform.py), but I think it would be clearer to define individual boolean flags for these things. So, the unit test code can do:
Where Maybe that's not too clear. Let me try to explain in another way. Say you have code throughout Python that works differently if the platform supports case-insensitive filenames. Rather than open code the test (e.g. "if plaform-x or platform-y or platform-z"), you define a global variable in one spot (e.g "have_case_insenstive_files = plaform-x or ..."). Then all the different places you need to check that, you just check that global. |
If the boolean flags for indicating if the platform supports some feature are only used by tests, it looks like Lib/test/support/__init__py is the place for that. We have skip_unless_symlink(), for example. Most of these ARM32 platform skips could be done that way I think. |
I'm working on a seperate PR for the PCBuild directory changes next so that we can separate the mechanical build changes from the code changes. |
d4bcb80
to
278b786
Compare
This PR has been rebased on the merged PCBuild changes |
I am currently working on refactoring the changes to ctypes for ARM to match #11797 |
Lib/distutils/sysconfig.py
Outdated
g['EXT_SUFFIX'] = _imp.extension_suffixes()[0] | ||
# if cross-compiling replace hardcoded platform-specific EXT_SUFFIX | ||
# with an EXT_SUFFIX that matches the target platform | ||
if get_platform() == get_target_platform(): |
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.
If we change the definition of get_platform
as per my post to python-dev, then to handle this I'd add a get_host_platform
which is only used for this check.
766fd54
to
6daef76
Compare
6f0d72b
to
2c2d75e
Compare
Rebased on master and cleaned up. |
Also, please try to avoid force pushing changes - it's much easier to review new commits. We'll squash merge at the end, so the history will disappear anyway. |
Sorry, I'll try to avoid force-pushing. It was getting hard to merge these changes with the other arm changes for testing purposes because of the long list of commits here. There were a lot of conflicts because the other commits were lifted out of this one. |
|
||
if targetPlatformFromEnvironment != None and targetPlatformFromEnvironment in TARGET_TO_PLAT: | ||
targetPlatform = TARGET_TO_PLAT[targetPlatformFromEnvironment] | ||
if os.name == 'nt': |
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.
Let's only define TARGET_TO_PLAT
for Windows as well. Even though it's static, it still gets constructed on each call and it doesn't have any meaning on other OS's.
Force pushing to reset when you've done a big refactor or rebase is fine, since re-reviewing from the start is probably necessary. But for fix-ups we get a "view changes since last review" button when you just add new commits, which makes things much easier on our side. If there isn't already a NEWS file for bpo-35920, please add one, and hopefully the macOS failure is transient and the rebuild will succeed. If so, I think this is ready to merge. |
Lib/distutils/util.py
Outdated
@@ -38,7 +38,7 @@ def get_host_platform(): | |||
if os.name == 'nt': | |||
if 'amd64' in sys.version.lower(): | |||
return 'win-amd64' | |||
if 'arm32' in sys.version.lower(): | |||
if 'arm' in sys.version.lower(): |
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.
sys.version() returns ARM not arm32
sys.version
'3.8.0a3+ (heads/test:5145ef5d65, Apr 19 2019, 14:58:01) [MSC v.1916 32 bit (ARM)]'
@paulmon It looks like the macOS build issue is a real issue - circular dependency within distutils
Probably best to move the |
That line is spawn.py hasn't changed in a long time. I think the problem is sysconfig.py line 18. I can't see a reason for the "from .util import get_platform, get_host_platform" to be there, it looks like it might an incomplete refactoring. I've removed it and I'm doing some testing to make sure the standard tests still pass on PC and ARM. |
I'd worry that |
Is the Azure pipelines PR build missing now? I think that's where the MacOS failure was showing up. |
Hmm... guess the webhook got lost? Close/reopen is normally the best way. I'll do it. |
Waited an hour and tried again. Stills seems like the webhook is missing |
I started a build manually at https://dev.azure.com/python/cpython/_build/results?buildId=41266 Other PRs seem to be working, so not sure what's going on here. |
Thanks. It looks like all of the builds passed now, including macOS. |
Indeed. Congrats! |
At a minimum this code needs to be refactored to take into account removing libffi_msvc and moving to the current libffi implementation based on #3806.
https://bugs.python.org/issue35920