Developer Setup
This page sets up a machine for work on Sprite itself. One script does the
work: scripts/setup-dev-machine.sh. It puts every bulky product under
one scratch prefix, builds the pinned toolchain, configures and stages
Sprite, and runs a smoke test. The script never runs sudo. When an apt
package is missing, it prints the apt command and stops.
Quick start
Clone the repository, print the plan, then run it:
git clone https://github.com/andyjost/Sprite.git
cd Sprite
scripts/setup-dev-machine.sh --prefix /path/to/scratch --dry-run
scripts/setup-dev-machine.sh --prefix /path/to/scratch
The dry run prints every command and runs none. The real run stops at the
first problem. Fix the cause, then run the same command again: a finished
step is skipped, and configure runs again only when its flags changed or
--reconfigure asks for it. The whole run takes under an hour on a
current machine. Most of that time goes to the PAKCS build, the conda
solve, and the compilation of the Curry library for the C++ backend.
The steps
The script runs nine steps in this order.
Machine. Prints the OS, the cores, the memory, the swap, and the tools it found.
--jobs autostaysauto:makecounts the processors when it starts, so no count of this machine entersMake.config.apt packages. Checks
git swi-prolog-nox g++ make curl ccache timeand thelinux-toolspackages of the running kernel, which provideperf. SWI-Prolog serves PAKCS alone: the build of its saved states in step 3 and the test oraclepakcs. Sprite itself runs no Prolog, and its C++ runtime needs no Boost.timeis GNU time, which the benchmark harness uses for the peak memory of a run. A missing package stops the script. The printed command installs the missing ones.--skip-aptskips the check on a system without dpkg.PAKCS 3.4.1. Downloads the binary archive from curry-lang.org into
PREFIX/downloadsand verifies its SHA-256. The hash is the one ofconda/curry-frontend/meta.yaml. The archive unpacks toPREFIX/pakcs-3.4.1. The script gives SWI-Prolog 9 the stack limit that the distribution sets for version 8, then runsmakethere. The build takes about five minutes. Sprite takes the Curry front end and the test oracle from this tree.Checkout. Clones the repository when
--reponames a missing directory. Initializes the pybind11 submodule only. Linksinstallandobject-rootof the checkout toPREFIX/installandPREFIX/object-root. A link that points elsewhere stops the script. The script deletes nothing.Conda environment. Creates
PREFIX/conda/envfromconda/dev-environment.ymlof the checkout with micromamba, mamba, or conda, whichever is found first. The package cache goes toPREFIX/conda/pkgs. The environment holds Python 3.14, numpy, Sphinx, and the Sphinx theme, and nothing else.configure. Runs
configurein the clean environment with the system compilers, the PAKCS of step 3, and the Python of step 5. The script probesconfigure --helpand adds--jobsand--with-ccachewhen configure supports them. configure emptiesinstallandobject-root, so the script records the flags inPREFIX/configure-argsand skips the step whileMake.configexists and the flags are the same.--reconfigureforces it.make stage. Builds the runtime and compiles the Curry library for both backends. Thenmake overlayextracts the archived products of the test programs, after the stage so that they are newer than the installed library interfaces.Smoke test. Runs one fast unit test file on each backend under the address-space cap and the time limit of the test drivers.
Next steps. Prints the paths for the personal rules file and the runs to make next.
With --icurry the script also installs icurry 3.1.0 through the
Curry Package Manager, after step 3. That is the optional second route
from Curry to ICurry. The step follows the CI script
.github/scripts/install-curry-toolchain.sh. It writes ~/.cpmrc
only when the file is missing, with the CPM home under PREFIX/cpm.
The clean environment
A conda toolchain in the login shell exports CC, CXX, CFLAGS,
CXXFLAGS, CPPFLAGS, and LDFLAGS. The Makefiles of Sprite
append those flags, so a build in that shell mixes two toolchains. The
script runs configure, make, and the smoke test under env -i with five
variables: PATH=/usr/local/bin:/usr/bin:/bin, HOME,
LC_ALL=C.UTF-8, TMPDIR, and CCACHE_DIR=PREFIX/ccache. Use the
same command for every later build:
env -i PATH=/usr/local/bin:/usr/bin:/bin HOME=$HOME LC_ALL=C.UTF-8 CCACHE_DIR=PREFIX/ccache make stage
CCACHE_DIR keeps the compiler cache under the prefix, not under
HOME. With configure --with-ccache the compiler of the
installation runs ccache too, so every test and every program that
compiles a module for the C++ backend reads the variable. For a shell
outside the clean environment, say once
ccache --set-config cache_dir=PREFIX/ccache.
SPRITE_SETUP_CLEAN_PATH replaces the PATH of the clean environment.
Layout of the prefix
Path |
Content |
|---|---|
|
the PAKCS archive |
|
PAKCS: |
|
the conda environment; |
|
the conda package cache |
|
the staged install, linked from the checkout |
|
the object tree, linked from the checkout |
|
the CPM home, with |
|
the compiler cache ( |
|
the flags of the last configure run |
Options
Option |
Meaning |
|---|---|
|
the scratch root; required |
|
the checkout; cloned when missing; the default is the checkout that holds the script |
|
the clone URL |
|
the branch to clone |
|
the job count for configure, when it supports
|
|
run configure although |
|
print every command, run none |
|
do not check the apt packages |
|
also install icurry 3.1.0 through cypm |
|
the unit test file of the smoke test; the default is
|
|
the address-space cap of each smoke run in KiB, or
|
|
the time limit of each smoke run |
|
the system compilers |
PAKCS_VERSION and ICURRY_VERSION in the environment change the
pinned versions. A PAKCS version without a pinned hash gets its size and
hash printed instead of a check.
Every budget is a parameter: the job count, the memory cap, and the time limit. The script detects the cores and the memory and prints them. Do not copy a number from one machine to the next.
After the setup
The last step prints the same list with the paths of the machine.
Calibrate the test manifest on the new machine. Run every test file once per backend on a quiet machine with the manifest update of the test runner:
cd tests ./run_tests -j 1 --backend both --update-manifest
The durations and the peak memory of every test file must be measured there, then committed in
tests/manifest.json. See./run_tests -hand section 10 oftests/README.Record a baseline with the benchmark harness on a quiet machine. The records carry the deterministic columns steps, forks, and collections, which the compare command checks:
cd tests ./run_benchmarks -b cxx -b py --label baseline -o PREFIX/baseline.jsonl ./run_benchmarks counters PREFIX/baseline.jsonl
Update the personal rules file with the new paths: the Python, the PAKCS tree, icurry, the install and object trees, the conda package cache, the compiler cache, and the clean environment. Record the cores and the memory.
Copy
tests/.cache/icurry.dbfrom the old machine. The cache is keyed by the source text, so the first suite run then compiles nothing.
Notes
PAKCS, cypm, and icurry write under
/tmp. A sandbox that mounts/tmpread-only breaks them.The Kiel mirrors of the Curry Package Manager do not answer. The script writes a
~/.cpmrcthat namescpm.curry-lang.org.The script was written for Ubuntu 24.04. On another distribution, install the equivalents of the apt packages and pass
--skip-apt.tests/unit_setup_script.pyruns the script with--dry-runand checks the plan. It needs no network and installs nothing.