Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upbpo-35920: Windows 10 ARM32 platform support #11774
Conversation
paulmon
requested review from
rhettinger,
skrah and
python/email-team
as
code owners
Feb 6, 2019
This comment has been minimized.
This comment has been minimized.
the-knights-who-say-ni
commented
Feb 6, 2019
|
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! |
the-knights-who-say-ni
added
the
CLA not signed
label
Feb 6, 2019
bedevere-bot
added
the
awaiting review
label
Feb 6, 2019
skrah
reviewed
Feb 6, 2019
Modules/_decimal/libmpdec/bits.h Outdated
skrah
reviewed
Feb 6, 2019
PCbuild/_decimal.vcxproj Outdated
zooba
reviewed
Feb 6, 2019
| @@ -92,6 +94,23 @@ def get_platform (): | |||
|
|
|||
| # get_platform () | |||
|
|
|||
| def get_target_platform (): | |||
This comment has been minimized.
This comment has been minimized.
zooba
Feb 6, 2019
Member
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.
This comment has been minimized.
This comment has been minimized.
paulmon
Feb 6, 2019
Author
Contributor
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
This comment has been minimized.
This comment has been minimized.
zooba
Feb 14, 2019
Member
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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
paulmon
Feb 20, 2019
Author
Contributor
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=''): |
This comment has been minimized.
This comment has been minimized.
Lib/platform.py Outdated
Lib/platform.py Outdated
PCbuild/_contextvars.vcxproj Outdated
PCbuild/_freeze_importlib.vcxproj Outdated
PCbuild/pyproject.props Outdated
PCbuild/pythoncore.vcxproj Outdated
Tools/winiot/sync_win_iot.py Outdated
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
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.
|
This comment has been minimized.
This comment has been minimized.
|
@skrah I was agreeing that your comment made sense. |
This comment has been minimized.
This comment has been minimized.
|
@zooba I also think anything under |
This comment has been minimized.
This comment has been minimized.
|
@paulmon Yes, I should have used /DMASM_AND_INTRINSICS; I agree that the use of |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
the-knights-who-say-ni
added
CLA signed
and removed
CLA not signed
labels
Feb 12, 2019
This comment has been minimized.
This comment has been minimized.
|
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. |
paulmon
force-pushed the
paulmon:win-arm32-proof-of-concept
branch
from
d4bcb80
to
278b786
Feb 14, 2019
This comment has been minimized.
This comment has been minimized.
|
This PR has been rebased on the merged PCBuild changes |
This comment has been minimized.
This comment has been minimized.
|
I am currently working on refactoring the changes to ctypes for ARM to match #11797 |
zooba
reviewed
Feb 14, 2019
| 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(): |
This comment has been minimized.
This comment has been minimized.
zooba
Feb 14, 2019
Member
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.
zooba
reviewed
Feb 14, 2019
Lib/distutils/util.py Outdated
zooba
reviewed
Feb 20, 2019
PC/layout/main.py Outdated
PC/layout/support/options.py Outdated
paulmon
force-pushed the
paulmon:win-arm32-proof-of-concept
branch
2 times, most recently
from
766fd54
to
6daef76
Feb 21, 2019
paulmon
force-pushed the
paulmon:win-arm32-proof-of-concept
branch
from
6f0d72b
to
2c2d75e
Apr 12, 2019
This comment has been minimized.
This comment has been minimized.
|
Rebased on master and cleaned up. |
zooba
reviewed
Apr 22, 2019
Lib/distutils/sysconfig.py Outdated
Lib/distutils/util.py Outdated
Lib/distutils/util.py Outdated
Lib/distutils/util.py Outdated
Lib/platform.py Outdated
Lib/test/test_codecs.py Outdated
Lib/test/test_codecs.py Outdated
Lib/test/test_codecs.py Outdated
Lib/test/test_mimetypes.py Outdated
This comment has been minimized.
This comment has been minimized.
|
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. |
zooba
referenced this pull request
Apr 22, 2019
Merged
Fixes platform.win32_ver on non-Windows platforms #12912
paulmon
added some commits
Apr 22, 2019
This comment has been minimized.
This comment has been minimized.
|
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. |
zooba
reviewed
Apr 22, 2019
|
|
||
| if targetPlatformFromEnvironment != None and targetPlatformFromEnvironment in TARGET_TO_PLAT: | ||
| targetPlatform = TARGET_TO_PLAT[targetPlatformFromEnvironment] | ||
| if os.name == 'nt': |
This comment has been minimized.
This comment has been minimized.
zooba
Apr 22, 2019
Member
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.
This comment has been minimized.
This comment has been minimized.
|
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. |
paulmon
changed the title
bpo-35920: CPython for Windows ARM32 proof of concept
bpo-35920: Windows 10 ARM32 platform support
Apr 22, 2019
paulmon
reviewed
Apr 23, 2019
| @@ -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(): | |||
This comment has been minimized.
This comment has been minimized.
paulmon
Apr 23, 2019
•
Author
Contributor
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)]'
This comment has been minimized.
This comment has been minimized.
|
@paulmon It looks like the macOS build issue is a real issue - circular dependency within distutils
Probably best to move the |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
I'd worry that |
This comment has been minimized.
This comment has been minimized.
|
Is the Azure pipelines PR build missing now? I think that's where the MacOS failure was showing up. |
This comment has been minimized.
This comment has been minimized.
|
Hmm... guess the webhook got lost? Close/reopen is normally the best way. I'll do it. |
zooba
closed this
Apr 24, 2019
zooba
reopened this
Apr 24, 2019
paulmon
closed this
Apr 24, 2019
paulmon
reopened this
Apr 24, 2019
This comment has been minimized.
This comment has been minimized.
|
Waited an hour and tried again. Stills seems like the webhook is missing |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Thanks. It looks like all of the builds passed now, including macOS. |
zooba
merged commit 62dfd7d
into
python:master
Apr 25, 2019
bedevere-bot
removed
the
awaiting review
label
Apr 25, 2019
This comment has been minimized.
This comment has been minimized.
|
Indeed. Congrats! |
paulmon commentedFeb 6, 2019
•
edited by bedevere-bot
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