CMake Error when building ITKMontage wheel for aarch64

Hi,
I’m trying to compile and build an ITKMontage python3.9 wheel for aarch64 on a raspberry pi 4 using ITKPythonPackage as described here Prerequisites — ITKPythonPackage documentation

I’ve checked out the release branch of ITKPythonPackage and set the following env variables

MANYLINUX_VERSION=_2_28
TARGET_ARCH=aarch64
NO_SUDO=1 #This seems to avoid that the GPG error, shown in the output, causes any problems

Everything seems to work fine all the way until it’s time to run the cmake where it complains that the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER isn’t correct.

Running “which gcc” and “which g++” in the container shows that toolset 11 is installed instead of 12 as in error output

/opt/rh/gcc-toolset-11/root/usr/bin/g++
/opt/rh/gcc-toolset-11/root/usr/bin/gcc

I’ve tried to set the CMAKE_C_COMPILER and CMAKE_CXX_COMPILER variables to the correct paths, both with export and as -D options without any noticable difference.

Any ideas what I’m doing wrong?
Also, has anyone built an ITKMontage wheel for aarch64 and can confirm that it’s possible?

Here’s the full output from running
./ITKPythonPackage/scripts/dockcross-manylinux-build-module-wheels.sh cp39
from the ITKMontage root.

Install aarch64 architecture emulation tools to perform build for ARM platform
{
  "supported": [
    "linux/arm64",
    "linux/amd64",
    "linux/riscv64",
    "linux/ppc64le",
    "linux/s390x",
    "linux/386",
    "linux/mips64le",
    "linux/mips64",
    "linux/arm/v7",
    "linux/arm/v6"
  ],
  "emulators": [
    "python3.11",
    "qemu-i386",
    "qemu-mips64",
    "qemu-mips64el",
    "qemu-ppc64le",
    "qemu-riscv64",
    "qemu-s390x",
    "qemu-x86_64"
  ]
}
AlmaLinux 8 - BaseOS                            2.5 MB/s | 4.1 MB     00:01    
AlmaLinux 8 - AppStream                         4.4 MB/s |  10 MB     00:02    
AlmaLinux 8 - Extras                             20 kB/s |  19 kB     00:00    
AlmaLinux 8 - PowerTools                        2.0 MB/s | 2.2 MB     00:01    
Last metadata expiration check: 0:00:01 ago on Sun 18 Feb 2024 10:31:12 PM UTC.
Dependencies resolved.
================================================================================
 Package       Architecture     Version                   Repository       Size
================================================================================
Installing:
 sudo          aarch64          1.9.5p2-1.el8_9           baseos          1.0 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 1.0 M
Installed size: 4.5 M
Downloading Packages:
sudo-1.9.5p2-1.el8_9.aarch64.rpm                2.1 MB/s | 1.0 MB     00:00    
--------------------------------------------------------------------------------
Total                                           931 kB/s | 1.0 MB     00:01     
AlmaLinux 8 - BaseOS                            3.3 MB/s | 3.4 kB     00:00    
Importing GPG key 0xC21AD6EA:
 Userid     : "AlmaLinux <packager@almalinux.org>"
 Fingerprint: E53C F5EF 91CE B0AD 1812 ECB8 51D6 647E C21A D6EA
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux
Key imported successfully
Import of key(s) didn't help, wrong key(s)?
Public key for sudo-1.9.5p2-1.el8_9.aarch64.rpm is not installed. Failing package is: sudo-1.9.5p2-1.el8_9.aarch64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
Error: GPG check FAILED
Collecting ninja==1.11.1
  Downloading ninja-1.11.1-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.7/155.7 kB 2.1 MB/s eta 0:00:00
Collecting scikit-build==0.17.6
  Downloading scikit_build-0.17.6-py3-none-any.whl (84 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 84.3/84.3 kB 3.3 MB/s eta 0:00:00
Requirement already satisfied: wheel>=0.32.0 in /opt/_internal/cpython-3.9.15/lib/python3.9/site-packages (from scikit-build==0.17.6->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (0.38.4)
Requirement already satisfied: setuptools>=42.0.0 in /opt/_internal/cpython-3.9.15/lib/python3.9/site-packages (from scikit-build==0.17.6->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (65.6.0)
Collecting distro
  Downloading distro-1.9.0-py3-none-any.whl (20 kB)
Requirement already satisfied: packaging in /opt/_internal/cpython-3.9.15/lib/python3.9/site-packages (from scikit-build==0.17.6->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (21.3)
Requirement already satisfied: tomli in /opt/_internal/cpython-3.9.15/lib/python3.9/site-packages (from scikit-build==0.17.6->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (2.0.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /opt/_internal/cpython-3.9.15/lib/python3.9/site-packages (from packaging->scikit-build==0.17.6->-r /ITKPythonPackage/requirements-dev.txt (line 2)) (3.0.9)
Installing collected packages: ninja, distro, scikit-build
Successfully installed distro-1.9.0 ninja-1.11.1 scikit-build-0.17.6
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

[notice] A new release of pip available: 22.3.1 -> 24.0
[notice] To update, run: /opt/python/cp39-cp39/bin/python -m pip install --upgrade pip
++++ dirname /ITKPythonPackage/scripts/internal/manylinux-build-module-wheels.sh
+++ cd /ITKPythonPackage/scripts/internal
+++ pwd
++ script_dir=/ITKPythonPackage/scripts/internal
++ [[ 1 -eq 0 ]]
++ PYBINARIES=()
++ for version in "$@"
++ PYBINARIES+=(/opt/python/*${version}*/bin)
++ case $(uname -m) in
+++ uname -m
++ ARCH=aarch64
++ export PATH=/work/tools/doxygen-1.8.16/bin:/opt/rh/gcc-toolset-11/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/work/tools/doxygen-1.8.16/bin:/opt/rh/gcc-toolset-11/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ case $(uname -m) in
+++ uname -m
++ ARCH=aarch64
++ type doxygen
++ type ninja
++ test '!' -d ninja
++ pushd ninja
/work/ninja /work
++ git checkout release
Already on 'release'
Your branch is up to date with 'origin/release'.
++ cmake -Bbuild-cmake -H.
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:6 (project):
  The CMAKE_C_COMPILER:

    /opt/rh/gcc-toolset-12/root/usr/bin/cc

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:6 (project):
  The CMAKE_CXX_COMPILER:

    /opt/rh/gcc-toolset-12/root/usr/bin/c++

  is not a full path to an existing compiler tool.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "/work/ninja/build-cmake/CMakeFiles/CMakeOutput.log".
See also "/work/ninja/build-cmake/CMakeFiles/CMakeError.log".

Hi @John_Bergelin ,

Setting the ITK_PACKAGE_VERSION for ITK 5.3.0 may help provide the right build. See,

2 Likes

Thank you for replying, @matt.mccormick.

I pivoted a bit and went for a cross-compilation on an ubuntu 20.04 amd64 machine instead. It seems like the raspberry pi had some storage issues while extracting the ITKPythonBuild tar file, so I’m not 100% sure that the whole folder structure actually was there when I tried building it.

This time I used the master branch with these variables set:

export MANYLINUX_VERSION=_2_28
export TARGET_ARCH=aarch64
export ITKPYTHONPACKAGE_TAG=master
export ITK_PACKAGE_VERSION=v5.3.0
export ITK_MODULE_NO_CLEANUP=TRUE

and then ran
./ITKPythonPackage/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh cp39

And everything worked, except for when sudo was being installed in the manylinux docker from the script manylinux-aarch64-build-module-wheels.sh, throwing this error:

Importing GPG key 0xC21AD6EA:
 Userid     : "AlmaLinux <packager@almalinux.org>"
 Fingerprint: E53C F5EF 91CE B0AD 1812 ECB8 51D6 647E C21A D6EA
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux
Key imported successfully
Import of key(s) didn't help, wrong key(s)?
Public key for sudo-1.9.5p2-1.el8_9.aarch64.rpm is not installed. Failing package is: sudo-1.9.5p2-1.el8_9.aarch64
 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
Error: GPG check FAILED

The GPG warning can be resolved by importing the new key with this command
rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux

soruce: AlmaLinux OS - Forever-Free Enterprise-Grade Operating System

So, the wheel is now built and I can run it on the target machine! Thanks for pointing me in the right direction.


As a side note, I also tried a fresh build on the release branch of ITKPythonPackage which also seems to work fine (with the GPG fix) all the way until the very end, where the auditwheel_whitelist_monkeypatch.py fails with this output

++ uname -m
+ for whl in dist/*linux*$(uname -m).whl
+ /opt/python/cp39-cp39/bin/python /ITKPythonPackage/scripts/internal/auditwheel_whitelist_monkeypatch.py repair dist/itk_montage-0.8.1-cp39-cp39-linux_aarch64.whl -w /work/dist/ --whitelist ''
Traceback (most recent call last):
  File "/ITKPythonPackage/scripts/internal/auditwheel_whitelist_monkeypatch.py", line 8, in <module>
    from auditwheel.policy import _POLICIES as POLICIES
ImportError: cannot import name '_POLICIES' from 'auditwheel.policy' (/opt/python/cp39-cp39/lib/python3.9/site-packages/auditwheel/policy/__init__.py)

master branch has this fix, which resolves the _POLICIES error.

2 Likes