Skip to content

feat: add LLVM+Clang+LLD toolchain#494

Merged
talos-bot merged 1 commit intosiderolabs:mainfrom
dsseng:llvm
Feb 11, 2026
Merged

feat: add LLVM+Clang+LLD toolchain#494
talos-bot merged 1 commit intosiderolabs:mainfrom
dsseng:llvm

Conversation

@dsseng
Copy link
Member

@dsseng dsseng commented Dec 1, 2025

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.

@dsseng dsseng changed the title WIP: feat: add LLVM+Clang+LLD toolchain feat: add LLVM+Clang+LLD toolchain Dec 1, 2025
@dsseng dsseng self-assigned this Dec 1, 2025
@dsseng dsseng added this to Planning Dec 1, 2025
@github-project-automation github-project-automation bot moved this to To Do in Planning Dec 1, 2025
@dsseng dsseng moved this from To Do to In Progress in Planning Dec 5, 2025
@dsseng dsseng force-pushed the llvm branch 4 times, most recently from bbd87ba to 86ad4a8 Compare December 13, 2025 15:30
@dsseng dsseng moved this from In Progress to On Hold in Planning Dec 19, 2025
Copy link
Member Author

@dsseng dsseng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO:

  • implement best practices, such as LTOing the compiler
  • LLVM version 21.1.8 is out
  • configure Renovate for LLVM

@dsseng dsseng moved this from On Hold to In Progress in Planning Jan 5, 2026
@dsseng dsseng marked this pull request as ready for review January 24, 2026 21:05
@dsseng dsseng requested a review from Copilot January 24, 2026 21:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and lld build stages (with aarch64 and stack-size patches) and version/checksum vars for LLVM 21.1.8 in Pkgfile.
  • Add a new tools-llvm image 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 to ttl.sh for 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 lld package duplicate the ones under llvm/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 under llvm/patches and 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.

@dsseng dsseng force-pushed the llvm branch 2 times, most recently from a4fab81 to dbe11b2 Compare February 5, 2026 16:56
@smira smira moved this from In Progress to In Review in Planning Feb 6, 2026
@github-project-automation github-project-automation bot moved this from In Review to Approved in Planning 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>
@dsseng
Copy link
Member Author

dsseng commented Feb 11, 2026

/m

@talos-bot talos-bot merged commit bd4ae8f into siderolabs:main Feb 11, 2026
13 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Planning Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants