feat(packaging): ship libc++ 22's std module source for sysroots

With LLVM 23 bundled, a sysroot still on libc++ 22 without its own
module source (Alpine v3.24) is the mirror image of the case that
started this: the toolchain's source is a release ahead of the
sysroot's headers. The new libcxx-22-modules module installs libc++
22.1.8's module source under share/crafter-build/libc++-modules/22,
where SysrootStdModule looks for the release a sysroot is on.

It only configures libc++'s runtimes build and installs the cxx-modules
component: std.cppm as configure generates it and the .inc files from
the source tree, nothing compiled, about 600 KB installed. The
component is staged and copied because it also writes
lib/libc++.modules.json, which belongs to the bundled libc++.

Verified in the built Flatpak: `crafter-build --version` lists release
22, and a cross build against an Alpine v3.24 aarch64 sysroot (libc++
22.1.3) precompiles that source with clang 23, links and runs under
qemu.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-03 17:01:21 +02:00
commit 4159ee4117
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB

View file

@ -183,6 +183,33 @@ modules:
url: https://github.com/bytecodealliance/wasmtime/releases/download/v49.0.2/wasmtime-v49.0.2-x86_64-linux.tar.xz
sha256: a4d6e9e3a5a60f527cf7793d674c48930c80c2e8977995b8a275cad3254b9322
- name: libcxx-22-modules
# The std module source of the libc++ release before the bundled one, for
# cross sysroots that carry that libc++ without it: Alpine packages the
# headers and the library but not share/libc++/v1, and a module source
# only compiles against the headers of its own release. crafter-build
# picks <major>/std.cppm here by the sysroot's _LIBCPP_VERSION
# (SysrootStdModule in Crafter.Build:Toolchain). Add a module like this
# one per release worth supporting; the bundled clang has to be able to
# compile that release's headers.
buildsystem: simple
build-commands:
# Configure only. The cxx-modules component is std.cppm as configure
# generates it plus the .inc files straight from the source tree, so
# nothing is compiled, and libc++'s own install rule stays the one
# place that knows what a module source install consists of.
- cmake -S runtimes -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/app/bin/clang -DCMAKE_CXX_COMPILER=/app/bin/clang++ "-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi" -DLIBCXXABI_USE_LLVM_UNWINDER=OFF -DLIBCXX_INSTALL_MODULES=ON
# Staged, not installed to /app: the component also writes
# lib/libc++.modules.json, which would replace the bundled libc++'s.
- cmake --install build --component cxx-modules --prefix "$PWD/stage"
- grep -q "_LIBCPP_VERSION 22" libcxx/include/__config
- mkdir -p /app/share/crafter-build/libc++-modules
- cp -r stage/share/libc++/v1 /app/share/crafter-build/libc++-modules/22
sources:
- type: archive
url: https://github.com/llvm/llvm-project/releases/download/llvmorg-22.1.8/llvm-project-22.1.8.src.tar.xz
sha256: 922f1817a0df7b1489272d18134ee0087a8b068828f87ac63b9861b1a9965888
- name: crafter-build
buildsystem: simple
build-options: