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

WIP: Windows arm64 builds - help needed #93

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
vcvars:
- 'vcvars32.bat'
- 'vcvars64.bat'
- 'vcvarsamd64_arm64.bat'
profile:
- 'static-noopt'
- 'shared-pgo'
Expand Down Expand Up @@ -128,3 +129,4 @@ jobs:
with:
name: 'cpython-install-only-${{ matrix.version }}'
path: cpython-*.tar.gz

45 changes: 38 additions & 7 deletions cpython-windows/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ def hack_props(
suffix = b"x64"
elif arch == "win32":
suffix = None
elif arch == "arm64":
suffix = b"arm64" # TODO check it
else:
raise Exception("unhandled architecture: %s" % arch)

Expand Down Expand Up @@ -1442,9 +1444,11 @@ def build_openssl_for_arch(
elif arch == "amd64":
configure = "VC-WIN64A"
prefix = "64"
elif arch == "arm64":
configure = "VC-WIN64-ARM"
prefix = "arm64" # TODO check it ???
else:
print("invalid architecture: %s" % arch)
sys.exit(1)
raise Exception("unhandled architecture: %s" % arch)

# The official CPython OpenSSL builds hack ms/uplink.c to change the
# ``GetModuleHandle(NULL)`` invocation to load things from _ssl.pyd
Expand Down Expand Up @@ -1508,6 +1512,7 @@ def build_openssl(

root_32 = td / "x86"
root_64 = td / "x64"
root_arm64 = td / "arm64"

if arch == "x86":
root_32.mkdir()
Expand All @@ -1531,13 +1536,26 @@ def build_openssl(
profile,
jom_archive=jom_archive,
)
elif arch == "arm64":
root_64.mkdir()
build_openssl_for_arch(
perl_path,
"arm64",
openssl_archive,
nasm_archive,
root_arm64,
profile,
jom_archive=jom_archive,
)
else:
raise ValueError("unhandled arch: %s" % arch)
raise Exception("unhandled architecture: %s" % arch)

install = td / "out"

if arch == "x86":
shutil.copytree(root_32 / "install" / "32", install / "openssl" / "win32")
elif arch == "arm64":
shutil.copytree(root_arm64 / "install" / "arm64", install / "openssl" / "arm64")
else:
shutil.copytree(root_64 / "install" / "64", install / "openssl" / "amd64")

Expand Down Expand Up @@ -1641,9 +1659,14 @@ def build_libffi(
if arch == "x86":
args.append("-x86")
artifacts_path = ffi_source_path / "i686-pc-cygwin"
else:
elif arch == "arm64":
args.append("-arm64")
artifacts_path = ffi_source_path / "aarch64-w64-cygwin"
elif arch == "amd64":
args.append("-x64")
artifacts_path = ffi_source_path / "x86_64-w64-cygwin"
else:
raise Exception("unhandled architecture: %s" % arch)

subprocess.run(args, env=env, check=True)

Expand Down Expand Up @@ -2001,8 +2024,11 @@ def build_cpython(
elif arch == "x86":
build_platform = "win32"
build_directory = "win32"
elif arch == "arm64":
build_platform = "arm64"
build_directory = "arm64"
else:
raise ValueError("unhandled arch: %s" % arch)
raise Exception("unhandled architecture: %s" % arch)

with tempfile.TemporaryDirectory(prefix="python-build-") as td:
td = pathlib.Path(td)
Expand All @@ -2029,7 +2055,7 @@ def build_cpython(
# We need all the OpenSSL library files in the same directory to appease
# install rules.
if not static:
openssl_arch = {"amd64": "amd64", "x86": "win32"}[arch]
openssl_arch = {"amd64": "amd64", "x86": "win32"}[arch] # TODO
openssl_root = td / "openssl" / openssl_arch
openssl_bin_path = openssl_root / "bin"
openssl_lib_path = openssl_root / "lib"
Expand Down Expand Up @@ -2434,9 +2460,14 @@ def main():
if os.environ.get("Platform") == "x86":
target_triple = "i686-pc-windows-msvc"
arch = "x86"
else:
elif os.environ.get("Platform") == "arm64":
target_triple = "aarch64-pc-windows-msvc"
arch = "arm64"
elif os.environ.get("Platform") == "x64":
target_triple = "x86_64-pc-windows-msvc"
arch = "amd64"
else:
raise Exception("unhandled architecture: %s" % os.environ.get("Platform"))

# TODO need better dependency checking.
openssl_archive = BUILD / ("openssl-%s-%s.tar" % (target_triple, args.profile))
Expand Down