Add an option to disable use of bundled LLVM. (#12256)
* Adds an option `IREE_BUILD_BUNDLED_LLVM` (default ON) which builds
LLVM+tools from the in-repo submodule (`third_party/llvm-project`). When
disabled, CMake must be configured such that find_package for `LLVM`,
`MLIR`, and `LLD` functions and are at commit levels appropriate.
* Re-organizes the LLVM cmake setup to be better contained and
normalized vs in-tree/bundled and installed.
* Switches MLIR sub-projects iree-dialects, mlir-hlo and torch-dialects
to configure from the main IREE build so that they can be used on top of
a locally built or installed LLVM.
* Updates mechanisms for locating lit so that it is consistent between
the two modes.
* Moves the binary directory for `third_party/llvm-project/llvm` ->
`llvm-project`. This means that folks interacting with the bundled LLVM
in the build directory will say things like `ninja llvm-project/all` or
`./llvm-project/bin/mlir-opt`.
* Moves the MLIR sub-projects from under
`llvm-project/tools/{subproject}` ->
`llvm-external-projects/{subproject}` so that it is consistent between
bundled and installed modes. Practically, this means that if invoking
`iree-dialects-opt` from the command line, it is in a different place.
* Fix to a transform dialect ODR issue which was latent and a namespace
conflict with upstream. Not sure what triggered it but put it down to
the vagaries of linking.
* Fix to the VMVX dependent dialects that came up when building IREE
with all backends disabled.
With this, I was able to install my own LLVM with these commands:
```
cd third_party/llvm-project
mkdir build
cd build
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS="mlir;lld" \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_TARGETS_TO_BUILD="" \
-DLLVM_INSTALL_UTILS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON \
-DLLVM_CCACHE_BUILD=ON
ninja
cmake -DCMAKE_INSTALL_PREFIX=$HOME/tmp/llvm -P cmake_install.cmake
```
```
cmake -GNinja -B ../iree-build-inst/ -S . \
-DIREE_TARGET_BACKEND_DEFAULTS=OFF \
-DIREE_HAL_DRIVER_DEFAULTS=OFF \
-DIREE_HAL_DRIVER_LOCAL_SYNC=ON \
-DIREE_HAL_DRIVER_LOCAL_TASK=ON \
-DIREE_BUILD_BUNDLED_LLVM=OFF \
-DLLVM_DIR=$HOME/tmp/llvm/lib/cmake/llvm \
-DMLIR_DIR=$HOME/tmp/llvm/lib/cmake/mlir \
-DLLD_DIR=$HOME/tmp/llvm/lib/cmake/lld \
-DCMAKE_BUILD_TYPE=Release
```
* Python builds have not yet been tested in the installed path and need
some ergonomic help.
* Will follow-up with a script to build various configurations of
LLVM/MLIR/LLD so that we can wire it up to CI.
Progress on #12231IREE (Intermediate Representation Execution Environment, pronounced as “eerie”) is an MLIR-based end-to-end compiler and runtime that lowers Machine Learning (ML) models to a unified IR that scales up to meet the needs of the datacenter and down to satisfy the constraints and special considerations of mobile and edge deployments.
See our website for project details, user guides, and instructions on building from source.
IREE is still in its early phase. We have settled down on the overarching infrastructure and are actively improving various software components as well as project logistics. It is still quite far from ready for everyday use and is made available without any support at the moment. With that said, we welcome any kind of feedback on any communication channels!
See our website for more information.
IREE is licensed under the terms of the Apache 2.0 License with LLVM Exceptions. See LICENSE for more information.