kvm-unit-tests on macOS

Cross-compiler with ELF support is required for build of kvm-unit-tests on macOS.

Building cross-compiler from source

A cross-compiler toolchain can be built from source using crosstool-ng. The latest released version of crosstool-ng can be installed using homebrew

$ brew install crosstool-ng

A case-sensitive APFS/HFS+ volume has to be created using Disk Utility as a build and installation directory for the cross-compiler. Please see Apple documentation for details.

Assuming the case-sensitive volume is named /Volumes/BuildTools, the cross-compiler can be built and installed there:

$ X_BUILD_DIR=/Volumes/BuildTools/ct-ng-build
$ X_INSTALL_DIR=/Volumes/BuildTools/x-tools
$ mkdir $X_BUILD_DIR
$ ct-ng -C $X_BUILD_DIR x86_64-unknown-linux-gnu

Once compiled, the cross-compiler can be used to build the tests:

$ ./configure --cross-prefix=$X_INSTALL_DIR/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-
$ make

Pre-built cross-compiler

x86_64-elf-gcc package in Homebrew provides pre-built cross-compiler but it fails to compile kvm-unit-tests.

Running the tests

GNU coreutils should be installed prior to running the tests:

$ brew install coreutils