Cupid

Inside Cupid

Platforms and the build

The build needs no Haskell tools at all: a C compiler, meson, ninja, python3 and bison are the whole list. It also probes almost nothing, which is unusual for C of this age, and it has very few options. Both follow from what the code targets now. The options themselves are listed in Build options and install layout.

Modern 64-bit systems only

Cupid targets 64-bit Linux, macOS and the BSDs on x86-64 and ARM64, and Windows on x86-64. On these, the questions autoconf used to ask all have the same answer: int is four bytes, pointers eight, floating point is IEEE, the stack grows down, and every C99 header is present. src/sysdeps.h writes those answers down, and static assertions in prelude.h check the sizes. The only real differences left are Windows against POSIX, and sometimes macOS, and machdep.c holds the code that differs: finding the library directory, running the editor and the shell, dynamic loading of FFI objects, timers and signals. Linux, macOS and Windows are built and tested on every change; on Windows, see Build Cupid on Windows.

meson, with generated files kept in the build tree

The build is meson only. Three kinds of file are generated:

  • config.h holds the build options and the install paths.
  • platform.h is generated from platform.h.in with the operating system and architecture names as meson knows them, in the *_HOST_OS spellings the C sources test. Only C reads it; the libraries get the same facts from Cupid.SysConfig.
  • parser.c and parser.h are generated by bison into the build directory, and no copies are kept in src/. A hand-regenerated file goes stale. A stale parser.h next to input.c would also win over the generated one for a quoted #include, and the build would then use the wrong token numbers.

The libraries have one platform-dependent piece too: the widths of C types and the values of errno and signal constants. A small C program, libraries/tools/mksysconfig.c, asks the C compiler at build time and writes the answers into the module Cupid.SysConfig and the header HsBaseConfig.h. That is what lets the build do without any Haskell tools.

Two feature options

A build option is a flag like any other, so each of the ten inherited from Hugs had to justify its second code path. profiling and checks did. profiling changes the layout of every heap cell, so it can't become a run-time switch without costing every build. checks is a developer build that keeps assertions, checks cell tags and adds the +D bytecode listing. char-encoding and readline remain as well, but they choose a character set and a library, not a feature.

Where a deleted option chose between two behaviours, the less surprising one stayed: the one the default build already had, unless that left a documented feature missing. So the one-line banner, the build without a fatal-signal handler, absolute file names in messages, the elapsed-time line after each command and the "while evaluating:" lines after a stack overflow are gone, with the code only they compiled. So are the primitives that exposed the interpreter's cells and bytecode, and the three experimental modules over them that nothing imported. :xplain and +x are documented, so they are always built instead, and +x is off by default.

Every configuration is tested

An option nothing exercises rots. So the regression suite has to pass in the default build, with each option on alone and with both on, and tools/check-configurations builds and tests all four. With two feature options those four are every combination of them; a third would make the sweep a sample, five of eight. char-encoding and readline are not swept. No feature option changes what a program prints (checks and profiling each add entries to the :set listing), so every configuration is compared against the same expected output, with no filters. See Check every build configuration.

Edit this page on GitHub