feat: add LLVM+Clang+LLD toolchain#494
Merged
talos-bot merged 1 commit intosiderolabs:mainfrom Feb 11, 2026
Merged
Conversation
bbd87ba to
86ad4a8
Compare
dsseng
commented
Jan 2, 2026
Member
Author
There was a problem hiding this comment.
TODO:
- implement best practices, such as LTOing the compiler
- LLVM version 21.1.8 is out
- configure Renovate for LLVM
dsseng
commented
Jan 24, 2026
There was a problem hiding this comment.
Pull request overview
This PR introduces an LLVM 21-based toolchain (LLVM + Clang + LLD) and a dedicated tools-llvm image suitable for building Linux kernels, and wires it into the build, reproducibility, and CI pipelines.
Changes:
- Add new
llvm,clang, andlldbuild stages (with aarch64 and stack-size patches) and version/checksum vars for LLVM 21.1.8 inPkgfile. - Add a new
tools-llvmimage that pulls in the LLVM toolchain, prunes development artifacts, and use it as the reproducibility-test target. - Update Makefile,
.kres.yaml, and CI workflow to build/push the new image and run reproducibility tests against it, including optional pushes tottl.shfor PRs.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tools-llvm/pkg.yaml | Defines the new tools-llvm image, aggregating the llvm stage into /rootfs and stripping LLVM development headers/static archives before finalizing. |
| llvm/pkg.yaml | Adds the core llvm stage that builds LLVM 21.1.8 with Clang and LLD enabled from source, applies local patches, and installs into /usr under /rootfs. |
| llvm/patches/llvm-stack-size.patch | Introduces an upstream-derived patch to always request a larger thread stack size (originally Mac-specific) for LLVM’s threading support. |
| llvm/patches/fix-memory-mf_exec-on-aarch64.patch | Adds an upstream-derived patch to adjust memory protection flags for executable pages on Linux/aarch64. |
| lld/pkg.yaml | Defines a standalone lld build stage that depends on llvm, fetches LLD and related components, applies the same LLVM patches, builds, and installs LLD under /usr. |
| lld/patches/llvm-stack-size.patch | Duplicates the LLVM stack-size patch for use within the lld package context. |
| lld/patches/fix-memory-mf_exec-on-aarch64.patch | Duplicates the aarch64 memory protection patch for use within the lld package context. |
| clang/pkg.yaml | Adds a standalone clang build stage depending on llvm, building and installing Clang with appropriate standalone and linker options. |
| Pkgfile | Introduces version and checksum variables for LLVM 21.1.8 and its component tarballs (LLVM, Clang, LLD, libunwind, cmake, third-party) for use by the new packages. |
| Makefile | Regenerates build targets to include tools-llvm and updates reproducibility-test to exercise the tools-llvm target. |
| .kres.yaml | Adds tools-llvm to the list of Kres-managed targets and sets tools-llvm as the reproducible target name used by the Makefile. |
| .github/workflows/ci.yaml | Extends the default CI job for PRs with an optional make PUSH=true REGISTRY=ttl.sh step to push images to ttl.sh without failing the build if that push fails. |
Comments suppressed due to low confidence (1)
lld/patches/llvm-stack-size.patch:26
- These LLVM patch files in the
lldpackage duplicate the ones underllvm/patches(same content and upstream references). To reduce duplication and the risk of the two copies drifting apart, consider centralizing shared LLVM patches (for example, keeping them only underllvm/patchesand reusing them from here).
Imported from Alpine: https://gitlab.alpinelinux.org/alpine/aports/-/blob/9e8202998fa718a7be6fb2d8aba639f97a94bb6a/main/llvm21/llvm-stack-size.patch
Patch-Source: https://github.com/chimera-linux/cports/blob/8c0359f31b9d888e59ced0320e93ca8ad79ba1f9/main/llvm/patches/0010-always-set-a-larger-stack-size-explicitly.patch
From 18e09846d9333b554e3dfbbd768ada6643bf92c0 Mon Sep 17 00:00:00 2001
From: Daniel Kolesa <daniel@octaforge.org>
Date: Sat, 27 Nov 2021 01:03:28 +0100
Subject: [PATCH 10/22] always set a larger stack size explicitly
---
llvm/lib/Support/Threading.cpp | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/llvm/lib/Support/Threading.cpp b/llvm/lib/Support/Threading.cpp
index 923935bbc..26594aac8 100644
--- a/llvm/lib/Support/Threading.cpp
+++ b/llvm/lib/Support/Threading.cpp
@@ -77,7 +77,7 @@ unsigned llvm::ThreadPoolStrategy::compute_thread_count() const {
// keyword.
#include "llvm/Support/thread.h"
-#if defined(__APPLE__)
+#if 1
// Darwin's default stack size for threads except the main one is only 512KB,
// which is not enough for some/many normal LLVM compilations. This implements
// the same interface as std::thread but requests the same stack size as the
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a4fab81 to
dbe11b2
Compare
smira
approved these changes
Feb 6, 2026
LLVM toolchain provides numerous opportunities for building Linux kernels, such as kCFI, ThinLTO, Rust support and easy cross-compilation Build a toolchain sufficient for Linux, without compiler-rt and libstdc++, but with llvm-binutils and lld AArch32 (ARM) support is enabled for building parts of AArch64 Linux kernel that need it for 32-bit ABIs. Signed-off-by: Dmitrii Sharshakov <dmitry.sharshakov@siderolabs.com>
Member
Author
|
/m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLVM toolchain provides numerous opportunities for building Linux
kernels, such as kCFI, ThinLTO, Rust support and easy cross-compilation
Build a toolchain sufficient for Linux, without compiler-rt and
libstdc++, but with llvm-binutils and lld
AArch32 (ARM) support is enabled for building parts of AArch64 Linux
kernel that need it for 32-bit ABIs.