62.1. rust-1.98.1
The Rust compiler, with cargo, clippy, rustdoc and rustfmt
| Version | 1.98.1, release 2 |
| Shelf | lang — Language implementations, plus the modules of any language that has no module shelf of its own |
| Phase | 31_compilers (Compilers), 4 of 22 in build order |
| Licence | MIT OR Apache-2.0 |
| Homepage | https://www.rust-lang.org/ |
| Build time | 51.3 SBU |
| Installed size | 767.8 MiB in 6917 files |
| Recipe | ports/core/lang/rust/kpkgbuild |
About
This port is the Rust compiler, rustc, with cargo, clippy, rustdoc and rustfmt. A large part of KDOS is built with it: command-line programs such as ripgrep, fd, bat and helix, the Mozilla browsers and Chromium, librsvg, mesa, linux, typst and the Python packages with Rust extensions all name it in depends. It is built in 31_compilers, the phase that holds the long compiler builds, so that a failure there restores 30_foundation and loses minutes, not the foundation work before it (see How KDOS is built).
KDOS builds Rust differently from upstream’s release in three ways. It links the system LLVM, the llvm port, instead of compiling the LLVM inside the source tarball. It links rustc and the standard library dynamically against musl, where the musl target’s default is static. And cargo links the system libgit2, libssh2, curl, OpenSSL and zlib rather than compiling the copies their -sys crates carry.
Rust is written in Rust, so the build starts from a released compiler: the previous stable rustc, rust-std and cargo for x86_64-unknown-linux-musl, the three extra sources in the recipe. They are the stage0 compiler that x.py starts from to compile this release.
Sources
rust-1.98.1.tar.xz(233.1 MiB)
sha256be1816e7f6c40abb90245ad6e024bed2a7e88d7dda4561e4d5470207df616b9f
upstream: https://static.rust-lang.org/dist/rustc-1.98.1-src.tar.xz
archive copy: sources-3/lang--rust-1.98.1.tar.xzcargo-1.97.1-x86_64-unknown-linux-musl.tar.xz(11.4 MiB)
sha256623a1315bdbddc5e7a807aaf7e1911d1435a294758e170b8758f49fc57a3e67c
upstream: https://static.rust-lang.org/dist/2026-07-16/cargo-1.97.1-x86_64-unknown-linux-musl.tar.xz
archive copy: sources-3/lang--cargo-1.97.1-x86_64-unknown-linux-musl.tar.xzrust-std-1.97.1-x86_64-unknown-linux-musl.tar.xz(37.4 MiB)
sha25651d83178680556f73a5fa8ad865b76a1ff541867445c00fc65dc67246bc2de66
upstream: https://static.rust-lang.org/dist/2026-07-16/rust-std-1.97.1-x86_64-unknown-linux-musl.tar.xz
archive copy: sources-3/lang--rust-std-1.97.1-x86_64-unknown-linux-musl.tar.xzrustc-1.97.1-x86_64-unknown-linux-musl.tar.xz(100.8 MiB)
sha2561b1f926d3b5bf8036c858180dbc9518c6c317154718ee5c5460bb23d23bacf5d
upstream: https://static.rust-lang.org/dist/2026-07-16/rustc-1.97.1-x86_64-unknown-linux-musl.tar.xz
archive copy: sources-3/lang--rustc-1.97.1-x86_64-unknown-linux-musl.tar.xz
Dependencies
Depends on: curl, cmake, python3, llvm, libssh2, libgit2, openssl, xz.
Required by (94): aardvark-dns, akonadi-search, angelfish, atuin, bandwhich, bat, bindgen, bottom, caligula, cargo-c, cbindgen, chess-tui, chromium, clamav, corrosion, crubit, cxx-rust-cssparser, ddnet, delta, difftastic, doxx, dust, espflash, eza, fd, firefox-esr, helix, hexyl, hurl, hyperfine, iamb, impression, inlyne, jujutsu, just, kdepim-addons, kdeplasma-addons, libdovi, libimagequant, librepcb, librewolf, librsvg, linux, lnav, mesa, mesa-opencl, mqttui, netavark, newsboat, nodejs, numbat, ouch, oxipng, pizauth, presenterm, probe-rs, procs, python3-bcrypt, python3-cryptography, python3-jellyfish, python3-maturin, python3-orjson, python3-pydantic-core, python3-rpds-py, python3-setuptools-rust, resources, resvg, ripgrep, ripgrep-all, rmpc, ruby, ruff, rust-analyzer, sd, sniffnet, starship, surfer, taskwarrior, taskwarrior-tui, tealdeer, termusic, thin-provisioning-tools, thunderbird, tokei, tree-sitter, trippy, ttyper, typst, virtiofsd, waypipe, wiremix, xh, yazi, zoxide.
Patches
build.sh applies these; kpkg applies nothing by itself.
rust-llvm23-amx-tf32.patch— removes theamx-tf32x86 target feature from rustc’s feature table, together with its intrinsics incore::arch(_tile_mmultf32psand__tile_mmultf32ps), their tests and their run-time detection instd_detect; the system LLVM has no such feature, and a rustc that lists it fails on its first target query with “‘+amx-tf32’ is not a recognized feature”.rust-llvm23-assign-guid.patch— Reapply "LLVM 23: Run AssignGUIDPass in some places"This reverts commit 4919940fad92a2a503e3fe7fc6a5594fb9771e72.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/31_compilers/phase.env && kpkg install rust'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/lang/rust.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/lang/rust
echo 'be1816e7f6c40abb90245ad6e024bed2a7e88d7dda4561e4d5470207df616b9f rust-1.98.1.tar.xz' | sha256sum -c -
echo '623a1315bdbddc5e7a807aaf7e1911d1435a294758e170b8758f49fc57a3e67c cargo-1.97.1-x86_64-unknown-linux-musl.tar.xz' | sha256sum -c -
echo '51d83178680556f73a5fa8ad865b76a1ff541867445c00fc65dc67246bc2de66 rust-std-1.97.1-x86_64-unknown-linux-musl.tar.xz' | sha256sum -c -
echo '1b1f926d3b5bf8036c858180dbc9518c6c317154718ee5c5460bb23d23bacf5d rustc-1.97.1-x86_64-unknown-linux-musl.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/rust
SRC=$SRC_ROOT/rust-1.98.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf rust-1.98.1.tar.xz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf rust-std-1.97.1-x86_64-unknown-linux-musl.tar.xz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf rustc-1.97.1-x86_64-unknown-linux-musl.tar.xz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf cargo-1.97.1-x86_64-unknown-linux-musl.tar.xz -C "$SRC_ROOT"
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers _date, _rust, _cargo, _triplet, watch and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i $PORT_SRC/rust-llvm23-amx-tf32.patch
patch -p1 -i $PORT_SRC/rust-llvm23-assign-guid.patch
mkdir -p build/cache/$_date
cp $PORT_SRC/rust-std-$_rust-$_triplet.tar.xz build/cache/$_date/
cp $PORT_SRC/rustc-$_rust-$_triplet.tar.xz build/cache/$_date/
cp $PORT_SRC/cargo-$_cargo-$_triplet.tar.xz build/cache/$_date/
cat << EOF > config.toml
[llvm]
targets = "X86"
link-shared = true
[build]
docs = false
extended = true
locked-deps = true
vendor = true
python = "/usr/bin/python3"
tools = ["cargo", "clippy", "rustdoc", "rustfmt", "src", "rust-analyzer-proc-macro-srv"]
description = "kdos"
profiler = true
[install]
prefix = "/usr"
[rust]
channel = "stable"
jemalloc = true
codegen-units-std = 1
rustflags = ["-Cstrip=debuginfo"]
[target.$_triplet]
llvm-config = "/usr/bin/llvm-config"
llvm-filecheck = "/usr/lib/llvm/utils/FileCheck"
crt-static = false
EOF
mkdir "$SRC/rust"
export CARGO_HOME="$SRC/rust"
export RUST_BACKTRACE=1
export LIBSSH2_SYS_USE_PKG_CONFIG=1
export LIBGIT2_NO_VENDOR=1
python3 ./x.py build --jobs "$KDOS_JOBS"
DESTDIR=$PKG python3 ./x.py install -v --jobs "$KDOS_JOBS"
python3 ./x.py dist rustc-dev --jobs "$KDOS_JOBS"
mkdir "$SRC/rustc-dev"
tar -xf build/dist/rustc-dev-$version-$_triplet.tar.xz -C "$SRC/rustc-dev" --strip-components=1
"$SRC/rustc-dev/install.sh" --prefix=/usr --destdir="$PKG" --disable-ldconfig
for f in "$PKG"/usr/lib/rustlib/$_triplet/lib/*.so; do
[ -e "$PKG/usr/lib/${f##*/}" ] || continue
ln -sf "../../../${f##*/}" "$f"
done
rm -f "$PKG"/usr/lib/rustlib/{components,install.log,rust-installer-version,uninstall.sh} \
"$PKG"/usr/lib/rustlib/manifest-*
install -d "$PKG/usr/share/bash-completion/completions"
mv "$PKG/etc/bash_completion.d/cargo" "$PKG/usr/share/bash-completion/completions/cargo"
rmdir "$PKG/etc/bash_completion.d"
The switches, and why each is set:
targets = "X86"— the back ends x.py would build if it compiled LLVM. Withllvm-configset below it compiles no LLVM, so this changes nothing:librustc_driverlinks whatever back ends the system LLVM has, which thellvmport builds with every target.link-shared = true— link rustc against LLVM’s shared libraries (libLLVM*.sofrom thellvmport) rather than static archives.docs = false— build no HTML documentation. The image would not ship it: the size policy removes HTML manuals.extended = true— build the tools named intoolsas well as the compiler.locked-deps = true— build with theCargo.lockfiles exactly as the release ships them; cargo fails rather than resolve a different dependency.vendor = true— take every crate from thevendor/directory of the source tarball; nothing is downloaded.python = "/usr/bin/python3"— the Python that runs x.py’s scripts.tools—cargo,clippy,rustdocandrustfmt, plus two for therust-analyzerport:"src"installs the standard library’s source underlib/rustlib/src, without which rust-analyzer resolves nothing instdorcore, and"rust-analyzer-proc-macro-srv"installslibexec/rust-analyzer-proc-macro-srv, without which it expands no derive or attribute macro.description = "kdos"— a string appended to the version, sorustc -Vreadsrustc <version> (<commit> <date>) (kdos). Without it, x.py marks a build from a source tarball as “built from a source tarball”.profiler = true— build theprofiler_builtinsruntime from the copy of compiler-rt in the tarball.-C instrument-coverage,-C profile-generate(and so profile-guided optimisation) andcargo-llvm-covneed it.channel = "stable"— build the stable channel, which allows only stable language features.jemalloc = true— link rustc against jemalloc, from the vendoredtikv-jemalloc-syscrate, instead of the C library’smalloc. musl’s allocator is slow under rustc’s allocation pattern.codegen-units-std = 1— compile the standard library, which every Rust program links, as one code-generation unit, as upstream’s release builds do. rustc itself keeps the default of 16.rustflags = ["-Cstrip=debuginfo"]— pass-C strip=debuginfoto every rustc that x.py runs, so nothing the bootstrap links keeps debug information (see What kpkg does around build.sh).llvm-config = "/usr/bin/llvm-config"— build against the LLVM that thisllvm-configdescribes, thellvmport, and do not compile the LLVM insrc/llvm-project. This is why the recipe carries the two LLVM patches.llvm-filecheck— where LLVM’sFileCheckis:/usr/lib/llvm/utils/FileCheck, where thellvmport installs its utilities. With an external LLVM and nollvm-filecheck, x.py looks forFileCheckinllvm-config --bindirand then inllvm/underllvm-config --libdir, and its sanity check stops the build when neither exists; this tree keeps it in neither place.crt-static = false— link rustc, its tools and the standard library for this target against the shared musllibc.so. The musl target’s own default for programs rustc compiles stays static, which is why every Rust port passes-C target-feature=-crt-static(see Writing ports).RUST_BACKTRACE=1— print a backtrace when any Rust program in the build panics, x.py’s own helpers included, so a failure in the log says where it happened.LIBSSH2_SYS_USE_PKG_CONFIG=1,LIBGIT2_NO_VENDOR=1— make thelibssh2-sysandlibgit2-syscrates that cargo is built with link thelibssh2andlibgit2ports instead of compiling their bundled copies.script/env/chroot.envexportsLIBGIT2_NO_VENDORonly from40_langon, after this phase.--jobs "$KDOS_JOBS"— run x.py’s builds with the tree’s job count.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/rust, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf rust-1.98.1-2.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/rust, and runs the triggers its paths call for.
Contents
Installed programs: cargo, cargo-clippy, cargo-fmt, clippy-driver, rust-gdb, rust-gdbgui, rust-lldb, rustc, rustdoc, rustfmt.
Installed libraries: librustc_driver-9a4c673f3cd4e306.so.
Installed directories: /usr/lib/rustlib, /usr/share/doc/cargo, /usr/share/doc/clippy, /usr/share/doc/rustc, /usr/share/doc/rustfmt, /usr/share/licenses/rust.
Short descriptions
cargo |
The Rust package manager |
rustc |
The Rust compiler |
rustdoc |
generate documentation from Rust source code |
Notes
The stage0 tarballs are copied into build/cache/<date>/, where x.py looks before it downloads anything. The recipe’s _date and _rust must be the compiler_date and compiler_version that src/stage0 in the new source names; when they differ, x.py looks for a directory that is not there, tries the network, and the build fails in the chroot. After a version bump, read src/stage0 and set both.
rustc-dev is the compiler’s own crates (rustc_driver, rustc_middle and the rest) as .rmeta files under lib/rustlib/x86_64-unknown-linux-musl/lib. x.py install installs it only when tools names it, and the list above does not. A tool built against rustc’s internals with #![feature(rustc_private)] links them; crubit, which Chromium needs, is one. build.sh makes the rustc-dev dist tarball with x.py dist rustc-dev and runs the tarball’s own install.sh into the package. That tarball carries its own copies of the compiler’s shared libraries; each one /usr/lib already holds is replaced with a symbolic link to it, so the two can never differ.
The rest of build.sh tidies the install: it deletes the installer’s bookkeeping in lib/rustlib (components, install.log, manifest-*, uninstall.sh, rust-installer-version), which describes an installation kpkg already tracks, and moves cargo’s bash completion from /etc/bash_completion.d to /usr/share/bash-completion/completions, where bash-completion loads it on demand.
Both patches adapt rustc to LLVM 23, the series the llvm port carries, which is newer than the LLVM this Rust release is built against. The header of rust-llvm23-assign-guid.patch says only that it reapplies an upstream commit; what it does is add LLVM’s AssignGUIDPass ahead of the two places rustc writes ThinLTO bitcode, when built against LLVM 23 or later. That LLVM assigns the global identifiers ThinLTO’s summaries are keyed on only when the pass pipeline asks for them.