C/C++ toolchains(compiler, linker etc.)cmakemakeorninja.lit(optional for testing)
1. Configuration:
make config # generate configuration file at build/config.cmake2. Build LLVM, MLIR and Clang:
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS="mlir;clang" \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=DEBUG
ninja
ninja check-mlirFor faster compilation,it is recommended to use -DLLVM_USE_LINKER=lld.
3. Build cmlirc:
makeOr manually follow this:
mkdir build
cd build
cmake -G Ninja ..
ninja1. Configuration:
make config # generate configuration file at build/config.cmakeSpecify the PATH in config.cmake.
# Build configuration options
# NOTE: set(LLVM_BUILD_DIR path/to/your/pre-built/installation) # if you're using your pre-built installation.
set(LLVM_BUILD_DIR ${CMAKE_SOURCE_DIR}/llvm-project/build) # If you're building this proj from scratch, you should not change it
# Compilation options
set(USE_CCACHE ON)
# Build options
set(BUILD_EXECUTABLES ON)
set(ENABLE_TESTING ON) # Set it ON to enable testing
# Derived paths
# NOTE: you can force cmake to overwrite these PATHs
set(LLVM_DIR ${LLVM_BUILD_DIR}/lib/cmake/llvm)
set(MLIR_DIR ${LLVM_BUILD_DIR}/lib/cmake/mlir)
set(Clang_DIR ${LLVM_BUILD_DIR}/lib/cmake/clang)2. Build cmlirc:
makeOr manually follow this:
mkdir build
cd build
cmake -G Ninja ..
ninja1. Install lit
Activate a python virtual env(venv, conda, uv etc.) and install lit using pip:
pip install lit2. Run tests
make testOr manually follow this:
cd build
ninja check-cmlirc- This work is inspired by Polygeist
Copyright 2026 dashygo097
Licensed under the Apache License, Version 2.0. See LICENSE for details.