// CONTENTS Part 00 · Start here

// PART 00

Build system

Chapter 04 / 56 3 min read English Part 00 of 14

The build is Cargo, one workspace, one lockfile. What varies between machines is the toolchain (clang + mold), the parallelism setting, and which Cargo features you select.

Build and publish pipeline

Prerequisites

  • Rust — install via rustup (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh), 2021 edition.
  • C/C++ toolchain and libraries (Ubuntu/Debian):
sudo apt update
sudo apt install -y clang lld mold build-essential pkg-config \
    libssl-dev libpq-dev cmake git
  • Desktop/GTK libraries — only needed for Tauri desktop builds (libwebkit2gtk-4.1-dev and friends); server builds do not require them. The webkit2gtk package must be the 4.1 series.
  • PostgreSQL client library — libpq-dev (Windows builds expect libpq under C:\pgsql\pgsql\lib, wired in .cargo/config.toml).

The build configuration that ships with the repo

.cargo/config.toml at the repository root is the single source of truth for local builds and CI:

[build]
jobs = 3                # project default; do not override unless the host cannot fit it

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]

clang is required because rustc on Debian passes -fuse-ld=lld, which a bare gcc driver cannot resolve; mold links the ~280 MB dev binary far faster than GNU ld. On a host where rustc is killed for memory, the documented exception is CARGO_BUILD_JOBS=1 (or 2) for that host only — do not edit the config file for it.

Build commands

cargo build -p botserver                          # debug dev build (target/debug/botserver)
cargo build -p botserver --release                # optimized build
cargo build -p botserver --no-default-features --features minimal   # smallest chat-only server
cargo check -p <crate>                            # syntax/type gate, no codegen

The release profile (Cargo.toml) optimizes for size and startup: opt-level = "z", lto = true, codegen-units = 1, strip = true, panic = "abort". Never build release locally for development work — debug builds are the documented default; release is the packaging pipeline’s job.

Verify the binary

./target/debug/botserver --version
# botserver 7.1.2

The version is [workspace.package] version in the root Cargo.toml — currently 7.1.2. A guard script fails any documentation that quotes a different product version, which is why this book never hardcodes one outside the manifest.

Codegen, vendored crates and submodules

  • The two office-document crates are vendored under 3rdparty/ with a patch and are excluded from the workspace on purpose; do not move them.
  • Cloning with --recursive (or git submodule update --init --recursive) is the safe form if submodules are in play.
  • Generated documentation sources live under botbook/src/08-rest-api-tools/generated/ and friends; they are regenerated by scripts/gen_*.py, never edited by hand.

Quick reference

Command Purpose
cargo build -p botserver Dev build, target/debug/botserver
cargo build -p botserver --release Optimized build (packaging)
cargo check -p <crate> Fast type gate
cargo clippy --workspace Lint gate — must pass with 0 warnings
cargo fmt Format
cargo test -p <crate> Test a library crate
cargo test -p botserver --bin botserver Binary-crate unit tests
sccache --show-stats Compiler cache hits (ephemeral CI)

Next steps

After the build: run Diesel migrations, start the stack, and read Module and service structure to see what the binary mounts at boot.

Found a mistake? Open an issue · All books

// SEARCH ESC
Pagefind · 236 pages · 4 books Enter to open ↑ ↓ to move