9.9.24
Roguelikes are more fun with source.
Preamble on Deterministic Build Results
The C language specification allows compilers to grab information from the runtime environment and jam it into the executable. On one hand, it's nice to have locale and time information in a build. On the other hand, it obscures the super power of digital devices to produce consistent results across the globe. We provide explicit values below to achieve stable results.
Example Build Environment
- Linux (Ubuntu 22.04)
- Bash (5.1)
- Cosmocc (3.6.2) https://github.com/jart/cosmopolitan/releases/tag/3.6.2
- SDL (2.28.5) https://github.com/libsdl-org/SDL/releases/tag/release-2.28.5
- Game repository: git clone https://rufe.org/source/moria_at
Shell Variables
Use a shell variable for the absolute path of SDL2 ($SDLPATH)
Use a shell variable for the absolute path of cosmocc ($COSMOCC)
Capture values for hash and version. Store them in a shell variables:
- export VERSION=0003.0000.0360
- export HASH=97b6c8dd295ec62
Setup
- git reset --hard $HASH
- ln -sf $SDLPATH sdl2
- ln -sf `realpath platform/sdl2` src/platform
Building from the game repository root
- LC_ALL=C SOURCE_DATE_DEPOCH=0 $COSMOCC src/moria_at.c -O1 -g1 -I. -fno-omit-frame-pointer -Wno-implicit-function-declaration -Wno-implicit-int -Wno-return-type -Isdl2/include -DNDEBUG -DRELEASE -U__DATE__ -U__TIME__ -fno-math-errno -ffp-contract=fast -freciprocal-math -fno-trapping-math -lm -o bin/moria_at.exe
Binary Versioning
- sed -i "s/\/$VERSION/g" bin/moria_at.exe
- sed -i "s/\/$HASH/g" bin/moria_at.exe
Compare hashes with Steam
- sha256sum bin/moria_at.exe
- sha256sum $STEAMDIR/steamapps/common/Moria/moria_at.exe