This guide walks through building the core compiler and runtime parts of IREE from source. Auxiliary components like the Python bindings and Vulkan driver are documented separately, as they require further setup.
Install Bazel version > 2.0.0 (see .bazelversion
for the specific version IREE uses) by following the official docs.
We recommend Clang. GCC is not fully supported.
$ sudo apt install clang
Set environment variables for Bazel:
export CC=clang export CXX=clang++
$ python3 -m pip install numpy
Clone the repository, initialize its submodules and configure:
$ git clone https://github.com/google/iree.git $ cd iree $ git submodule update --init $ python3 configure_bazel.py
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 iree/...
Tip:
You can add flags like--test_env=IREE_VULKAN_DISABLE=1
to your test command to change how/which tests run.
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 Linux are:
build --disk_cache=/tmp/bazel-cache # Use --config=debug to compile IREE and LLVM without optimizations # and with assertions enabled. build:debug --config=asserts --compilation_mode=opt '--per_file_copt=iree|llvm@-O0' --strip=never # Use --config=asserts to enable assertions. This has to be done globally: # Code compiled with and without assertions can't be linked together (ODR violation). build:asserts --compilation_mode=opt '--copt=-UNDEBUG'
Build all of IREE's ‘tools’ directory:
$ bazel build iree/tools/...
Check out what was built:
$ ls bazel-bin/iree/tools/ $ ./bazel-bin/iree/tools/iree-translate --help
Translate a MLIR file and execute a function in the compiled module:
$ ./bazel-bin/iree/tools/iree-run-mlir ./iree/tools/test/iree-run-mlir.mlir \ -function-input="i32=-2" -iree-hal-target-backends=vmvx -print-mlir