Menu

Appendix C — Toolchain Setup (current procedure)

Toolchain and QEMU setup: building from source, the two tracks, and the commands used in the book.

Typereference

Temporary by the project’s own roadmap: a script/rustup-style installer will replace this procedure. Until then, this is the setup this book’s labs were verified with.

# Build the toolchain

Prerequisites: Rust (pinned by rust-toolchain.toml), fasm (flat assembler), GNU ld, cc, and — for the QEMU track and the metal interludes — qemu-system-x86_64 plus the cross binutils (gcc-arm-none-eabi, gcc-riscv64-unknown-elf).

$ cargo build --release -p langc -p tyu -p lmod-pack -p lmod-sign -p lmod-encrypt
$ export PATH="$PWD/target/release:$PATH"     # tyu finds langc on PATH
$ langc --help
$ tyu help

# The two tracks

  • Hosted (most labs): --target=x86_64-unknown-linux-gnu — builds and runs on the computer, no simulator.
  • QEMU metal (chapters 8 and 6’s interlude): --target=x86_64-unknown-none --platform=x86_64-unknown-none — runs under qemu-system-x86_64.

# The commands used in this book

# build + direct run (hosted)
$ tyu build labs/.../lab.mod --target=x86_64-unknown-linux-gnu \
      --sysroot=sysroot --out-dir=build/<name>
$ ./build/<name>/image.elf

# harness run (checks the S marker, classifies the verdict)
$ tyu run labs/.../lab.mod --target=x86_64-unknown-linux-gnu \
      --sysroot=sysroot --out-dir=build/<name>

# MMIO chapters: name the platform pack, and use static link mode
$ tyu test --manifest=labs/ch08/manifest.toml \
      --target=x86_64-unknown-none --platform=x86_64-unknown-none \
      --mode=static

# inspection (the debugging habit of ch. 2)
$ langc --emit=tc labs/.../lab.mod --sysroot=sysroot   # per-term stack trace
$ langc --emit=ir labs/.../lab.mod --sysroot=sysroot   # IR dump

# A project manifest (optional)

tyu.toml in a project directory removes the repeated flags:

[project]
main = "src/main.mod"
modules = ["src/"]

[targets.dev]
triple = "x86_64-unknown-linux-gnu"

[profile.dev]
features = ["concurrency", "module-loading"]

[toolchain.x86_64-unknown-none]
qemu = "qemu-system-x86_64"

Run from the project root with tyu run src/main.mod --profile=dev.

# Clean state

Stale builds: delete the lab’s --out-dir (each lab keeps its own) or tyu clean. The test harness builds fixtures in fresh temporary directories by design — two modules with the same module name sharing one out-dir can silently reuse a neighbor’s object.

# The test suites the book quotes

$ cargo test -p execution-tests --test dynamic_signed      # ch. 13, signed load
$ cargo test -p execution-tests --test dynamic_negative    # ch. 13, refusals
$ cargo test -p execution-tests --test dynamic_encrypted   # ch. 13, at rest
On this page