-
Notifications
You must be signed in to change notification settings - Fork 28
feat: add LLVM+Clang+LLD toolchain #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
bbd87ba to
86ad4a8
Compare
There was a problem hiding this 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
TODO: renovate? 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 Signed-off-by: Dmitrii Sharshakov <[email protected]> fix: target ARM as well aarch64 Linux kernels expect a thumbv8a-unknown-linux-gnueabi compiler to be available and use it for AArch32 interfaces and vdso add it to the llvm target config Signed-off-by: Dmitrii Sharshakov <[email protected]>
ttl.sh is a public ephemeral OCI registry which can be a very convenient way of publishing built artifacts, such as toolchains, for each CI run triggered by a pull request. Unlike ghcr.io this registry does not require credentials. Signed-off-by: Dmitrii Sharshakov <[email protected]>
Signed-off-by: Dmitrii Sharshakov <[email protected]>
make sure there're symbols to debug a core dump
This reverts commit ec2eb08.
Signed-off-by: Dmitrii Sharshakov <[email protected]>
prepare for bootstrapping
Signed-off-by: Dmitrii Sharshakov <[email protected]>
| - name: Push to ttl.sh | ||
| if: github.event_name == 'pull_request' | ||
| run: | | ||
| make PUSH=true REGISTRY=ttl.sh PROGRESS=plain | ||
| continue-on-error: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: drop before merging
| - tools-zlib-ng | ||
| - tools-zstd | ||
| reproducibleTargetName: tools | ||
| reproducibleTargetName: tools-llvm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a new reproducibility test target merging tools and tools-llvm to test them together, but ship separately
| # - stage: clang | ||
| # to: /rootfs | ||
| # - stage: lld | ||
| # to: /rootfs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These targets should be removed altogether since I now changed projects (clang, lld) to build together with llvm
There was a problem hiding this 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, 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 <[email protected]>
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.
|
|
||
| patch -p1 < /pkg/patches/fix-memory-mf_exec-on-aarch64.patch | ||
| patch -p1 < /pkg/patches/llvm-stack-size.patch |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package invokes patch here but does not declare a patch stage dependency in the dependencies list, unlike other packages that apply /pkg/patches (for example, fakeroot/pkg.yaml:3-9 and tools-cpio/pkg.yaml:3-7). To avoid relying on the toolchain image implicitly providing patch and to stay consistent with the rest of the repo, please add - stage: patch to the dependencies.
| patch -p1 < /pkg/patches/fix-memory-mf_exec-on-aarch64.patch | ||
| patch -p1 < /pkg/patches/llvm-stack-size.patch |
Copilot
AI
Jan 24, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This package also uses the patch command but, like llvm/pkg.yaml, does not declare a patch stage dependency. For consistency with other patched packages and to ensure patch is available in the build environment, please add - stage: patch to the dependencies.
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
Signed-off-by: Dmitrii Sharshakov [email protected]