CPULLVM is built and tested on Linux Ubuntu and Windows.
Please refer to the "Host Platforms" section in the README for details.
CPULLVM requires the following software to be installed:
- Software required by LLVM on Linux or software required by LLVM on Windows depending on your platform of choice
- Meson
- Meson v1.9.0 or later must be used to support building picolibc with eld
- Ninja
- Git
- CPULLVM releases use clang and clang-cl to build on Linux and Windows, respectively. Alternative toolchains may be used, but are not tested.
Library testing requires:
Testing with QEMU (using QEMU's system emulation)
is enabled by default, but can be disabled using the -DENABLE_QEMU_TESTING=OFF CMake
option if testing is not required or QEMU is not installed.
A relatively recent version of QEMU is required to support the latest RISC-V extensions. CPULLVM currently builds and tests with QEMU v10.1.3.
The riscv32im_xqci_ilp32 library-test variant requires an Xqci and Xqccmp enabled QEMU build. Clone and build the QEMU Xqci fork, and ensure the binary is available as qemu-system-riscv32-xqci in your PATH:
git clone --branch feature/xqci https://github.com/quic/qemu.git qemu-xqci
cd qemu-xqci
./configure --target-list=riscv32-softmmu
ninja
# CPULLVM expects this executable name
mv "<path-to>/qemu-system-riscv32" "<path-to>/qemu-system-riscv32-xqci"
Refer to the Xqci json file for the flags that need to be passed to QEMU.
CPULLVM may contain patches with changes that are pending or unmerged in the upstream projects it uses.
Generally, these patches are automatically applied, except for llvm-project which must be
patched manually. The below command assumes you are in the cpullvm-toolchain directory:
python3 qualcomm-software/cmake/patch_repo.py --method apply qualcomm-software/patches/llvm-project
Other projects (eld, picolibc, etc.) are checked out and patched automatically. If you prefer, you can check out and patch the repos manually and use those, see our developer documentation.
The commands below can be used to build a toolchain containing Picolibc libraries for all currently-enabled embedded variants.
Note
Not all runtimes may be built on all hosts. CPULLVM's musl and musl-embedded libraries are only expected to be built on Linux hosts. Windows runtimes (compiler-rt, profile libraries) are expected to be built on Windows hosts. Please refer to our workflows and build scripts for examples on how our toolchains are built and packaged on different hosts.
The commands in the sections below assume you are in the cpullvm-toolchain/qualcomm-software directory.
All dependencies are assumed to be present in your PATH.
First, populate the CC and CXX environment variables to tell CMake which toolchain to use:
Linux:
export CC=clang
export CXX=clang++
Windows:
$env:CC = 'clang-cl'
$env:CXX = 'clang-cl'
Then, the toolchain can be configured directly with CMake and built:
mkdir build
cd build
cmake .. -GNinja -DFETCHCONTENT_QUIET=OFF
ninja llvm-toolchain
To run all LLVM, eld, and library tests together, the below command may be used:
ninja check-all-llvm-toolchain
Tests can also be run in smaller subsets, please refer to our developer documentation for more information.
ninja install-llvm-toolchain
To create a zip or tar.xz file as appropriate for the platform:
ninja package-llvm-toolchain
CPULLVM can be configured and built in a variety of ways, including changing the default libc to use for embedded, building Linux libraries, and building only a subset of library variants. These (and other) options are documented in part in our developer documentation.