Part VIII. Languages
This part covers 40_lang, the first of the five userland phases. Read it if you are building KDOS past the compilers, or adding a Python module, a Perl module or a developer tool and need to know where it goes.
The phase installs the language modules and developer tools whose dependencies are all in place once Part VII is done:
- the
python3-*andperl-*modules - a few more language implementations
- build helpers, debuggers, tracers and language servers
- documentation tools
- the version-control tools that work beside git
This introduction explains what decides that a port belongs here, how the phase’s list is filed by shelf, how its environment differs from the compilers phase’s, and which of its ports have a full page. The package pages follow, in one chapter per shelf, in the shelves’ own order. Within a shelf, they are in the order kpkgdepends builds them.
What belongs here
Every file of the phase’s list opens with the same statement of the rule:
# Language modules and developer tools — the python3-* and perl-* modules,
# language implementations, build and documentation tools, debuggers and
# version control — whose dependency closure needs nothing past 31_compilers.
script/phases/40_lang/packages.d/buildtools.txt, lines 15–17
Two things decide a port’s phase: its subject, and how far its dependency closure reaches. A Python module whose closure stops at the compilers is a 40_lang port. A Python module that needs GTK is not, whatever its shelf, because a phase may build only on what the phases before it installed; the python-gui modules therefore have their pages in Parts IX to XI, beside the libraries they bind. The rule, with the phase each kind of port goes to, is in Which phase lists a port, and testing/phaseclosure.py enforces it (see Every phase installs exactly its list).
The ports that every recipe builds with are not here. Perl and Python, the autotools, CMake, Meson and Ninja, the Python packaging chain under Sphinx, and git itself are Part VI’s; this phase adds to them.
The list, by shelf
The list is a directory, script/phases/40_lang/packages.d/, with one file per shelf, named after it: devtools.txt holds the devtools ports this phase installs. The files are read in byte order as if they were one list (see Package lists). The phase has no 00-order.txt and so no pinned run: every port’s position comes from its dependencies and from where its name stands in the list.
The chapters below take the shelves in the order of ports/shelves. The ones that carry the phase are these:
toolchain-
Additions to the compilers rather than compilers:
musl-lddandmusl-localesfor the C library, LLVM’slibclc,libunwind-nongnu, which unwinds another process or a core file as well as its own, and Crubit’scc_bindings_from_rs, which writes C++ headers for calling Rust crates. buildtools,lang-
Build helpers that only some recipes use, such as SCons, GN,
autoconf-archiveandunifdef, and the language implementations whose closure ends at the compilers: LuaJIT, Duktape, OCaml, and the JavaScript tooling esbuild, yarn andtypescript-go. devtools-
Debuggers, tracers and analysers (
strace,ltrace, Valgrind, and the BPF toolslibbpf,bpftoolandbcc), the language serversrust-analyzer,goplsandzls, and command-line developer tools such asjust,hyperfineanddifftastic. vcs,doctools-
Version-control front ends and extensions (
tig,lazygit,gh,jujutsu,git-lfs), and documentation tools: the Linuxman-pages,typst,cmark,discountandgtk-doc. pythonand thepython-*shelves-
pythonholds the build backends and extension tooling a module’s build runs:wheel,cython,maturin,meson-python,scikit-build-core,pybind11and the rest.python-libs,python-net,python-sci,python-devandpython-hwhold runtime modules, by subject. The recipes follow the module shape of Canonical build shapes. perl-cpan- CPAN modules beyond the ones Part VI installed.
A chapter lists its ports in build order, but the build does not go shelf by shelf: kpkgdepends walks the whole list and installs each port after what it depends on, so a python port can build before a devtools one that comes earlier in the book. The Phase row of each package page gives the port’s place in the phase’s real order.
The environment
The phase’s environment is in script/phases/40_lang/phase.env, and the other userland phases’ files differ from it only in the comment that names the phase and in its title and description:
export CHROOT=1
export PORT_REPO="/ports/core /kdos/src/system /kdos/src/art"
source "${BASH_SOURCE[0]%/*}/../../env/chroot.env"
script/phases/40_lang/phase.env, lines 23–26
The file differs from 31_compilers’ in two ways:
- It has no
LD_LIBRARY_PATHline. - It sets
PORT_REPO, the list of directories kpkg searches for recipes, naming/kdos/src/systemand/kdos/src/artbeside/ports/core.31_compilerssets none, so kpkg takes the list in/etc/kpkg.conf, and the only one of those directories that exists in the chroot is/ports/core.
KDOS’s own programs can therefore be found from this phase on (see Where kpkg looks for a port). This phase builds none of them; Parts IX, X, XI and XIII do.
A third difference comes from the shared script/env/chroot.env, which every chroot phase sources. From this phase on it exports the switches for Rust’s -sys crates:
# RUST -sys CRATES LINK THE SYSTEM LIBRARY, from 40_lang on: each switch
# makes its crate use the library's pkg-config file instead of compiling the
# copy the crate carries, so the packaged program has a DT_NEEDED on the
# system library and takes its security fixes. A crate whose library is not
# installed, or whose pinned version the system's does not satisfy, fails its
# build script and names the library; the port then lists it in `depends`.
# LIBGIT2_NO_VENDOR libgit2-sys, even with vendored-libgit2
# RUSTONIG_SYSTEM_LIBONIG onig_sys (oniguruma)
# LIBSQLITE3_SYS_USE_PKG_CONFIG libsqlite3-sys, even with bundled
# ZSTD_SYS_USE_PKG_CONFIG zstd-sys
# Off in 20_selfhost to 31_compilers: oniguruma arrives in 41_system, and
# rust and cargo-c (31_compilers) export LIBGIT2_NO_VENDOR themselves. The
# phase that sourced this file decides: its phase.env's path names it.
case ${BASH_SOURCE[1]-} in
*/phases/[23]?_*/phase.env) ;;
*) export LIBGIT2_NO_VENDOR=1 RUSTONIG_SYSTEM_LIBONIG=1 \
LIBSQLITE3_SYS_USE_PKG_CONFIG=1 ZSTD_SYS_USE_PKG_CONFIG=1 ;;
esac
script/env/chroot.env, lines 185–202
BASH_SOURCE[1] is the path of the phase.env that sourced the file, so the case keeps the switches out of 20_selfhost, 30_foundation and 31_compilers and exports them in every later phase. With them set, a Rust program that would compile its own copy of libgit2, oniguruma, SQLite or zstd links the system’s library instead, found through its pkg-config file. The program then carries a DT_NEEDED entry for the shared library, and a security fix to the library reaches it without a rebuild. Either way the crate’s build script fails and names the library, but the two causes have different fixes. When the library is not installed, list its port in the port’s depends. When the crate asks for a version the installed library does not satisfy, depends changes nothing, because the library is already there: move the library’s port to a version the crate accepts, or move the port to a version whose crate accepts the installed library.
Which ports have full pages
No port of this phase is named in docs/kfs/data/tier-a.txt, so none is Tier A. A port here has a full page when it is Tier B (see The three tiers), and in this phase that is mostly for one reason: it vendors its dependencies. The Rust and Go tools (rust-analyzer, ruff, gh, jujutsu and others) and some Python modules carry a second tarball, a bundle of their dependencies made in advance so that the build needs no network, and the recipe’s vendoring = key names its kind (see Vendoring). The other Tier B ports carry a patch, have a long build.sh, or are dependencies of 20 or more ports, as python3-wheel, python3-cython and python3-typing-extensions are of Python modules across the tree. Every other port has a card, a compact page of its recipe’s facts.
See also
- The userland:
40_langto44_apps: the five phases in the whole journey - Phases, package lists and shelves: how a phase and a shelf differ
- Anatomy of a kpkg install: the steps every port below goes through
- Reading a package page: how the pages below are laid out
- Part IX: the next phase