Nuxi CloudABI for Arch Linux

Not long after the port of CloudABI to the Linux kernel became stable, community members Mara Bos and Maarten de Vries did all the necessary work to package CloudABI for Arch Linux, making it the first Linux distribution to have easily installable support for CloudABI. Nuxi would like to thank Mara and Maarten for their contributions!

This document explains how to install all the necessary software on Arch Linux to both develop and run CloudABI programs.

1. Installing a C and C++ compiler for CloudABI

A complete toolchain for CloudABI based on LLVM's Clang and GNU Binutils can be obtained by installing the cloudabi-toolchain package from the Arch Linux User Repository (AUR). This package installs a copy of the toolchain for every architecture supported by CloudABI, thus making it very easy to cross compile software for other hardware:

$ yaourt -S cloudabi-toolchain ... $ ls /usr/bin/*-unknown-cloudabi-{cc,c++} /usr/bin/aarch64-unknown-cloudabi-c++ /usr/bin/aarch64-unknown-cloudabi-cc /usr/bin/x86_64-unknown-cloudabi-c++ /usr/bin/x86_64-unknown-cloudabi-cc

2. Accessing the CloudABI Ports Collection

The toolchain provided by Arch Linux does not ship with any code that has been cross compiled for CloudABI, meaning it cannot be used to build CloudABI applications on its own. Cross compiled libraries and tools are instead provided by the CloudABI Ports Collection. Software that is part of the CloudABI Ports Collection is automatically packaged for a variety of systems, including Arch Linux's pacman.

The CloudABI Ports Collection can be accessed by adding both a repository snippet and a public signing key to pacman's configuration. This can be accomplished by running the following commands:

$ sudo tee -a /etc/pacman.conf << EOF [cloudabi-ports] Server = EOF $ sudo pacman-key -r 0DA51B8531344B15 $ pacman-key -f 0DA51B8531344B15 pub rsa4096/31344B15 2015-09-10 [SC] [expires: 2020-09-08] Key fingerprint = 1EAC 388A 6C0D 6572 1A22 3743 0DA5 1B85 3134 4B15 uid [ unknown] CloudABI Ports Collection for Arch Linux <> uid [ unknown] CloudABI Ports Collection for Debian <> sub rsa4096/3E5E7A05 2015-09-10 [E] [expires: 2020-09-08] $ sudo pacman-key --lsign-key 0DA51B8531344B15 $ sudo pacman -Sy

It typically makes sense to at least install the standard C++ runtime environment package, so that it is possible to compile C and C++ applications that depend on just core C, C++ and POSIX interfaces:

$ sudo pacman -S x86_64-unknown-cloudabi-cxx-runtime Packages (6) x86_64-unknown-cloudabi-cloudlibc-0.22-1 x86_64-unknown-cloudabi-compiler-rt-3.8.0-1 x86_64-unknown-cloudabi-libcxx-3.8.0-1 x86_64-unknown-cloudabi-libcxxabi-3.8.0-1 x86_64-unknown-cloudabi-libunwind-3.8.0-1 x86_64-unknown-cloudabi-cxx-runtime-1.0-1 :: Proceed with installation? [Y/n] y

A full list of packages provided by the CloudABI Ports Collection can be obtained by running the following command:

$ pacman -Sl cloudabi-ports cloudabi-ports aarch64-unknown-cloudabi-boost 1.60.0-4 cloudabi-ports aarch64-unknown-cloudabi-buddy 2.4-5 cloudabi-ports aarch64-unknown-cloudabi-bzip2 1.0.6-5 cloudabi-ports aarch64-unknown-cloudabi-c-runtime 1.0-1 ...

3. Executing CloudABI applications

Our eventual goal is to provide support for CloudABI in the form of a kernel module that can be used in combination with a stock Linux kernel. Unfortunately we still depend on a fair number of local changes to the kernel that need to be upstreamed first, meaning that support for CloudABI is currently only available in the form of a modified Linux kernel with integrated CloudABI support.

Though manually compiling a kernel is normally a tedious job, the AUR also provides a package to easily build and install it from source:

$ yaourt -S cloudabi-linux ... $ sudo grub-mkconfig -o /boot/grub/grub.cfg $ sudo reboot

Keep in mind that building the kernel requires a significant amount of disk space. If the system's /tmp is small, it may be necessary to provide an alternative build directory to yaourt using the --tmp command line flag. As your system is now using a custom kernel, packages that provide external kernel modules should be replaced by their DKMS versions. After installing the kernel and rebooting, CloudABI executables can be executed directly:

$ cat hello.c #include <stdio.h> int main(void) { dprintf(1, "Hello, world\n"); } $ x86_64-unknown-cloudabi-cc -o hello hello.c $ ./hello Hello, world

The AUR also provides the cloudabi-utils package that contains the cloudabi-run utility. This tool can be used to spawn CloudABI applications safely, ensuring that no resources are accidentally leaked into the process. The shell commands below show how cloudabi-run can be used to execute the CloudABI test suite. Please refer to cloudabi-run's manual page for more examples.

$ yaourt -S cloudabi-utils ... $ mkdir tmp-unittest $ cloudabi-run /usr/x86_64-unknown-cloudabi/bin/cloudlibc-unittests << EOF %TAG !,2015:cloudabi/ --- tmpdir: !file path: tmp-unittest logfile: !fd stdout nthreads: !!int 8 EOF