Skip to content

Latest commit

 

History

History
124 lines (91 loc) · 4.68 KB

File metadata and controls

124 lines (91 loc) · 4.68 KB

Building from source

Host platforms

CPULLVM is built and tested on Linux Ubuntu and Windows.

Please refer to the "Host Platforms" section in the README for details.

Prerequisites

CPULLVM requires the following software to be installed:

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.

Patching

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.

Building

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.

Configuring and building the toolchain

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

Testing the 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.

Installing the toolchain

ninja install-llvm-toolchain

Packaging the toolchain

To create a zip or tar.xz file as appropriate for the platform:

ninja package-llvm-toolchain

Advanced usage

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.