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
bpo-35976: Enable Windows projects to build with platform ARM32 #11825
Conversation
PCbuild/get_externals.bat
Outdated
@@ -49,7 +49,7 @@ echo.Fetching external libraries... | |||
|
|||
set libraries= | |||
set libraries=%libraries% bzip2-1.0.6 | |||
if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.0j | |||
if NOT "%IncludeSSLSrc%"=="false" set libraries=%libraries% openssl-1.1.1a |
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 change should be in the OpenSSL PR.
PCbuild/openssl.props
Outdated
@@ -11,7 +11,8 @@ | |||
</ItemDefinitionGroup> | |||
<PropertyGroup> | |||
<_DLLSuffix>-1_1</_DLLSuffix> | |||
<_DLLSuffix Condition="$(Platform) == 'x64'">$(_DLLSuffix)-x64</_DLLSuffix> |
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 deletion should be in the OpenSSL PR.
PCbuild/pyproject.props
Outdated
@@ -68,6 +68,8 @@ | |||
<LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> | |||
<LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration> | |||
<LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration> | |||
<TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine> |
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.
Move this up alongside the other TargetMachine
conditions
PCbuild/pyproject.props
Outdated
@@ -68,6 +68,8 @@ | |||
<LinkTimeCodeGeneration Condition="$(Configuration) == 'Release'">UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> | |||
<LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGInstrument'">PGInstrument</LinkTimeCodeGeneration> | |||
<LinkTimeCodeGeneration Condition="$(SupportPGO) and $(Configuration) == 'PGUpdate'">PGUpdate</LinkTimeCodeGeneration> | |||
<TargetMachine Condition="'$(Platform)'=='ARM'">MachineARM</TargetMachine> | |||
<AdditionalDependencies Condition="'$(Platform)'=='ARM'">version.lib;shlwapi.lib;ws2_32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> |
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'm not convinced you need these. I see nothing in here that isn't a default.
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.
There might be a different way to fix this, but the defaults aren't there for ARM. As far as I can see from the command line output it doesn't link to any external dependencies without this.
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.
Here's the problem: Microsoft.Cpp.CoreWin.props only includes kernel32 and user32 for ARM because MinimalCoreWindows is true.
These files are in C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\ on my machine
There is no way to override this because Toolset.props sets MinimalCoreWindows to true if it's empty. If it's not empty and not true in Microsoft.Cpp.CoreWin.props then you get no libs at all. If Microsoft.Cpp.CoreWin.props was changed so the second check was '$(MinimalCoreWin)'!='true' then we could override MinimalCoreWin with false.
Toolset.props include Microsoft.Cpp.Common.props which includes Microsoft.Cpp.Corewin.props and there's no way to change MinimalCoreWin in between the check in Toolset and Microsoft.Cpp.Corewinprops that I can see.
The simplest fix would be to remove version.lib,kernel32.lib,and user32.lib from this list so that they aren't repeated
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.
Ah I see, in that case, leave them there and make them unconditional (provided nothing breaks). They get used on all platforms, and I'd rather not have it look like we have different sets.
(That said, I'm also keen to find ways to reduce this list, as that will mean we're trying to do less random stuff in the core. But that's a long term project.)
PCbuild/python.props
Outdated
<opensslDir>$(ExternalsDir)openssl-1.1.0j\</opensslDir> | ||
<opensslOutDir>$(ExternalsDir)openssl-bin-1.1.0j\$(ArchName)\</opensslOutDir> | ||
<opensslDir>$(ExternalsDir)openssl-1.1.1a\</opensslDir> | ||
<opensslOutDir>$(ExternalsDir)openssl-bin-1.1.1a\$(ArchName)\</opensslOutDir> |
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.
Save for the OpenSSL PR
PCbuild/python.props
Outdated
@@ -180,6 +189,7 @@ | |||
|
|||
<!-- The version and platform tag to include in .pyd filenames --> | |||
<PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag> | |||
<PydTag Condition="$(ArchName) == 'arm32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win_arm</PydTag> |
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.
Looking ahead to the future, do you think "ARM == ARM32" is going to hold for the long term? Or should we explicitly put win_arm32
now? I'd prefer to be more explicit, unless there's a lot of precedent for leaving the bitness out here.
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.
And I mean from a consumer point of view. Clearly Microsoft has decided that $(Platform)=='ARM'
already, but that doesn't directly follow that we have to do the same.
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'm glad you brought this up. There was some win_arm code already in cpython, but it looks like it was there to support Windows CE. That might be another reason to use win_arm32 here, to completely disambiguate it from both arm64 and arm on Windows CE.
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.
specifically the arm32 implementation currently relies on the following snippet in pc/pyconfig.h
It looks like support for Windows CE has been removed but there's a few comments still lingering. If Windows CE is no longer supported then the PYD_PLATFORM_TAG will also need to be edited to match. There's a doc snippet in Doc/whatsnew/3.5.rst that says the platform tag for Windows on ARM is win_arm as well.
#elif defined(_M_ARM)
#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)")
#define PYD_PLATFORM_TAG "win_arm"
#else
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.
Comments should be addressed, except for the AdditionalDependencies one, because I haven't found a different way to get it to pull in any dependencies as there appears to be no defaults for ARM. Verified that it builds on x86 and x64 on my dev machine. edit: see comment above about AdditionalDependencies. I think this is ready to go unless you still have concerns. |
I think this is ready to merge. @zware - as the person who touches the build files second-most, any thoughts? |
Oh, except for the |
About |
Afraid not. Last time I tried both MSBuild and Visual Studio failed to handle the files properly without the items directly in there (a fairly subtle difference between parsing the unevaluated project file and the evaluated one). @paulmon - let's update that string to |
I searched for 'win-arm' 'win_arm' and 'arm' and only found one other place that looks like it needs changed to arm32. |
As long as we fix any others before making a stable release, it'll be fine to catch them later. But I suspect you're right and it's mostly inferred from the two places you've updated. |
These are the mechanical changes to Windows build files seperated from code changes.
The solution still builds.
Building of ctypes is disabled because the build will need to be refactored to work with libffi changes that use libffi sources from cpython-source-deps.
https://bugs.python.org/issue35976