Testing/Compilers
It is often useful to test building the Dæmon engine or the Unvanquished game with various compilers, and various compiler versions.
Different compilers may detect mistakes others may not, they may also implement different warnings helping to improve the code.
Different compilers may also trigger bugs, either bugs in the compiler itself, either bugs in our code that are only triggered with such compiler, and then we better know them in advance.
Note
Unless stated otherwise, the following instructions are written for Ubuntu 24.04 LTS Noble Numbat. For the Arm architectures, some of the given instructions are meant to work on Debian 12 Bookworm too.
For some installation instructions, gdebi
must be installed, if needed it can be installed this way:
sudo apt install -V gdebi-core
For convenience, the following instructions assume the user is using the Ubuntu 24.04 (Noble Numbat) Linux distribution. Instructions may be translatable to other distributions, but this choice makes easy to provide consistent instructions, and it is easy to install this distribution in a virtual machine if needed. It is actually a good idea to test things in a virtual machine or in a dedicated chroot anyway, especially because installing many compilers may bring a lot of dependencies and dedicating a specific environment for such task can be preferred by some people.
Note
The compiler paths have to be used this way with CMake (example with GCC 14):
cmake .. -DCMAKE_C_COMPILER=gcc14 -DCMAKE_CXX_COMPILER=g++14
When the compiler is a subcommand of a binary, the command and the subcommand must be separated with a semicolon and quoted (example with Zig CC and Zig C++):
cmake .. -DCMAKE_C_COMPILER='zig;cc' -DCMAKE_CXX_COMPILER='zig;c++'
Sometime a specific CMake toolchain file is required, in such case it is mentioned.
Contents
GCC
Ubuntu provides multiple GCC versions in their repositories. It's possible to install multiple versions of GCC at the same time. With Ubuntu 24.04 Noble, GCC 10, 11, 12, 13 and 14 are provided. Installing the C++ compiler also installs the related C compiler (as a dependency package). The package name is in the form g++-<version>
, for example g++-14
.
One can install all of them in one go:
sudo apt install -V g++-10 g++-11 g++-12 g++-13 g++-14
The GCC compiler paths will be (for example with GCC 14):
gcc-14 g++-14
Cross-platform GCC
Note
Architectures like armel
can only be used to build servers running native game code (exe or dll), clients will not be able to join online games.
Ubuntu provides GCC packages for cross-compiling to a various of architectures. The package name is in the form g++-<arch>-<system>-<libc>
, for example g++-arm-linux-gnueabihf
for the Linux 32-bit ARM with hard float libc (armhf
. On Ubuntu Noble, the provided GCC cross-compilers are different variants of GCC 13.
One can install GCC for amd64
, i686
, arm64
, armhf
, and armel
this way:
apt-get install g++-x86-64-linux-gnu g++-i686-linux-gnu g++-aarch64-linux-gnu g++-arm-linux-gnueabihf g++-arm-linux-gnueabi
The GCC compiler paths for amd64
, i686
, arm64
, armhf
, and armel
will be, in that order:
/usr/bin/x86_64-linux-gnu-gcc /usr/bin/x86_64-linux-gnu-g++
/usr/bin/i686-linux-gnu-gcc /usr/bin/i686-linux-gnu-g++
/usr/bin/aarch64-linux-gnu-gcc /usr/bin/aarch64-linux-gnu-g++
/usr/bin/arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-g++
/usr/bin/arm-linux-gnueabi-gcc /usr/bin/arm-linux-gnueabi-g++
MinGW
Note
The MinGW compilers have to be configured using CMake toolchain files, here for amd64
:
cmake .. -DCMAKE_TOOLCHAIN_FILE=../daemon/cmake/cross-toolchain-mingw64.cmake
or for i686
:
cmake .. -DCMAKE_TOOLCHAIN_FILE=../daemon/cmake/cross-toolchain-mingw32.cmake
Note
MinGW comes with two threading flavours, for building the Dæmon engine and the native Unvanquished game binaries we need to use the Posix threading flavour in order to be compatible with other libraries.
Ubuntu provides a version of MinGW to cross-compile Windows binaries on Linux for both amd64
and i686
architectures. Installing the C++ compiler also installs the related C compiler (as a dependency package). On Ubuntu 24.04 Noble, the provided MinGW is MinGW 13 (based on GCC 13).
Installing g++-mingw-w64
will install both gcc-mingw-w64-x86-64
and gcc-mingw-w64-i686
for 64-bit and 32-bit x86 (amd64
and i686
).
One can install MinGW and select Posix as default threading flavour this way:
sudo apt install g++-mingw-w64 sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix sudo update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
The GCC compiler paths for the amd64 architecture will be:
x86_64-w64-mingw32-gcc x86_64-w64-mingw32-g++
The GCC compiler paths for the i686 architecture will be:
i686-w64-mingw32-gcc i686-w64-mingw32-g++
Clang
Ubuntu provides some Clang versions in their repositories. It's possible to install multiple versions of Clang at the same time. With Ubuntu 22.04 Noble, Clang 14, 15, 16, 17, 18 are provided in the base packages, Clang 19 is proposed in updates. Installing the C compiler also installs the related C++ compiler (included within the same package). The package name is in the form clang-<version>
, for example clang-18
. The default Clang compiler in Ubuntu Noble is Clang 18 if you just install clang
.
One can install all of them in one go:
sudo apt install -V clang-14 clang-15 clang-16 clang-17 clang-18 clang-19
The Clang compiler paths will be (for example with Clang 19):
clang-19 clang++-19
Upstream Clang
The LLVM project provides a dedicated repository apt.llvm.org providing multiple versions of Clang. For Ubuntu 22.04 Noble, Clang 17, 18, 19 and 20 are provided. Each version is provided by a dedicated repository.
To set-up the LLVM 20 repository, one can do:
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \ | gpg --dearmor | sudo dd status=none of=/usr/share/keyrings/llvm-archive-keyring.gpg echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main' \ | sudo dd status=none of=/etc/apt/sources.list.d/llvm-20.list sudo apt update
Removing the version to the distribution string (llvm-toolchain-noble
in the .list
file makes possible to install the in-development Clang but it may replace the latest stable version because of them sharing the same major version number.
To install Clang 20, one can then do:
sudo apt install -V clang-20
The Clang compiler paths will be (for example with Clang 19):
clang-20 clang++-20
Here is an example of unified /etc/apt/sources.list.d/llvm.list
file that will provide multiple Clang versions at once:
deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-17 main deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main
Though, it can be preferred to not install clang versions from the LLVM Apt repository when the distribution provides it, as some distribution packages may require a specific LLVM version and versions may conflict (especially some Mesa packages). Since Ubuntu Noble already provides 14, 15, 16, 17, 18 and 19, here is a /etc/apt/sources.list.d/llvm.list
file that will provide the remaining Clang 10, 11, 12, 13 and 20:
deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/hirsute/ llvm-toolchain-hirsute-10 main deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/hirsute/ llvm-toolchain-hirsute-11 main deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/impish/ llvm-toolchain-impish-12 main deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/jammy/ llvm-toolchain-jammy-13 main deb [arch=amd64 signed-by=/usr/share/keyrings/llvm-archive-keyring.gpg] http://apt.llvm.org/noble/ llvm-toolchain-noble-20 main
The LLVM repositories for Ubuntu Hirsute and Impish are compatible with Ubuntu Noble.
This way it's possible to install all Clang from Clang 10 to 20 on Ubuntu Noble, some from the Ubuntu repositories, others from the LLVM repositories:
sudo apt install -V clang-10 clang-11 clang-12 clang-13 clang-14 clang-15 clang-16 clang-17 clang-18 clang-19 clang-20
Intel ICC and ICX
ICC is the historical official Intel compiler, it is not based on GCC, neither on Clang, and as such brings some interests. Development stopped in 2023, and ICX is said to be preferred, but ICC being very different while still being very recent keeps the interest alive.
ICX is the new official Intel compiler, it is based on Clang, and may be based on a more recent version than the one available in the stock Ubuntu.
They are both part of the Intel OneAPI repository.
It's possible to install multiple versions of ICC and ICX at the same time.
To set-up the Intel OneAPI repository, one can do:
wget -qO- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \ | gpg --dearmor | sudo dd status=none of=/usr/share/keyrings/oneapi-archive-keyring.gpg echo 'deb [signed-by=/usr/share/keyrings/intel-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main' \ | sudo dd status=none of=/etc/apt/sources.list.d/oneapi.list sudo apt-get update
To install the latest ICX, one can do:
sudo apt install -V intel-oneapi-compiler-dpcpp-cpp
To install the latest ICC, one can do:
sudo apt install -V intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
This will also install an ICX version from 2023.
The ICC compiler paths will be (example with ICC 2023.2.4):
/opt/intel/oneapi/compiler/2023.2.4/linux/bin/intel64/icc /opt/intel/oneapi/compiler/2023.2.4/linux/bin/intel64/ipc
The ICX compiler paths will be (latest
can be replaced with an explicit version string):
/opt/intel/oneapi/compiler/latest/linux/bin/icx /opt/intel/oneapi/compiler/latest/linux/bin/icpx
AMD AOCC
AOCC is the official AMD compiler, it is based on Clang, and may be based on a more recent version than the one available in the stock Ubuntu. It's possible to install multiple versions of AOCC at the same time. The packages are meant to work on both Ubuntu and Debian.
There is no repository, and one should accept an EULA before using it. The latest download is always listed on this page:
Here follows the link to the EULA and the instructions for AOCC 5.0.0:
wget https://download.amd.com/developer/eula/aocc/aocc-5-0/aocc-compiler-5.0.0_1_amd64.deb sudo gdebi aocc-compiler-aocc-compiler-5.0.0_1_amd64.deb
The compiler paths will be:
/opt/AMD/aocc-compiler-5.0.0/bin/clang /opt/AMD/aocc-compiler-5.0.0/bin/clang++
Arm armclang
Arm Compiler for Linux or armclang
is one of the official Arm compilers.
There is no repository, and one should accept an EULA before using it. The latest download is always listed on this page:
Here is the EULA at the time of the version 24.10.1:
It's possible to install multiple versions of ArmClang at the same time.
Packages for Ubuntu 20.04 Focal Fossa are known to work on Debian Bookworm too. They should work on Ubuntu Noble too, so even if packages for Ubuntu Noble are provided, the following instructions should work on both Ubuntu, Ubuntu-based Armbian, Raspberry PI OS (Debian-based) and Debian-based Armbian.
To install ArmClang 24.10.1 on Ubuntu or Debian one can do:
wget https://developer.arm.com/-/cdn-downloads/permalink/Arm-Compiler-for-Linux/Version_24.10.1/arm-compiler-for-linux_24.10.1_Ubuntu-20.04_aarch64.tar tar xf arm-compiler-for-linux_24.10.1_Ubuntu-20.04_aarch64.tar cd cd arm-compiler-for-linux_24.10.1_Ubuntu-20.0 ./arm-compiler-for-linux_24.10.1_Ubuntu-20.04.sh --accept --save-packages-to packages cd packages gdebi gcc-14.2.0_Ubuntu-20.04.deb gdebi arm-linux-compiler-24.10.1_Ubuntu-20.04.deb
The ArmClang paths will be:
/opt/arm/arm-linux-compiler-24.10.1_Ubuntu-20.04/bin/armclang /opt/arm/arm-linux-compiler-24.10.1_Ubuntu-20.04/bin/armclang++
The first version number is the Clang one, the second version number is the Ubuntu one, so for example ArmClang 23.10 for Ubuntu 22.04 would have those paths:
/opt/arm/arm-linux-compiler-23.10_Ubuntu-22.04/bin/armclang /opt/arm/arm-linux-compiler-23.10_Ubuntu-22.04/bin/armclang++
ArmClang 24.10.1 is based on LLVM 19.1.0.
ArmClang also comes provides some GCC (and requires it to be installed), it is unknown what it is for. At the time of ArmClang 24.10.1, GCC is on version 14.2.0:
/opt/arm/gcc-14.2.0_Ubuntu-20.04/bin/gcc /opt/arm/gcc-14.2.0_Ubuntu-20.04/bin/g++
For some unknown reasons ArmClang selects system's GCC instead, so maybe the provided GCC is only there for systems not installing upstream GCC, despite being a required dependency.
Zig CC
Zig a compiler for the Zig language and provides C and C++ compilers featuring some interesting abilities to cross compile for different platforms or systems.
Zig doesn't provide any Debian package or repository but an Ubuntu Snap or a tarball of prebuilt binaries.
Installing Zig with Snap
To download and install Zig using Snap on Ubuntu one can do:
sudo snap install zig --classic --beta
The cc
and c++
commands are subcommands of the zig
binary.
For example one can do this to print the version of the Zig C compiler: zig cc -v
, or to print the help for Zig C++ compiler: zig cc --help
.
To use Zig compilers, CMake has to be configured this way:
cmake .. -DCMAKE_C_COMPILER='zig;cc' -DCMAKE_CXX_COMPILER='zig;c++'
Installing Zig with the tarball
Alternatively, to download and unpack Zig 0.13.0 one can do:
https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz tar xf zig-linux-x86_64-0.13.0.tar.xz
The zig
binary will be found as zig-linux-x86_64-0.13.0/zig
.
One can add the zig
binaries to the current PATH
environment variable this way:
export PATH="${PATH}:$(realpath zig-linux-x86_64-0.13.0)"
This setting is not permanent and will only be kept for the current shell.
When using an absolute path to the zig binary, for example /opt/zig-linux-x86_64-0.13.0/zig
, the CMake command line would be:
cmake .. \ -DCMAKE_C_COMPILER='/opt/zig-linux-x86_64-0.13.0/zig;cc' \ -DCMAKE_CXX_COMPILER='/opt/zig-linux-x86_64-0.13.0/zig;c++'
Note
If you get this error:In file included from /usr/include/bits/errno.h:26: /usr/include/linux/errno.h:1:10: fatal error: 'asm/errno.h' file not found 1 | #include <asm/errno.h> | ^~~~~~~~~~~~~
You may try this workaround:
sudo ln -s /usr/include/asm-generic /usr/include/asm
Apple Clang
Apple Clang can of course be tested on macOS, but it can also be tested on Linux using Darling.
On macOS, Apple Clang is the default compiler, so nothing special has to be done to use it.