Skip to content

e3m3/mlir-rust

Repository files navigation

Copyright

Copyright 2024-2025, Giordano Salvador SPDX-License-Identifier: BSD-3-Clause

Author/Maintainer: Giordano Salvador 73959795+e3m3@users.noreply.github.com

Description

Fedora 41

MacOS 14

Rust library and bindings implementing the MLIR [1] (license [2]) compiler framework. Uses the C API bindings from the mlir_sys crate (site [3] and license [4]).

Documentation

Read the API at https://e3m3.github.io/mlir-rust/mlir/.

Prerequisites

  • rust-2024

  • llvm-19, clang-19, and mlir-sys (or llvm version matching mlir-sys)

  • libxml2 and libz headers (for testing)

  • num_cpus (for testing)

  • python3-lit, FileCheck (for testing)

    • By default, tests/lit-tests.rs will search for the lit executable in $PYTHON_VENV_PATH/bin (if it exists) or the system's /usr/bin.
  • [docker|podman] (for testing/containerization)

    • A Fedora [5] image can be built using containers/Containerfile.fedora*.

Setup

  • Native build:

    cargo build
  • Build Rust lit tests:

    cargo build --manifest-path tests/lit-tests-rust/Cargo.toml
  • Run Rust lit test (e.g., tests/lit-tests-rust/src/<test-name>.lit-rs:

    cargo run --manifest-path tests/lit-tests-rust/Cargo.toml -- <test-name>
  • Build and run lit test suite (MLIR + Rust):

    cargo test -- --nocapture
  • Container build and test podman [6]:

    podman build -t mlir-rust -f container/Containerfile .
  • Container build and test docker [7]:

    docker build -t mlir-rust -f container/Dockerfile .
  • If make is installed, you can build the image by running:

    make

References

  1. https://mlir.llvm.org/

  2. https://github.com/llvm/llvm-project/blob/main/mlir/LICENSE.TXT

  3. https://crates.io/crates/mlir-sys

  4. https://github.com/mlir-rs/mlir-sys/blob/main/LICENSE

  5. https://fedoraproject.org/

  6. https://podman.io/

  7. https://www.docker.com/