The FPC build lives in toolchain.lock, and build.pas compiles with it when it is installed
Date: 2026-12-02
Area: build, ci
Related: ADR 0169
Context
The engine needs a 3.3.1 build from fpc-toolchain, and CI pins one build of it. Until now each of six workflows named
that build in its own FPC_VERSION variable, scripts/engine/build.sh named it again, and build.pas named it in the
message it prints when the compiler is older than 3.3.1. build.pas ran whatever fpc came first on PATH.
fpc-toolchain installs builds side by side, under toolchains/<identity>/ in its root, and a machine's default fpc
is often another build. On a machine whose default fpc was 3.2.4, ./build.pas runner stopped with "The engine needs
FPC 3.3.1" although the pinned build was installed: every shell had to run eval "$(fpc-toolchain env 3.3.1+11)"
first, and an agent's tool shell does not keep that between calls.
fpc-toolchain already has a project pin, toolchain.lock (identity, repo, sha256sums): its action installs the
build a lock names when no version is given, install.sh --lock installs it and checks the release's SHA256SUMS
against the lock, and fpc-toolchain check --lock refuses another compiler. Its fpc-<version> front-end runs a
build's driver by its path with -n and that build's own etc/fpc.cfg, so neither PATH nor a ~/.fpc.cfg or
./fpc.cfg changes what compiles.
Decision
toolchain.lockin the repository root is the only place that selects the build. No workflow passesversion, so the action reads the lock.pr.yml'sbuild-mainwrites the PR's lock over its base checkout before installing, so both benchmark builds still use one compiler.build.pascompiles with the pinned build whenever it is installed.source/shared/FPCToolchain.pasreads the lock'sidentityas fpc-toolchain does and looks fortoolchains/<identity>/bin/fpcin$FPC_TOOLCHAIN_ROOT, by default~/.local/share/fpc-toolchains. When that driver exists, every compile, compiler query and the Win32 SafeSEH check run it as the front-end does, by path with-n @<build>/etc/fpc.cfg; otherwise they run thefpconPATH, as before. Every build prints the compiler it runs, and on Linux and macOS, when it is not the pinned build, how to install that build. Another compiler is chosen by changing the lock (identityandsha256sums), not the shell.- Programs compiled against
build.pas's units use the compiler that made them. Each unit directory records the command incompiler-command.txt, andscripts/engine/unit-fpc.shruns it where the engine's test scripts (run-with-fetch-server.sh,script-artifact-imports-test.sh) compile a program against those units, so the lookup stays in one place. The workflows' own inline compiles keep thefpconPATH, which the action makes the pinned build. - The lookup covers Linux and macOS. On Windows, fpc-toolchain installs a host directory under
binand its helper is PowerShell;build.pasthere keeps running thefpconPATH. build.pasitself stays compiled by theinstantfpconPATH. It andsource/sharedbuild on FPC 3.2.2 and later, so the default compiler only runs the build tool; the targets it builds use the pinned compiler.
Consequences
- On Linux and macOS, a machine with the pinned build installed builds every target with CI's compiler from a plain
./build.pas, and a machine without it gets a line naming the missing build andinstall.sh --lock toolchain.lock. - A compiler bump is one change to
toolchain.lock(identityandsha256sums), plus the Win32 manifest re-audit ADR 0169 requires. - A shell that selects another build with
fpc-toolchain envno longer changes whatbuild.pascompiles with while the pinned build is installed. - The workflows depend on the action reading
toolchain.lockfrom the workspace root, so each job checks the repository out before installing FPC, as they already do.