Skip to content
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

Enable arm64 for MSVC on Windows #5811

Merged
merged 2 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions winbuild/build.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Download and install:
* `CMake 3.12 or newer <https://cmake.org/download/>`_
(also available as Visual Studio component C++ CMake tools for Windows)

* `NASM <https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D>`_
* x86/x64: `NASM <https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D>`_

Any version of Visual Studio 2017 or newer should be supported,
including Visual Studio 2017 Community, or Build Tools for Visual Studio 2019.
Expand All @@ -42,8 +42,8 @@ behaviour of ``build_prepare.py``:
If ``PYTHON`` is unset, the version of Python used to run
``build_prepare.py`` will be used. If only ``PYTHON`` is set,
``EXECUTABLE`` defaults to ``python.exe``.
* ``ARCHITECTURE`` is used to select a ``x86`` or ``x64`` build. By default,
uses same architecture as the version of Python used to run ``build_prepare.py``.
* ``ARCHITECTURE`` is used to select a ``x86``, ``x64`` or ``ARM64``build.
By default, uses same architecture as the version of Python used to run ``build_prepare.py``.
is used.
gaborkertesz-linaro marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@nulano nulano Dec 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to have disappered in a force-push. Is there any reason not to include it anymore?

Suggested change
is used.
is used. Note that the ``ARM64`` build is not fully supported and some dependencies may fail to build. Pull requests are welcome.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I didn't mention that LittleCMS is the last dependency and VS2019 update is merged, just not released yet:
mm2/Little-CMS#288
Patch to use VS2019 project: gaborkertesz-linaro@0af6042

So if either VS2019 project is accepted or VS2017 will be updated for ARM64 as well and LCMS2 is released, all external dependencies will be enabled.
Probably this pull request can be blocked until updated LCMS2 is released.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lcms2 2.13 has now been released.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up, I'm going to rebase my changes and run the tests!

* ``PILLOW_BUILD`` can be used to override the ``winbuild\build`` directory
path, used to store generated build scripts and compiled libraries.
Expand Down
19 changes: 12 additions & 7 deletions winbuild/build_prepare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import platform
import shutil
import struct
import subprocess
Expand Down Expand Up @@ -93,6 +94,7 @@ def cmd_msbuild(
architectures = {
"x86": {"vcvars_arch": "x86", "msbuild_arch": "Win32"},
"x64": {"vcvars_arch": "x86_amd64", "msbuild_arch": "x64"},
"ARM64": {"vcvars_arch": "x86_arm64", "msbuild_arch": "ARM64"},
}

header = [
Expand Down Expand Up @@ -223,21 +225,21 @@ def cmd_msbuild(
"filename": "lcms2-2.13.tar.gz",
"dir": "lcms2-2.13",
"patch": {
r"Projects\VC2017\lcms2_static\lcms2_static.vcxproj": {
r"Projects\VC2019\lcms2_static\lcms2_static.vcxproj": {
# default is /MD for x86 and /MT for x64, we need /MD always
"<RuntimeLibrary>MultiThreaded</RuntimeLibrary>": "<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>", # noqa: E501
# retarget to default toolset (selected by vcvarsall.bat)
"<PlatformToolset>v141</PlatformToolset>": "<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>", # noqa: E501
"<PlatformToolset>v142</PlatformToolset>": "<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>", # noqa: E501
# retarget to latest (selected by vcvarsall.bat)
"<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>": "<WindowsTargetPlatformVersion>$(WindowsSDKVersion)</WindowsTargetPlatformVersion>", # noqa: E501
"<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>": "<WindowsTargetPlatformVersion>$(WindowsSDKVersion)</WindowsTargetPlatformVersion>", # noqa: E501
}
},
"build": [
cmd_rmdir("Lib"),
cmd_rmdir(r"Projects\VC2017\Release"),
cmd_msbuild(r"Projects\VC2017\lcms2.sln", "Release", "Clean"),
cmd_rmdir(r"Projects\VC2019\Release"),
cmd_msbuild(r"Projects\VC2019\lcms2.sln", "Release", "Clean"),
cmd_msbuild(
r"Projects\VC2017\lcms2.sln", "Release", "lcms2_static:Rebuild"
r"Projects\VC2019\lcms2.sln", "Release", "lcms2_static:Rebuild"
),
cmd_xcopy("include", "{inc_dir}"),
],
Expand Down Expand Up @@ -490,7 +492,10 @@ def build_pillow():
python_dir = os.environ.get("PYTHON")
python_exe = os.environ.get("EXECUTABLE", "python.exe")
architecture = os.environ.get(
"ARCHITECTURE", "x86" if struct.calcsize("P") == 4 else "x64"
"ARCHITECTURE",
"ARM64"
if platform.machine() == "ARM64"
else ("x86" if struct.calcsize("P") == 4 else "x64"),
)
build_dir = os.environ.get("PILLOW_BUILD", os.path.join(winbuild_dir, "build"))
sources_dir = ""
Expand Down