Skip to content

Getting Started with Glyim

Tutorial2 min read
Edit page

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.

  • Rust — latest stable toolchain, 2024 edition. Rust 1.95 or newer is required; the declared MSRV is 1.95 (pinned in Cargo.toml and enforced by the CI msrv job).
  • 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.
  • just and watchexec — optional, only for the convenience recipes in the repository’s justfile.

Before building, set LLVM_SYS_231_PREFIX to your LLVM 23 installation prefix:

Terminal
export LLVM_SYS_231_PREFIX="$(brew --prefix llvm@23)"
  1. Clone the repository:

    Terminal
    git clone https://github.com/elcoosp/glyim
    cd glyim
  2. Build the workspace in release mode:

    Terminal
    cargo build --release
  3. Locate the compiler driver. The binary is at target/release/glyim-cli — invoke it as glyim-cli (rename or symlink it to glyim if you prefer):

    Terminal
    ./target/release/glyim-cli --version

    You can also invoke the driver through Cargo on every call, which avoids symlinks:

    Terminal
    cargo run -p glyim-cli -- --help

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.

  1. Scaffold a new binary project:

    Terminal
    cargo run -p glyip -- new hello
    cd hello
  2. Inspect what glyip new generated. The project contains a Glyip.toml manifest and a src/main.g source file:

    Terminal
    cat Glyip.toml
    cat src/main.g
  3. Build the project:

    Terminal
    cargo run -p glyip -- build
  4. Run it:

    Terminal
    cargo run -p glyip -- run

    glyip run is a transparent wrapper: it exits with the compiled program’s exit code, so a failing program does not look like a passing command.

The scaffolded manifest declares the package and its targets:

Glyip.toml
[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.

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:

Terminal
glyim-cli src/main.g --emit exec -o hello
./hello

The --emit exec flag produces a runnable executable; the default --emit obj produces an object file. See the CLI reference for every flag.

You have a working toolchain. From here: