How to build minimal build of MLIR?

The MLIR documentation indicates that MLIR’s only third-party dependency is on the LLVM support library. But the instructions on getting started seem to force building the entirety of LLVM for the host hardware.

Are there instructions somewhere on how to build MLIR with only the LLVM support library, and not the rest of LLVM?

I produced some minimal examples recently here: https://github.com/llvm/llvm-project/tree/main/mlir/examples/minimal-opt

I was looking for a way to shrink the MLIR build-and-install time. It looks like with -DLLVM_ENABLE_PROJECTS=mlir and -DLLVM_TARGETS_TO_BUILD="Native", I will end up building lots of LLVM stuff. E.g., I see lots of .o files being built in lib/Analysis/CMakeFiles/LLVMAnalysis.dir/ that presumably have nothing to do with MLIR. Time for just a debug build is over an hour for me. That’s with g++. I can try the changes to force use of clang++.

LLVM is configured, so ninja alone will build all of LLVM.
There is no strict definition of “MLIR without LLVM” and so there isn’t a build target to this.
Since the MLIR tests are including some integrations tests we end up building most of LLVM to be able to run these tests. We also have a JIT integration in MLIR, and so building this library will depend on the LLVM optimizer/codegen as well.
This is why I wrote the examples, building ninja mlir-minimal-opt should not build any of LLVM hopefully.

Thanks, ninja mlir-minimal-opt did the trick.
For beginners like me, here are the commands to build mlir-minimal-opt after a fresh checkout of llvm-project:

cd llvm-project
mkdir build
cd build
cmake ../llvm/ -G Ninja \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DLLVM_CCACHE_BUILD=ON \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="Native" \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DLLVM_ENABLE_LLD=ON \
   -DLLVM_ENABLE_BACKTRACES=OFF \
   -DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO=-Wl,-icf=all
ninja mlir-minimal-opt