Building LLVM 23.1.1 from llvm.org on Discoverer CPU cluster

Building LLVM 23.1.1 from llvm.org on Discoverer CPU cluster

Overview

This document describes the build procedure for the LLVM 23.1.1 source distribution on an AMD EPYC 7H12 (Zen 2, x86_64) based CPU-only compute cluster (Discoverer CPU cluster). The build is performed from source using a shell-based recipe that loads Environment Modules, configures LLVM with CMake and Ninja, and installs the resulting tool chain into a versioned prefix.

The recipe and build log are published at:

https://gitlab.discoverer.bg/vkolev/recipes/-/blob/main/llvm/23/llvmorg-23.1.1.recipe https://gitlab.discoverer.bg/vkolev/recipes/-/blob/main/llvm/23/llvmorg-23.1.1.log

Build environment and approach

The build runs on AMD EPYC 7H12 compute nodes with the x86_64-unknown-linux-gnu host triple. The nodes are CPU-only, with no GPU, CUDA, ROCm or corresponding device files. The locale is set to LANG=C and LC_ALL=C. Build parallelism is set to 24 compile jobs, 8 link jobs and 8 TableGen jobs, with link jobs capped because LTO linking is memory-intensive.

Bootstrap tool chain

LLVM 23.1.1 is bootstrapped with the previously installed LLVM 23.1.0 tool chain. The C and C++ compilers are clang and clang++, the linker is lld, and the C++ standard library is libc++. This bootstrap approach ensures the new release is compiled by a Clang that already understands the LLVM codebase and produces code consistent with the intended tool chain.

Dependencies

The recipe loads the Discoverer-specific Environment Modules llvm-rt/23/23.1.0, cmake/4/4.4.3, ninja/1/1.13.1, swig/4/4.3.1, libedit/3/20250104-3.1-llvm, llvm/23/23.1.0, binutils/2/2.47-gold, zlib-ng-compat/2/2.3.3-llvm, zstd/1/1.5.7 and xz/5/5.8.3-llvm. SWIG is required for generating the LLDB Python bindings. libedit and curses provide command-line editing in LLDB. Lua is linked statically for LLDB scripting support, and xz/liblzma is used for compressed debug symbol handling. Python 3.11.5 is selected by probing python3.14 down to python3.8 because LLVM requires Python 3.8 or newer while the system python3 is older. PyYAML is installed into a local build directory for the libc header generator, which is driven during the runtimes build.

Environment hygiene

Inherited include and library paths from the bootstrap LLVM modulefile are cleared before configuration. This prevents the bootstrap libc++ headers from shadowing the headers being built in the runtimes sub-builds, which would otherwise produce errors such as unknown type name 'ldiv_t'. Required include and library paths are passed explicitly on the CMake command line.

Compiler and linker flags

The build type is Release. Full link-time optimisation is enabled with -flto=full for both compilation and linking, and -Wl,--lto-O3 requests aggressive LTO optimisation from the linker. C++ compilation uses -stdlib=libc++. The linker type is set to LLD. RTTI is enabled, assertions are enabled, and pedantic warnings are disabled, so the build remains suitable for diagnostic work without excessive warning noise.

Enabled projects and their functionality

The projects enabled for the build are clang, clang-tools-extra, flang, lld, lldb, mlir, polly and bolt, configured through -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;flang;lld;lldb;mlir;polly;bolt".

Clang is the C, C++ and Objective-C compiler frontend. It translates source code into LLVM intermediate representation and is the primary compiler produced by the build. Clang-tools-extra adds supplementary tooling such as clang-tidy for static analysis, clang-format for source formatting, scan-build for analyser-driven bug finding, and clang-doc for documentation generation.

Flang is the Fortran frontend. It provides Fortran language support for LLVM and appends flang-rt to the runtimes automatically, so the Fortran runtime is built without needing to be listed explicitly.

LLD is the LLVM linker. It provides a drop-in replacement for GNU ld and gold, supports ELF, COFF and Mach-O formats, and is used here both as the build linker and as part of the installed tool chain.

LLDB is the LLVM debugger. It provides breakpoints, expression evaluation, disassembly and process control. The build enables Python scripting through SWIG-generated bindings, Lua scripting through a static Lua library, editline and curses support for the command-line interface, and libxml2 for plist processing.

MLIR is the multi-level intermediate representation framework. It provides infrastructure for defining custom intermediate representations, transformations and code generation pipelines beyond the core LLVM IR. The recipe applies a patch for a missing generated-header dependency in MLIRRewrite to avoid race failures at high parallelism.

Polly is the polyhedral loop optimiser. It applies polyhedral techniques to loop nests for advanced optimisation of memory access patterns and parallelism.

BOLT is the post-link optimiser. It optimises the compiled binary after linking by reordering code and data to improve instruction cache and branch prediction behaviour. The recipe computes BOLT_TARGETS_TO_BUILD explicitly from the intersection of BOLT-supported targets and the selected X86 backend to avoid stale cache values from previous configurations.

Enabled runtimes

The runtimes enabled for the build are libcxx, libcxxabi, libunwind, compiler-rt, libc and openmp, configured through -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind;compiler-rt;libc;openmp". Flang appends flang-rt automatically.

libcxx is the C++ standard library implementation used with libc++-based Clang builds. libcxxabi provides low-level C++ runtime support such as exception handling and dynamic cast. libunwind provides stack unwinding support. compiler-rt supplies compiler runtime libraries including sanitiser runtimes and builtins. libc is the LLVM C library implementation, which requires PyYAML during its header generation step. openmp provides the OpenMP runtime for shared-memory parallelism.

Disabled components

The cross-project-tests project is disabled because it is a testing framework rather than a tool chain component. The pstl project is no longer present in the LLVM 23 monorepo. libclc is omitted from the default runtimes because it implements the OpenCL C device builtins library and targets GPUs only; the build nodes are CPU-only and lack AMDGPU, NVPTX or SPIR-V targets. GPU backends are therefore not included in LLVM_TARGETS_TO_BUILD, which is set to X86 only.

Patch for MLIRRewrite generated-header dependencies

Before configuration, the recipe applies llvmorg-23.1.1-mlir-rewrite-pdl-incgen.patch. This patch adds missing TableGen-generated header dependencies for MLIRRewrite in LLVM 23.1.0/23.1.1. Without the patch, high parallelism can cause compilation of FrozenRewritePatternSet.cpp to fail because generated PDL and PDLInterp headers are not guaranteed to be present.

Build time

CMake configuration completed in 32.9 seconds, Ninja file generation took 17.6 seconds, and the build produced 10,112 targets. LZMA compression support in LLDB was disabled because the expected symbols were not present in the static liblzma.a build. Tree-sitter syntax highlighting and OCaml bindings were disabled because their dependencies were not found.

Installed capabilities

The installed LLVM 23.1.1 tool chain provides a complete C, C++ and Objective-C compiler through Clang, Fortran support through Flang, and linking through LLD. Developers can debug applications with LLDB, using either Python or Lua scripting for automation. Static analysis and source-level tooling are available through clang-tidy, clang-format, scan-build and the other utilities in clang-tools-extra. Advanced optimisation is available through Polly for polyhedral loop optimisation and BOLT for post-link binary optimisation. MLIR provides infrastructure for building and transforming custom intermediate representations. The runtimes include libc++ for the C++ standard library, compiler-rt for sanitiser and built-in support, libc for C library functionality, and OpenMP for shared-memory parallelism. Users access the tool chain through the Environment Module system.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux