Skip to content

Commit 5f3dd47

Browse files
kongchen1992meta-codesync[bot]
authored andcommitted
{Continuous Integration} Wheels - Add Linux aarch64 build matrix leg (facebookresearch#387)
Summary: X-link: https://github.com/facebookexternal/projectaria_private_libs/pull/35 Pull Request resolved: facebookresearch#387 Explanation: Adds a native Linux aarch64 wheel to the `projectaria_tools` build matrix using GitHub's `ubuntu-24.04-arm` runner (free for public repos, so no QEMU emulation is needed). Three changes make the aarch64 build work: 1. `build_third_party_libs/install_manylinux_deps.sh` — two fixes, both of which also apply to x86_64: - The aarch64 `manylinux2014` image does not enable EPEL by default, so `gtest-devel` and `xxhash-devel` fail to resolve and `yum install` aborts the script. Add `yum install -y epel-release` first; this is a no-op on the x86_64 image, which already has EPEL enabled. - `libjpeg-turbo` 3.0.1 declares a `cmake_minimum_required` below 3.5, which CMake 4.x rejects outright. The `manylinux2014` image bumped CMake to 4.4 on both arches, so pass the CMake-suggested `-DCMAKE_POLICY_VERSION_MINIMUM=3.5`. 2. `setup.py` — Ocean's NEON RGB-conversion code passes signed vector types to unsigned intrinsics (for example `int8x16_t` into `vget_low_u8`). Clang accepts this by default, which is why Ocean's Android and iOS builds are unaffected, but GCC on Linux aarch64 rejects it and asks for `-flax-vector-conversions`. Add that flag to `CMAKE_CXX_FLAGS`, gated on Linux aarch64 so x86_64 and macOS builds are untouched. 3. `.github/workflows/build-wheels-and-deploy.yml` and `.github/workflows/test-for-build-wheels.yml` — add `ubuntu-24.04-arm` to the OS matrix, extend the ffmpeg-install step's condition to cover it, and add a build step with `CIBW_ARCHS: aarch64`. The step relies on `cibuildwheel`'s default `auditwheel repair`, which vendors the third-party shared libraries into the wheel and retags it `manylinux2014_aarch64`. NVDEC is not wired up on this leg because `libnvcuvid` has no aarch64 build. Reproducibility: Built and tested end-to-end in native `linux/arm64` containers. The resulting `manylinux2014_aarch64` wheel installs into a clean `python:3.11-slim` image — one with none of the build-time libraries present — and passes all 115 Python tests in the repository, including the H.265 random-access test that reads `data/gen2/aria_gen2_unit_test_sequence_with_pframe.vrs`. See the test plan for the full breakdown. Reviewed By: SeaOtocinclus, nrraina Differential Revision: D114764549 fbshipit-source-id: efb3c83e7fe5f55edced50a66dac3456f47a0c22
1 parent 11c1f6d commit 5f3dd47

4 files changed

Lines changed: 48 additions & 5 deletions

File tree

.github/workflows/build-wheels-and-deploy.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
strategy:
9090
fail-fast: false
9191
matrix:
92-
os: [macos-14, ubuntu-latest] # macos-14 is macSilicon
92+
os: [macos-14, ubuntu-latest, ubuntu-24.04-arm] # macos-14 = macSilicon; ubuntu-24.04-arm = native Linux aarch64
9393
python-version: ["3.10", "3.11", "3.12"]
9494
include: # Customize cibuildwheel python version to build
9595
- python-version: "3.10"
@@ -119,7 +119,7 @@ jobs:
119119
python -m pip install --upgrade pip
120120
python -m pip install cibuildwheel==2.21.0
121121
- name: Install ffmpeg dependency lib
122-
if: ${{ (matrix.os == 'macos-14') || (matrix.os == 'ubuntu-latest') }}
122+
if: ${{ (matrix.os == 'macos-14') || (matrix.os == 'ubuntu-latest') || (matrix.os == 'ubuntu-24.04-arm') }}
123123
shell: bash
124124
run: |
125125
./build_third_party_libs/build_ffmpeg_linuxunix.sh
@@ -147,6 +147,20 @@ jobs:
147147
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair --exclude libcuda.so.1 --exclude libnvcuvid.so.1 -w {dest_dir} {wheel}"
148148
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
149149
CIBW_ARCHS: "x86_64"
150+
- name: Build wheels for CPython
151+
if: ${{ matrix.os == 'ubuntu-24.04-arm' }}
152+
shell: bash
153+
run: |
154+
CMAKE_BUILD_PARALLEL_LEVEL=4 python -m cibuildwheel --output-dir dist
155+
env:
156+
CIBW_BUILD_VERBOSITY: 3
157+
CIBW_BUILD: ${{ matrix.cibw_build }}
158+
CIBW_BEFORE_BUILD_LINUX: bash build_third_party_libs/install_manylinux_deps.sh
159+
# Unlike the x86_64 leg above, NVDEC is not enabled here: NVIDIA ships
160+
# libnvcuvid for x86_64 only, so there is nothing for the CUDA env vars
161+
# or the auditwheel exclusions to act on.
162+
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
163+
CIBW_ARCHS: "aarch64"
150164
- name: Build wheels for CPython
151165
if: matrix.os == 'windows-2022'
152166
shell: bash

.github/workflows/test-for-build-wheels.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
strategy:
9292
fail-fast: false
9393
matrix:
94-
os: [macos-14, ubuntu-latest] # macos-14 is macSilicon
94+
os: [macos-14, ubuntu-latest, ubuntu-24.04-arm] # macos-14 = macSilicon; ubuntu-24.04-arm = native Linux aarch64
9595
python-version: ["3.10", "3.11", "3.12"]
9696
include:
9797
- python-version: "3.10"
@@ -120,7 +120,7 @@ jobs:
120120
python -m pip install --upgrade pip
121121
python -m pip install cibuildwheel==2.21.0
122122
- name: Install ffmpeg dependency lib
123-
if: ${{ (matrix.os == 'macos-14') || (matrix.os == 'ubuntu-latest') }}
123+
if: ${{ (matrix.os == 'macos-14') || (matrix.os == 'ubuntu-latest') || (matrix.os == 'ubuntu-24.04-arm') }}
124124
shell: bash
125125
run: |
126126
./build_third_party_libs/build_ffmpeg_linuxunix.sh
@@ -148,6 +148,20 @@ jobs:
148148
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "auditwheel repair --exclude libcuda.so.1 --exclude libnvcuvid.so.1 -w {dest_dir} {wheel}"
149149
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
150150
CIBW_ARCHS: "x86_64"
151+
- name: Build wheels for CPython
152+
if: ${{ (matrix.os == 'ubuntu-24.04-arm') }}
153+
shell: bash
154+
run: |
155+
CMAKE_BUILD_PARALLEL_LEVEL=4 python -m cibuildwheel --output-dir dist
156+
env:
157+
CIBW_BUILD_VERBOSITY: 3
158+
CIBW_BUILD: ${{ matrix.cibw_build }}
159+
CIBW_BEFORE_BUILD_LINUX: bash build_third_party_libs/install_manylinux_deps.sh
160+
# Unlike the x86_64 leg above, NVDEC is not enabled here: NVIDIA ships
161+
# libnvcuvid for x86_64 only, so there is nothing for the CUDA env vars
162+
# or the auditwheel exclusions to act on.
163+
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
164+
CIBW_ARCHS: "aarch64"
151165
- name: Build wheels for CPython
152166
if: matrix.os == 'windows-2022'
153167
shell: bash

build_third_party_libs/install_manylinux_deps.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /
2222

2323
# Install system deps
2424
# Toolchains
25+
# EPEL provides gtest-devel and xxhash-devel on manylinux2014_aarch64;
26+
# already enabled on the x86_64 image, so this is idempotent there.
27+
yum install -y epel-release
2528
yum install -y cmake git gtest-devel \
2629
lz4-devel libzstd-devel xxhash-devel libpng-devel libjpeg-turbo-devel wget
2730

@@ -34,9 +37,12 @@ cd /tmp; git clone https://github.com/fmtlib/fmt.git -b 10.2.1 \
3437
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DFMT_TEST=OFF .; make -j$thread install; rm -rf /tmp/fmt;
3538

3639
# Build lib jpeg turbo
40+
# libjpeg-turbo 3.0.1's cmake_minimum_required predates CMake 4.x's removal
41+
# of pre-3.5 policy compatibility; the manylinux2014 image (both arches) now
42+
# ships CMake 4.4+, so we opt into the CMake-suggested policy floor.
3743
cd /tmp && git clone https://github.com/libjpeg-turbo/libjpeg-turbo.git -b 3.0.1 \
3844
&& cd libjpeg-turbo \
39-
&& cmake -DCMAKE_BUILD_TYPE=Release -DWITH_JPEG8=1 -DCMAKE_INSTALL_DEFAULT_PREFIX=/usr .;make -j$thread install; rm -rf /tmp/libjpeg-turbo;
45+
&& cmake -DCMAKE_BUILD_TYPE=Release -DWITH_JPEG8=1 -DCMAKE_INSTALL_DEFAULT_PREFIX=/usr -DCMAKE_POLICY_VERSION_MINIMUM=3.5 .;make -j$thread install; rm -rf /tmp/libjpeg-turbo;
4046

4147
# Build Boost
4248
cd /tmp && git clone --recursive https://github.com/boostorg/boost.git -b boost-1.84.0 \

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import os
16+
import platform
1617
import re
1718
import subprocess
1819
import sys
@@ -64,6 +65,14 @@ def build_extension(self, ext):
6465
"-DCMAKE_POLICY_VERSION_MINIMUM=3.5",
6566
]
6667

68+
# Ocean's NEON RGB-conversion code mixes signed/unsigned vector types
69+
# in intrinsic calls (e.g. `int8x16_t` passed to `vget_low_u8`), which
70+
# Ocean's Android/iOS builds accept because Clang is permissive by
71+
# default. GCC on Linux aarch64 refuses the mismatch and requires
72+
# `-flax-vector-conversions` to allow it, matching Clang's behavior.
73+
if sys.platform.startswith("linux") and platform.machine() == "aarch64":
74+
cmake_args.append("-DCMAKE_CXX_FLAGS=-flax-vector-conversions")
75+
6776
# Note: env var uses "CUDA" (recognizable to users), CMake flag uses
6877
# "NVCODEC" (precise for build-system maintainers). Intentional.
6978
#

0 commit comments

Comments
 (0)