Lyric v4.5.0

The Pack Format

How a Lyric program becomes one executable file. This document is the contract between lyrpack, which writes packed executables, and lyrstub, which is one. The module inside is an ordinary .lyrbc and is specified in Bytecode.md; nothing here reaches into it.

Layout

A packed executable is three regions, in order:

┌────────────────────────────┐
│ stub executable            │  the platform's lyrstub, byte for byte
├────────────────────────────┤
│ payload                    │  one .lyrbc module, byte for byte
├────────────────────────────┤
│ footer                     │  24 bytes, see below
└────────────────────────────┘

The stub is a self-contained single-file build of lyrstub for one platform; the toolchain archive carries it under stubs/<rid>/. Nothing is patched into it: packing is a byte copy with two appends, which is why it needs no linker, no code signing step and no knowledge of the executable format it wraps. The operating system loads the file as the executable it begins with; the trailing bytes are cargo it never looks at.

Fixed 24 bytes at the very end of the file, little-endian:

Offset from end Size Field Content
−24 u32 version footer layout version, currently 1
−20 u32 reserved written as 0, ignored on read
−16 u64 length payload length in bytes, > 0
−8 8 bytes magic ASCII LYRPACK1

The footer sits at the end so the stub needs no knowledge of its own size: read the last 24 bytes, check the magic, and the payload lies directly before the footer, length bytes long.

The version covers the footer LAYOUT alone. The payload's format version stands in the .lyrbc header and is judged by the runtime inside the stub, with the same rules any runtime applies. The reserved field is written as zero and ignored on read, so a future minor can use it without breaking a deployed stub.

Three answers when the stub inspects its own file, and they are deliberately distinct:

What a packed program is

What packing is not

Failure duties

lyrpack refuses to overwrite either of its inputs, and a pack that fails midway deletes its half-written output: a file that starts and then reports itself empty or damaged must not be what a failed build leaves behind.