{"id":464,"date":"2026-09-10T14:20:12","date_gmt":"2026-09-10T13:20:12","guid":{"rendered":"https:\/\/hpcwithus.discoverer.bg\/?p=464"},"modified":"2026-09-10T14:20:12","modified_gmt":"2026-09-10T13:20:12","slug":"building-llvm-23-1-1-from-llvm-org-on-discoverer-cpu-cluster","status":"publish","type":"post","link":"https:\/\/hpcwithus.discoverer.bg\/?p=464","title":{"rendered":"Building LLVM 23.1.1 from llvm.org on Discoverer CPU cluster"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">Overview<\/h1>\n\n\n\n<p>This document describes the build procedure for the <a href=\"https:\/\/github.com\/llvm\/llvm-project\/releases\" data-type=\"link\" data-id=\"https:\/\/github.com\/llvm\/llvm-project\/releases\">LLVM 23.1.1 source distribution<\/a> on an AMD EPYC 7H12 (Zen 2, x86_64) based CPU-only compute cluster (<a href=\"https:\/\/discoverer.bg\" data-type=\"link\" data-id=\"https:\/\/discoverer.bg\">Discoverer CPU cluster<\/a>). The build is performed from source using a shell-based recipe that loads <a href=\"https:\/\/modules.readthedocs.io\/\" data-type=\"link\" data-id=\"https:\/\/modules.readthedocs.io\/\">Environment Modules<\/a>, configures LLVM with <a href=\"https:\/\/cmake.org\" data-type=\"link\" data-id=\"https:\/\/cmake.org\">CMake<\/a> and <a href=\"https:\/\/ninja-build.org\/\" data-type=\"link\" data-id=\"https:\/\/ninja-build.org\/\">Ninja<\/a>, and installs the resulting tool chain into a versioned prefix.<\/p>\n\n\n\n<p>The recipe and build log are published at:<\/p>\n\n\n\n<p><a href=\"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.recipe<\/a> <a href=\"https:\/\/gitlab.discoverer.bg\/vkolev\/recipes\/-\/blob\/main\/llvm\/23\/llvmorg-23.1.1.log\">https:\/\/gitlab.discoverer.bg\/vkolev\/recipes\/-\/blob\/main\/llvm\/23\/llvmorg-23.1.1.log<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Build environment and approach<\/h2>\n\n\n\n<p>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 <code>LANG=C<\/code> and <code>LC_ALL=C<\/code>. 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Bootstrap tool chain<\/h2>\n\n\n\n<p>LLVM 23.1.1 is bootstrapped with the previously installed LLVM 23.1.0 tool chain. The C and C++ compilers are <code>clang<\/code> and <code>clang++<\/code>, the linker is <code>lld<\/code>, and the C++ standard library is <code>libc++<\/code>. 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dependencies<\/h2>\n\n\n\n<p>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 <code>python3.14<\/code> down to <code>python3.8<\/code> because LLVM requires Python 3.8 or newer while the system <code>python3<\/code> is older. <a href=\"https:\/\/pypi.org\/project\/PyYAML\/\" data-type=\"link\" data-id=\"https:\/\/pypi.org\/project\/PyYAML\/\">PyYAML <\/a>is installed into a local build directory for the libc header generator, which is driven during the runtimes build.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Environment hygiene<\/h2>\n\n\n\n<p>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 <code>unknown type name 'ldiv_t'<\/code>. Required include and library paths are passed explicitly on the CMake command line.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Compiler and linker flags<\/h2>\n\n\n\n<p>The build type is <code>Release<\/code>. Full link-time optimisation is enabled with <code>-flto=full<\/code> for both compilation and linking, and <code>-Wl,--lto-O3<\/code> requests aggressive LTO optimisation from the linker. C++ compilation uses <code>-stdlib=libc++<\/code>. 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Enabled projects and their functionality<\/h2>\n\n\n\n<p>The projects enabled for the build are clang, clang-tools-extra, flang, lld, lldb, mlir, polly and bolt, configured through <code>-DLLVM_ENABLE_PROJECTS=\"clang;clang-tools-extra;flang;lld;lldb;mlir;polly;bolt\"<\/code>.<\/p>\n\n\n\n<p><a href=\"https:\/\/clang.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/clang.llvm.org\/\">Clang is the C, C++ and Objective-C compiler frontend<\/a>. 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.<\/p>\n\n\n\n<p><a href=\"https:\/\/flang.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/flang.llvm.org\/\">Flang is the Fortran frontend.<\/a> It provides Fortran language support for LLVM and appends <code>flang-rt<\/code> to the runtimes automatically, so the Fortran runtime is built without needing to be listed explicitly.<\/p>\n\n\n\n<p><a href=\"https:\/\/lld.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/lld.llvm.org\/\">LLD is the LLVM linker<\/a>. It provides a drop-in replacement for <a href=\"https:\/\/sourceware.org\/binutils\/docs\/ld\/\" data-type=\"link\" data-id=\"https:\/\/sourceware.org\/binutils\/docs\/ld\/\">GNU <code>ld<\/code><\/a> and <code><a href=\"https:\/\/llvm.org\/docs\/GoldPlugin.html\" data-type=\"link\" data-id=\"https:\/\/llvm.org\/docs\/GoldPlugin.html\">gold<\/a><\/code>, supports ELF, COFF and Mach-O formats, and is used here both as the build linker and as part of the installed tool chain.<\/p>\n\n\n\n<p><a href=\"https:\/\/lldb.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/lldb.llvm.org\/\">LLDB is the LLVM debugger<\/a>. It provides breakpoints, expression evaluation, disassembly and process control. The build enables Python scripting through <a href=\"https:\/\/www.swig.org\/\" data-type=\"link\" data-id=\"https:\/\/www.swig.org\/\">SWIG-generated bindings<\/a>, <a href=\"https:\/\/lua.org\/\" data-type=\"link\" data-id=\"https:\/\/lua.org\/\">Lua scripting<\/a> through a static Lua library, editline and curses support for the command-line interface, and libxml2 for plist processing.<\/p>\n\n\n\n<p><a href=\"https:\/\/mlir.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/mlir.llvm.org\/\">MLIR is the multi-level intermediate representation framework<\/a>. 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.<\/p>\n\n\n\n<p><a href=\"https:\/\/polly.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/polly.llvm.org\/\">Polly is the polyhedral loop optimiser<\/a>. It applies polyhedral techniques to loop nests for advanced optimisation of memory access patterns and parallelism.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/bolt\/README.md\" data-type=\"link\" data-id=\"https:\/\/github.com\/llvm\/llvm-project\/blob\/main\/bolt\/README.md\">BOLT is the post-link optimiser<\/a>. It optimises the compiled binary after linking by reordering code and data to improve instruction cache and branch prediction behaviour. The recipe computes <code>BOLT_TARGETS_TO_BUILD<\/code> explicitly from the intersection of BOLT-supported targets and the selected X86 backend to avoid stale cache values from previous configurations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Enabled runtimes<\/h2>\n\n\n\n<p>The runtimes enabled for the build are <a href=\"https:\/\/libcxx.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/libcxx.llvm.org\/\">libcxx<\/a>, <a href=\"https:\/\/libcxxabi.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/libcxxabi.llvm.org\/\">libcxxabi<\/a>, <a href=\"https:\/\/github.com\/llvm\/llvm-project\/tree\/main\/libunwind\" data-type=\"link\" data-id=\"https:\/\/github.com\/llvm\/llvm-project\/tree\/main\/libunwind\">libunwind<\/a>, <a href=\"https:\/\/compiler-rt.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/compiler-rt.llvm.org\/\">compiler-rt<\/a>, <a href=\"https:\/\/libc.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/libc.llvm.org\/\">libc<\/a> and <a href=\"https:\/\/openmp.llvm.org\/\" data-type=\"link\" data-id=\"https:\/\/openmp.llvm.org\/\">openmp<\/a>, configured through <code>-DLLVM_ENABLE_RUNTIMES=\"libcxx;libcxxabi;libunwind;compiler-rt;libc;openmp\"<\/code>. Flang appends <code>flang-rt<\/code> automatically.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Disabled components<\/h2>\n\n\n\n<p>The <code>cross-project-tests<\/code> project is disabled because it is a testing framework rather than a tool chain component. The <code>pstl<\/code> project is no longer present in the LLVM 23 monorepo. <code>libclc<\/code> 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 <code>LLVM_TARGETS_TO_BUILD<\/code>, which is set to X86 only.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Patch for MLIRRewrite generated-header dependencies<\/h2>\n\n\n\n<p>Before configuration, the recipe applies <code>llvmorg-23.1.1-mlir-rewrite-pdl-incgen.patch<\/code>. 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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Build time<\/h2>\n\n\n\n<p>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 <code>liblzma.a<\/code> build. Tree-sitter syntax highlighting and OCaml bindings were disabled because their dependencies were not found.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installed capabilities<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/hpcwithus.discoverer.bg\/?p=464\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[28],"tags":[14,48,13],"class_list":["post-464","post","type-post","status-publish","format-standard","hentry","category-compilers","tag-amd-zen2","tag-cmake","tag-llvm"],"_links":{"self":[{"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=\/wp\/v2\/posts\/464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=464"}],"version-history":[{"count":1,"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=\/wp\/v2\/posts\/464\/revisions"}],"predecessor-version":[{"id":465,"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=\/wp\/v2\/posts\/464\/revisions\/465"}],"wp:attachment":[{"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hpcwithus.discoverer.bg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}