This guide walks through building the core compiler and runtime parts of IREE from source. Auxilary components like the Python bindings and Vulkan driver are documented separately, as they require further setup.
Tip:
You can simplify installation by using a package manager like Scoop or Chocolatey.
Install Bazel version > 2.0.0 (see .bazelversion for the specific version IREE uses) by following the official docs.
Also install MSYS2 by following Bazel's documentation.
Install the full Visual Studio or “Build Tools For Visual Studio” from the downloads page.
Set a few environment variables. You are welcome to configure these however you choose. For example, you could set them as system or user level environment variables through your “System Properties” or you could use a shell such as PowerShell or cmder). Setting them through PowerShell would look like this:
> $env:BAZEL_VS = "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" > $env:USE_CLANG_CL = 1
Using your shell of choice (such as PowerShell or cmder), clone the repository and initialize its submodules:
> git clone https://github.com/google/iree.git > cd iree > git submodule update --init
Tip:
Editors and other programs can also clone the repository, just make sure that they initialize the submodules.
Run all core tests:
> bazel test -k --config=windows iree/...
In general, build artifacts will be under the bazel-bin
directory at the top level.
You can put a user.bazelrc at the root of the repository and it will be ignored by git. The recommended contents for Windows are:
build --config=windows build --disk_cache=c:/bazelcache build:debug --compilation_mode=dbg --copt=/O2 --per_file_copt=iree@/Od --strip=never
Build all of IREE's ‘tools’ directory:
> bazel build iree/tools/...
Check out what was built:
> dir bazel-bin\iree\tools\ > .\bazel-bin\iree\tools\iree-translate.exe --help
Translate a MLIR file and execute a function in the compiled module:
> .\bazel-bin\iree\tools\iree-run-mlir.exe .\iree\tools\test\simple.mlir -input-value="i32=-2" -iree-hal-target-backends=vmla -print-mlir