#llvm #bundler #mlir #automatic #topological-sorting #environment-setup

bin+lib llvm-bundler-rs

A bundler to download automatically LLVM and MLIR

1 unstable release

Uses new Rust 2024

0.2.0 Jun 11, 2025

#1092 in Development tools

Download history 634/week @ 2025-09-18 399/week @ 2025-09-25 181/week @ 2025-10-02 119/week @ 2025-10-09 136/week @ 2025-10-16 104/week @ 2025-10-23 65/week @ 2025-10-30 101/week @ 2025-11-06 41/week @ 2025-11-13 87/week @ 2025-11-20 42/week @ 2025-11-27 37/week @ 2025-12-04 47/week @ 2025-12-11 20/week @ 2025-12-18 12/week @ 2025-12-25 8/week @ 2026-01-01

101 downloads per month

MIT/Apache

22KB
208 lines

llvm-bundler-rs

llvm-bundler-rs is a Rust crate designed to automatically bundle LLVM and statically link MLIR into your project. By downloading prebuilt LLVM artifacts and configuring the necessary environment variables, it simplifies the setup process for projects that rely on LLVM and MLIR tooling.

Features

  • Automatic LLVM Bundling: Downloads and decompresses prebuilt LLVM artifacts (currently using Linux x64 tarballs) from a GitHub release.
  • Static Linking for MLIR: Configures environment variables to link LLVM and MLIR libraries properly with the correct order by parsing the CMake with a Regex and doing a topological sort.

Installation

Add llvm-bundler-rs to your project's Cargo.toml and use it in your build.rs to compile in the right order:

[dev-dependencies]
llvm-bundler-rs = "0.1.0"

To set the env variable and download if missing:

llvm_bundler_rs::bundler::bundle_cache()?;

To get the compile order of MLIR .a:

use llvm_bundler_rs::{dependency_graph::DependencyGraph, topological_sort::TopologicalSort};

let prefix =
    Path::new(&env::var(format!("MLIR_SYS_{LLVM_MAJOR_VERSION}0_PREFIX")).unwrap_or_default())
        .join("lib")
        .join("cmake")
        .join("mlir")
        .join("MLIRTargets.cmake");
let path = DependencyGraph::from_cmake(prefix)?;
let mlirlib = TopologicalSort::get_ordered_list(&path);

Dependencies

~2–23MB
~292K SLoC