Slicer for Ubuntu arm64

Notes on compilation efforts for compiling Slicer for arm64:

Problem: VTK does not compile.
Solution:

  • Set VTK_OPENGL_HAS_EGL and VTK_OPENGL_HAS_ES
  • In <SlicerDir>/SuperBuild/External_VTK.cmake remove section that has -DModule_vtkGUISupportQtOpenGL:BOOL=ON in it
  • Edit QVTKOpenGLNativeWidget.cxx to use QOpenGLExtraFunctions instead of QOpenGLFunctions_3_2_Core

Problem: CTKAPPLAUNCHER is a download of amd64
Solution: Overwrite executable <Slicer-build>/CTKAPPLAUNCHER/bin/CTKAppLauncher with compiled executable from <Slicer-build>/CTKAppLauncherLib-build/bin/CTKAppLauncher

1 Like

Thanks for the report.

Could you describe here:

  • how you setup the build environment / toolchain ?
  • in addition of the change described above, build options used ?

This would help improve the build system.

To enable others to reproduce the build, do you think a docker image could be added to https://github.com/Slicer/SlicerBuildEnvironment/ ?

For sure, I’m expect it to be a slog, so this post is just for my notes as well as other googlers. Build options are all default unless a note is present in the main post.

To enable others to reproduce the build, do you think a docker image could be added to GitHub - Slicer/SlicerBuildEnvironment: A repository of scripts to set up a Slicer build environment. ?

Of course, how can I create a docker image?

Platform is FriendlyDesktop for NanoPC-T4.

Details:
Qt
Qt 5.10.0, provided in image.
qtchooser cleaned up:

pi@NanoPC-T4:~/devel/S4R$ qtchooser -qt=5.10 -print-env
QT_SELECT=“5.10”
QTTOOLDIR=“/usr/local/Trolltech/Qt-5.10.0-rk64one-sdk/bin”
QTLIBDIR=“/usr/local/Trolltech/Qt-5.10.0-rk64one/lib”

CMake
CMake 3.14.1 built from source (make && sudo make install)

GCC

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/7/lto-wrapper
Target: aarch64-linux-gnu
Configured with: …/src/configure -v --with-pkgversion=‘Ubuntu/Linaro 7.3.0-27ubuntu1~18.04’ --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu/Linaro 7.3.0-27ubuntu1~18.04)

Problem: CTK fails to build
Issue:

  • QtOpenGLTimeMonitor is not available under GL ES2 (at least in 5.10.0)

PythonQt version under Slicer does not support OpenGL ES build.

Solution:
Workaround by manually removing non-OpenGL ES classes. Future fix upgrade PythonQt version.

Once I built Slicer on arm32. Please see here. I 'm surprised it 's so hard for arm64. Unfortunately, I don 't have any arm64 machine and can 't join in this effort. Good luck.

With OpenGL (ES) hardware acceleration?

I doubt it, didn 't even pay attention to that. The build was not usable in practice, VTK GPU rendering did not work, even the slices were not shown in the views. I 'll try a new build paying attention to OpenGL ES some weekend.

Yeah, that’s the kicker. I’m looking to produce a usable Slicer, hopefully.

For VTK, enable VTK_USE_SYSTEM_PNG, otherwise VTK builds libpng with NEON enabled.

Problem: libarchive fails to build
Solution: Add #include <sys/sysmacros.h> to <SlicerBuild>/LibArchive/libarchive/archive_pack_dev.c

Problem: zlib relocation errors
Solution: where present, use system zlib (via CMAKE_USE_SYSTEM_ZLIB, USE_BUILTIN_ZLIB, Slicer_USE_SYSTEM_zlib depending on project)

Problem: python-setuptools fails

/opt/dev/S4R/python-install/bin/PythonSlicer: 5: /opt/dev/S4R/python-install/bin/PythonSlicer: Syntax error: Unterminated quoted string

CMake Error at /opt/dev/S4/CMake/ExternalProjectForNonCMakeProject.cmake:104 (message):
  python-setuptools: bootstrap step failed with exit code '2'.

Solution: Just another effect of CTKAppLauncher being the wrong architecture. See solution for CTKAPPLAUNCHER is a download of amd64

Problem : CTK fails to build
Issue:
PythonQt version under Slicer does not support OpenGL ES build.

  • QtOpenGLTimeMonitor is not available under GL ES2 (at least in 5.10.0)

Solution :
In CTK/CMakeExternals/PythonQt.cmake:34, remove gui from the list of wrapped modules

Hint:
Set OpenGL_GL_PREFERENCE:STRING="GLVND" in PythonQt project

Notes:
My setup did not have Qt Designer built, so I disabled designer plugins in CTK.

Problem
SimpleITK compilation crashes (NanoPC-T4, 4GB ram, gcc 7.3)

Solution:
Disable SimpleITK
Possibly cross-compile if it’s a memory issue?

Disable all designer plugins for Slicer if designer is not available. -DSlicer_BUILD_QT_DESIGNER_PLUGINS:BOOL=OFF

Slicer wants vtkGUISupportQtOpenGL, see if workaround vtkGUISupportQt is enough

Just for information

I rebuilt Slicer on Odroid XU4 with a 32-bit ARM CPU. A clean build succeeded with this cmake config line :

#! Setting -DADDITIONAL_CXX_FLAGS -DCMAKE_C_FLAGS -DCMAKE_CXX_FLAGS is not sufficient.
#! export is required for python to build here
export CFLAGS=-I/usr/include/tirpc
export CXXFLAGS=-I/usr/include/tirpc; cmake -DSlicer_VTK_VERSION_MAJOR:INT=8 -DQt5_DIR:PATH=/usr/lib/cmake/Qt5 -DSlicer_USE_PYTHONQT_WITH_OPENSSL:BOOL=0 -DBUILD_TESTING:BOOL=0 -DCMAKE_BUILD_TYPE:STRING=Release -DSlicer_USE_SimpleITK:BOOL=0 …/Slicer

With a quick test, only one functionality is missing : viewing slices in 2D slice views ! With or without mali drivers. Volume rendering, segmention models show up. Slice data is visible in the 3D view, in the zoom preview (bottom left) but not in the RYG views. Would it really be an OpenGL ES problem ? I won’t insist of course, was just an experiment.

slicer_odroid_xu4

Does that machine/setup have OpenGL drivers for the Mali? If so, that simplifies things tremendously. Otherwise your setup is doing Mesa (software) rendering.

Looks like no, OpenGL ES 3.1. Would you check your VTK build to see if VTK_USE_OPENGL_ES is ON?