Build functioning dev packages for IREECompiler and IREERuntime. (#16008)
With this patch, external projects can do:
```
find_package(IREECompiler)
find_package(IREERuntime)
```
and access our targets by adding either the build or install tree
`lib/cmake/IREE` to the CMake package search path.
There are still some ergonomic issues that need to be addressed going
forward:
* cpuinfo breaks the one downstream I am testing this against. We really
should just finish killing that, so I am setting
-DIREE_ENABLE_CPUINFO=OFF in the dist package.
* We are not yet re-establishing the pretty `iree::runtime:...` aliases.
The underscore versions are available (`iree_runtime_...`).
* I want to further isolate the remaining bundled deps (yaml and
flatcc).
* New convenience install targets do not have full dependency
information. Need to do an `all` build first.
As part of this, I did some longstanding cleanups:
* Normalized the install component namespace. Defined
`IREECMakeExports`, `IREEDevLibraries-Compiler`,
`IREEDevLibraries-Runtime`, `IREERuntimeLibraries-Compiler`,
`IREEBundledLibraries`, `IREETools-Runtime`.
* Added convenience `iree-install-*` targets. Each includes a
`-stripped` variant as well.
* Moved MLIRInterop.h to the bindings/c directory where it should have
been all along and straightened the deps.
* Install the mlir-c headers to support libIREECompiler.so dev.
* Added the "busybox" tool binaries to the install distribution
(iree-lld, etc).
* Stopped bundling upstream `lld` and `clang` by default because they
bloat the size. `lld` is now bundled as `iree-lld` just like in the
Python packages. Clang and llvm-link can be gotten by installing the new
`IREETools-CompilerExtra` component if folks need those.
Note that this only installs public headers and libraries needed to
build against the compiler and runtime. Installing private things needed
to develop parts of the system are out of scope.
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 84c1a85..20518eb 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -65,6 +65,7 @@
iree::tooling::device_util
iree::tooling::vm_util
iree::vm
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -87,6 +88,7 @@
iree::tooling::yaml_util
iree::vm
yaml
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -123,6 +125,7 @@
iree::io::parameter_index
iree::io::scope_map
iree::tooling::parameter_util
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -134,6 +137,7 @@
iree::base
iree::base::internal::cpu
iree::schemas::cpu_data
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -150,6 +154,7 @@
iree::io::parameter_index
iree::io::scope_map
iree::io::stream
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -164,6 +169,7 @@
iree::base::internal::flatcc::parsing
iree::schemas::instruments
iree::schemas::instruments::dispatch_def_c_fbs
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -180,6 +186,7 @@
iree::base::internal::flatcc::parsing
iree::schemas::bytecode_module_def_c_fbs
iree::vm::bytecode::module
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -194,6 +201,7 @@
iree::io::parameter_index
iree::io::scope_map
iree::tooling::parameter_util
+ INSTALL_COMPONENT IREETools-Runtime
)
# Only enable fatelf tool when we're compiling it in.
@@ -211,6 +219,7 @@
iree::base::internal::file_io
iree::base::internal::path
iree::hal::local::elf::elf_module
+ INSTALL_COMPONENT IREETools-Runtime
)
endif() # IREE_HAL_EXECUTABLE_*_EMBEDDED_ELF
@@ -226,6 +235,7 @@
iree::tooling::context_util
iree::tooling::run_module
iree::vm
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -245,6 +255,7 @@
iree::tooling::yaml_util
iree::vm
yaml
+ INSTALL_COMPONENT IREETools-Runtime
)
iree_cc_binary(
@@ -268,20 +279,10 @@
)
if(IREE_BUILD_COMPILER)
- # If a target backend that requires LLD to link codegen executables is
- # enabled, install the target.
- if(IREE_LLD_TARGET)
- install(
- TARGETS lld
- COMPONENT Compiler
- RUNTIME DESTINATION bin
- )
- endif()
-
if(IREE_LLVM_LINK_TARGET)
install(
TARGETS llvm-link
- COMPONENT Compiler
+ COMPONENT IREETools-CompilerExtra
RUNTIME DESTINATION bin
)
endif()
@@ -289,7 +290,7 @@
if(IREE_CLANG_TARGET)
install(
TARGETS clang
- COMPONENT Compiler
+ COMPONENT IREETools-CompilerExtra
RUNTIME DESTINATION bin
)
endif()
@@ -312,6 +313,7 @@
MLIRTblgenLib
HOSTONLY
DISABLE_LLVM_LINK_LLVM_DYLIB
+ INSTALL_COMPONENT IREETools-CompilerDev
)
iree_cc_binary(
@@ -326,6 +328,7 @@
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
+ INSTALL_COMPONENT IREETools-Compiler
)
iree_cc_binary(
@@ -340,8 +343,27 @@
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
+ INSTALL_COMPONENT IREETools-Compiler
)
+ # Only build IREE's busybox lld if the backing LLVM has LLD enabled.
+ # Otherwise, it will build but fail at runtime saying that it is not
+ # supported, and this fouls up tools search heuristics.
+ if(IREE_LLD_TARGET)
+ iree_cc_binary(
+ NAME
+ iree-lld
+ SRCS
+ "iree-lld-main.cc"
+ DEPS
+ iree::compiler::bindings::c::headers
+ iree::compiler::API::Impl
+ HOSTONLY
+ SETUP_INSTALL_RPATH
+ INSTALL_COMPONENT IREETools-Compiler
+ )
+ endif()
+
iree_cc_binary(
NAME
iree-opt
@@ -354,6 +376,7 @@
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
+ INSTALL_COMPONENT IREETools-Compiler
)
iree_cc_binary(
@@ -365,6 +388,7 @@
iree::compiler::bindings::c::headers
iree::compiler::API::Impl
SETUP_INSTALL_RPATH
+ INSTALL_COMPONENT IREETools-Compiler
)
iree_cc_binary(
@@ -386,6 +410,7 @@
${IREE_LLD_TARGET}
HOSTONLY
SETUP_INSTALL_RPATH
+ INSTALL_COMPONENT IREETools-Compiler
)
# Ensure FileCheck and associated binaries get built. Tests don't have