xref: /kvm-unit-tests/README.macOS.md (revision 22f2901a0ea2dd5b5a32e51c51135e84a3da38ee)
1# kvm-unit-tests on macOS
2
3Cross-compiler with ELF support is required for build of kvm-unit-tests on
4macOS.
5
6## Building cross-compiler from source
7
8A cross-compiler toolchain can be built from source using crosstool-ng. The
9latest released version of
10[crosstool-ng](https://github.com/crosstool-ng/crosstool-ng) can be installed
11using [homebrew](https://brew.sh)
12```
13$ brew install crosstool-ng
14```
15
16A case-sensitive APFS/HFS+ volume has to be created using Disk Utility as a
17build and installation directory for the cross-compiler. Please [see Apple
18documentation](https://support.apple.com/guide/disk-utility/dsku19ed921c/mac)
19for details.
20
21Assuming the case-sensitive volume is named /Volumes/BuildTools, the
22cross-compiler can be built and installed there:
23```
24$ X_BUILD_DIR=/Volumes/BuildTools/ct-ng-build
25$ X_INSTALL_DIR=/Volumes/BuildTools/x-tools
26$ mkdir $X_BUILD_DIR
27$ ct-ng -C $X_BUILD_DIR x86_64-unknown-linux-gnu
28$ ct-ng -C $X_BUILD_DIR build CT_PREFIX=$X_INSTALL_DIR
29```
30
31Once compiled, the cross-compiler can be used to build the tests:
32```
33$ ./configure --cross-prefix=$X_INSTALL_DIR/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-
34$ make
35```
36
37## Pre-built cross-compiler
38
39x86_64-elf-gcc package in Homebrew provides pre-built cross-compiler but it
40fails to compile kvm-unit-tests.
41
42## Running the tests
43
44GNU coreutils should be installed prior to running the tests:
45```
46$ brew install coreutils
47```
48