Quill for AArch64

The quill tool is great for managing accounts on air-gapped systems. It took me a while to figure out how compile it for an AArch64 (or ARM64) system. Hopefully writing some key steps will result in less pain next time around.

Some of these incantations were gleaned from searches that led to the usual suspects like StackOverflow and Reddit.

Best to start with a docker image of ubuntu:hirsuite, even though I’m running jammy, for two reasons. Firstly, my target system only has glibc 2.33 so I need an older system. Secondly, during my struggles, I grew so frustrated that I began copying around C compiler binaries in system directories. I somehow replaced my cross-compiler with one which produced native binaries, sending me down blind alleys for hours. A hermetically sealed docker container limits the damage from such tantrums.

Once in the docker instance (e.g. podman run -it --rm ubuntu:hirsute):

# apt update
# apt install curl perl make gcc-aarch64-linux-gnu gcc git
# git clone https://github.com/dfinity/quill
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# source $HOME/.cargo/env
# rustup target add aarch64-unknown-linux-gnu

We need a certain config:

# cat > $HOME/.cargo/config << EOF
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
# curl https://www.openssl.org/source/openssl-1.1.1n.tar.gz | tar xz
# cd openssl-1.1.1n
# export ARCH=aarch64
# export MACHINE=unknown
# export CC=aarch64-linux-gnu-gcc
# ./config shared
# make

I don’t know exactly what ARCH and MACHINE do, but the above works for me.

At last:

# cd ../quill-0.2.15
# export OPENSSL_LIB_DIR=`pwd`
# export OPENSSL_INCLUDE_DIR=`pwd`/include/
# export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
# export CC=gcc
# cargo build --release --target aarch64-unknown-linux-gnu

Now it’s ready to run! We can remove symbols to halve its size:

# aarch64-linux-gnu-strip target/aarch64-unknown-linux-gnu/release/quill