Testing/Compilers
It often be 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 only triggers with such compiler, and then we better know them in advance.
For convenience, the following instructions assume the user is using the Ubuntu 24.04 Noble Linux distribution. Instructions may be translatable to other distributions, but this choice makes easy to provide consistent instructions, and this distribution provides easy way to install it as 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 an actual dedicated system for such task can be preferred by some.
Contents
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
Note
For some installation instructions, gdebi
must be installed, if needed it can be installed this way:
sudo apt install -V gdebi-core
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
MinGW
Ubuntu provides a version of MinGW to cross-compile Windows binaries on Linux. Ubuntu provides MinGW packages for compiling amd64 and i686 binaries. MinGW comes with two flavours, for the Dæmon engine we need the Posix one. 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).
One can install MinGW and select Posix as default 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. Installing the C compiler also installs the related C++ compiler (within the same package). The package name is in the form `clang-<version>`, for example `clang-18`.
One can install all of them in one go:
sudo apt install -V clang-14 clang-15 clang-16 clang-17 clang-18
The Clang compiler paths will be (for example with Clang 18):
clang-18 clang++-18
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 and 19 are provided. Each versions is provided by a dedicated repository.
To set-up the LLVM 19 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-19 main' \ | sudo dd status=none of=/etc/apt/sources.list.d/llvm-19.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 19, one can then do:
sudo apt install -V clang-19
The Clang compiler paths will be (for example with Clang 19):
clang-19 clang++-19
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
Intel ICC and ICX
ICC is the historic 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.
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 4.2.0:
wget https://download.amd.com/developer/eula/aocc/aocc-4-2/aocc-compiler-4.2.0_1_amd64.deb sudo gdebi aocc-compiler-4.2.0_1_amd64.deb
The compiler paths will be:
/opt/AMD/aocc-compiler-4.2.0/bin/clang /opt/AMD/aocc-compiler-4.2.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.04:
It's possible to install multiple versions of ArmClang at the same time.
Packages for Ubuntu 22.04 Jammy can be installed on Ubuntu 24.04 Noble.
To install ArmClang 24.04 on Ubuntu 24.04 one can do:
wget https://developer.arm.com/-/cdn-downloads/permalink/Arm-Compiler-for-Linux/Version_24.04/arm-compiler-for-linux_24.04_Ubuntu-22.04_aarch64.tar tar xf arm-compiler-for-linux_24.04_Ubuntu-22.04_aarch64.tar cd arm-compiler-for-linux_24.04_Ubuntu-22.04 ./arm-compiler-for-linux_24.04_Ubuntu-22.04.sh --accept --save-packages-to packages cd packages gdebi gcc-13.2.0_Ubuntu-22.04.deb gdebi arm-linux-compiler-24.04_Ubuntu-22.04.deb
The ArmClang paths will be:
/opt/arm/arm-linux-compiler-24.04_Ubuntu-22.04/bin/armclang /opt/arm/arm-linux-compiler-24.04_Ubuntu-22.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 on Ubuntu 20.04 would have those paths:
/opt/arm/arm-linux-compiler-23.10_Ubuntu-20.04/bin/armclang /opt/arm/arm-linux-compiler-23.10_Ubuntu-20.04/bin/armclang++
ArmClang 24.04 is based on LLVM 18.1.1.
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.04, GCC is on version 13.2.0:
/opt/arm/gcc-13.2.0_Ubuntu-22.04/bin/gcc /opt/arm/gcc-13.2.0_Ubuntu-22.04/bin/g++
For some unknown reasons ArmClang selects system's GCC 12 instead, so maybe the provided GCC is only there for systems not installing upstream GCC, despite being a required dependency.
Zig CC
Apple Clang
Apple Clang can of course be tested on macOS, but it can also be tested on Linux using Darling.