In this tutorial you build the Glyim compiler from source, create a new project with the glyip build tool, and run a Glyim program. You finish with a working toolchain and a mental model of the build workflow.
Prerequisites
Section titled “Prerequisites”- Rust — latest stable toolchain, 2024 edition. Rust 1.95 or newer is required; the declared MSRV is 1.95 (pinned in
Cargo.tomland enforced by the CImsrvjob). - LLVM 23 — required by the LLVM backend. The backend is a hard dependency of the workspace; there is no feature flag to build without it.
justandwatchexec— optional, only for the convenience recipes in the repository’sjustfile.
Before building, set LLVM_SYS_231_PREFIX to your LLVM 23 installation prefix:
export LLVM_SYS_231_PREFIX="$(brew --prefix llvm@23)"export LLVM_SYS_231_PREFIX="/usr/lib/llvm-23"Build the compiler
Section titled “Build the compiler”-
Clone the repository:
Terminal git clone https://github.com/elcoosp/glyimcd glyim -
Build the workspace in release mode:
Terminal cargo build --release -
Locate the compiler driver. The binary is at
target/release/glyim-cli— invoke it asglyim-cli(rename or symlink it toglyimif you prefer):Terminal ./target/release/glyim-cli --versionYou can also invoke the driver through Cargo on every call, which avoids symlinks:
Terminal cargo run -p glyim-cli -- --help
Create and run a project
Section titled “Create and run a project”glyip is Cargo’s counterpart for Glyim projects. It reads a Glyip.toml manifest, resolves dependencies, maintains a Glyip.lock lockfile, and drives the compiler.
-
Scaffold a new binary project:
Terminal cargo run -p glyip -- new hellocd hello -
Inspect what
glyip newgenerated. The project contains aGlyip.tomlmanifest and asrc/main.gsource file:Terminal cat Glyip.tomlcat src/main.g -
Build the project:
Terminal cargo run -p glyip -- build -
Run it:
Terminal cargo run -p glyip -- runglyip runis a transparent wrapper: it exits with the compiled program’s exit code, so a failing program does not look like a passing command.
What the scaffold looks like
Section titled “What the scaffold looks like”The scaffolded manifest declares the package and its targets:
[package]name = "hello"version = "0.1.0"edition = "2024"The default template produces a binary that prints a greeting. Edit src/main.g, rebuild, and run again — glyip build uses SHA-256 source fingerprints, so it recompiles only what changed.
Compile a single file directly
Section titled “Compile a single file directly”Once you are comfortable with glyip, you can bypass project management and drive the compiler directly. The equivalent of the tutorial so far, in one command:
glyim-cli src/main.g --emit exec -o hello./helloThe --emit exec flag produces a runnable executable; the default --emit obj produces an object file. See the CLI reference for every flag.
Next steps
Section titled “Next steps”You have a working toolchain. From here:
