Skip to content

Cross Compiling for Debian Bullseye (11.x) aarch64 with V8 8.x

Günter Obiltschnig edited this page Dec 31, 2022 · 1 revision

This article describes how to cross-compile macchina.io EDGE for a Debian Bullseye 64-bit ARM (arm64) target.

Prerequisites

A Debian Stretch host system (VM) with the following packages installed:

  • git
  • build-essential
  • libssl-dev
  • python
  • crossbuild-essential-arm64

Preparing the Host System

First we need to prepare the package manager to install packages required for cross-compiling. For example, the OpenSSL headers and libraries must be available for the arm64 architecture.

$ sudo dpkg --add-architecture arm64
$ sudo apt-get update

Install the essential packages for building the host tools:

$ sudo apt-get install build-essential libssl-dev python3 python-is-python3

Install the packages required for cross-compiling:

$ sudo apt-get install crossbuild-essential-arm64
$ sudo apt-get install libssl-dev:arm64

Building macchina.io

Get macchina.io Sources from GitHub

$ git clone https://github.com/macchina-io/macchina.io.git

Build the Host Tools

This will build the tools (e.g., BundleCreator) required for building macchina.io.

$ cd macchina.io
$ make -s -j8 hosttools

This takes a couple of minutes. Note: Depending on the number of CPU cores you have on your build machine, adjust the -j8 argument accordingly.

Build for Target

In order to build for the target, a build configuration file must be used. You can find various build configuration files in platform/build/config. The build configuration for an ARM64 target running Debian Bullseye is called X-Debian-Bullseye-ARM64.

The POCO_CONFIG environment (or Makefile) variable should contain the name of the build configuration to use. Therefore, we run:

$ POCO_CONFIG=X-Debian-Bullseye-ARM64 make -s -j8 DEFAULT_TARGET=shared_release

to build macchina.io for the target. The DEFAULT_TARGET=shared_release argument instructs the build system to build the release executables only. If omitted, the build system would build both debug and release executables.

Depending on build machine performance, this takes 20-30 minutes.

Create Tarball for Transfer to Target

To build a directory structure and tarball that can be easily transferred to the target device (e.g., via scp), use the install_runtime make target:

$ POCO_CONFIG=X-Debian-Bullseye-ARM64 make -s install_runtime INSTALLDIR=/home/admin/macchina_runtime

This will create the following directory structure:

macchina_runtime/
    lib/
        bundles/
    bin/
    etc/

Then, pack the macchina_runtime directory into a tarball:

$ tar cfz macchina_runtime.tgz /home/admin/macchina_runtime

Running macchina.io on the Target

Copy the tarball to the target (e.g., using scp) and expand it with:

$ tar xfz macchina_runtime.tgz

Before starting macchina.io, you have to set the LD_LIBRARY_PATH environment variable, so that the macchina.io shared libraries (both in the lib directory and in the codeCache) will be found.

$ export LD_LIBRARY_PATH=/path/to/macchina_runtime/lib:/path/to/macchina_runtime/bin/codeCache

You should also create the codeCache directory before you start macchina.io, so that the dynamic linker will find it. Otherwise, the first start of macchina.io may fail.

$ mkdir /path/to/macchina_runtime/bin/codeCache

Then you can start macchina.io:

$ /path/to/macchina_runtime/bin/macchina --config=/path/to/macchina_runtime/etc/macchina.properties