Skip to content

Enable PGO and native builds for aarch64-unknown-linux-gnu #484

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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
35 changes: 17 additions & 18 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,23 @@ jobs:
name: pythonbuild
path: build

- name: Download images
uses: actions/download-artifact@v4
with:
pattern: image-*
path: build
merge-multiple: true
# - name: Download images
# uses: actions/download-artifact@v4
# with:
# pattern: image-*
# path: build
# merge-multiple: true

# - name: Load Docker Images
# run: |
# for f in build/image-*.tar.zst; do
# echo "decompressing $f"
# zstd -d --rm ${f}
# done
# for f in build/image-*.tar; do
# echo "loading $f"
# docker load --input $f
# done

- name: Cache downloads
uses: actions/cache@v4
Expand All @@ -227,18 +238,6 @@ jobs:
${{ matrix.target_triple }}-${{ hashFiles('pythonbuild/downloads.py')}}
${{ matrix.target_triple }}-

- name: Load Docker Images
run: |
for f in build/image-*.tar.zst; do
echo "decompressing $f"
zstd -d --rm ${f}
done

for f in build/image-*.tar; do
echo "loading $f"
docker load --input $f
done

- name: Build
if: ${{ ! matrix.dry-run }}
run: |
Expand Down
9 changes: 4 additions & 5 deletions ci-runners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ depot-ubuntu-22.04:
platform: linux
free: false

# TODO: Enable this runner to perform native builds for aarch64
# depot-ubuntu-22.04-arm:
# arch: aarch64
# platform: linux
# free: false
depot-ubuntu-22.04-arm:
arch: aarch64
platform: linux
free: false

depot-macos-latest:
arch: x86_64
Expand Down
6 changes: 2 additions & 4 deletions ci-targets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ linux:
- "3.14"
build_options:
- debug
- noopt
- lto
- pgo+lto
build_options_conditional:
- options:
- freethreaded+debug
- freethreaded+noopt
- freethreaded+lto
- freethreaded+pgo+lto
minimum-python-version: "3.13"

armv7-unknown-linux-gnueabi:
Expand Down
10 changes: 5 additions & 5 deletions cpython-unix/targets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,11 @@ aarch64-unknown-linux-gnu:
- '3.12'
- '3.13'
- '3.14'
docker_image_suffix: .cross
host_cc: /usr/bin/x86_64-linux-gnu-gcc
host_cxx: /usr/bin/x86_64-linux-gnu-g++
target_cc: /usr/bin/aarch64-linux-gnu-gcc
target_cxx: /usr/bin/aarch64-linux-gnu-g++
# docker_image_suffix: .aarch64
host_cc: clang
host_cxx: clang++
target_cc: clang
target_cxx: clang++
needs:
- autoconf
- bdb
Expand Down
39 changes: 35 additions & 4 deletions pythonbuild/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import pathlib
import tarfile
import time

import docker # type: ignore
import jinja2
Expand Down Expand Up @@ -109,6 +110,25 @@ def run_container(client, image):
container = client.containers.run(
image, command=["/bin/sleep", "86400"], detach=True
)

# Check if container is actually running
for _ in range(10):
container.reload()

if container.status in ("created", "starting"):
time.sleep(1)
continue

if container.status == "running":
break

state = container.attrs.get("State", {})
exit_code = state.get("ExitCode")
error = state.get("Error", "")
raise RuntimeError(
f"Container failed to start (status {container.status}) with exit code {exit_code}: {error}"
)

try:
yield container
finally:
Expand All @@ -119,10 +139,21 @@ def run_container(client, image):
def container_exec(container, command, user="build", environment=None):
# docker-py's exec_run() won't return the exit code. So we reinvent the
# wheel.
create_res = container.client.api.exec_create(
container.id, command, user=user, environment=environment
)

try:
create_res = container.client.api.exec_create(
container.id, command, user=user, environment=environment
)
except Exception as exc:
if container.status != "running":
state = container.attrs.get("State", {})
exit_code = state.get("ExitCode")
error = state.get("Error", "")
raise RuntimeError(
f"Container is not running (status {container.status}) with exit code {exit_code}: {error}"
) from exc
else:
raise

exec_output = container.client.api.exec_start(create_res["Id"], stream=True)

for chunk in exec_output:
Expand Down
Loading