Repository navigation
Rework cmake test deps, target selection and presets. - #8423
Conversation
This patch does a few things: * Marks all targets under iree/test/ as EXCLUDE_FROM_ALL. * Configures check-tests to add a dependency to the global iree-test-deps target. * Added a seperate build step for CIs to build iree-test-deps. * Reworks compiler target selection to distinguish between "default" targets and those not built by default. * Fine-grained LLVM_TARGETS_TO_BUILD are added based on the IREE targets. * lld is built if CPU targets are enabled. * CPU targets are expanded from a new IREE_CPU_LLVM_TARGETS option (defaults to what we had previously hard-coded). In several places, we had hard-coded assumptions about the above. Fixes include: * Conditional inclusion of lld related things when lld is actually build (gated on an IREE_LLD_TARGET variable). * C++ code to initialize LLVM code generation was not generic based on targets actually available. Now it is. * Added bazel-to-cmake diversions for codegen targets that are hard-coded in Bazel to an IREELLVMCPUTargetDeps, which is manually populated with what is actually built (note that the LLVM build system has a more declarative way to do this but it is incompatible with ours). * Gate populating any CPU LLVM backends on IREE_CPU_LLVM_TARGETS_DEFAULTS as it layers better with the wonky CMake preset system. Adds CMakePresets.json. This is experimental but encoded some of our getting started configurations: * minimal: Disables all optional compiler features and samples. * clang-dev: Recommended clang dev settings (enables ninja/clang/lld/ccache and defaults to RelWithDebInfo and assertions). * minimal-clang-dev: Combination of the first two. * x86-clang-dev: The first two plus options to enable CPU compilation on x86. Presets can be set with something like (requires CMake 3.21+): ``` cmake -B../iree-build --preset x86-clang-dev ``` The setup is a bit wonky, but we can add more for common cases, and it is just starting points. Users can flip options from there. With all of the above, the build is down to ~3200 files for `minimal-clang-dev` (only vmvx compilation is enabled) and ~3800 for `x86-clang-dev` (only vmvx and cpu/x86 enabled). Will probably take some more fiddling to find good defaults.
ScottTodd
left a comment
There was a problem hiding this comment.
Nice, thanks for narrowing the LLVM target deps.
|
This is awesome. Really looking forward to not have to build all backends, but just the CPU backends for my in-progress big change to backends. Having to get all tests to build before I can even run the tests is really getting in the way for me! |
…ng in multiple factors of disk thrash savings).
|
going to give this a try first |
benvanik
left a comment
There was a problem hiding this comment.
Let's hold off on the cmake presets file - unless there's a pressing need I'd say what's in there today should just be in your local CMakeUserPresets.json if you want to use presets. Adding a global presets file fundamentally changes CLion/vscode/etc behavior and is pretty disruptive so it should be added with care (this file being present in the repo makes it so I can't build anything on Windows, for example, without going and forcing presets to be disabled in my vscode settings) - it's a lot less like a bazelrc than one coming from bazel may first think :) If you think it's really useful as-is then you'll need to rename it to CMakePresets.json.example or something so it doesn't break others by default.
I've got a sketch from awhile back that I'd like to revive that decomposes things to make more sense in IDEs w/ cross-compilation and be usable from CMakeUserPresets.json (which can inherit the base CMakePresets.json to allow for local configuration). I'll fiddle with that a bit more.
Ugh, no good deed. But thanks for checking. I'll pop this out of the patch then in some fashion. Some of the stuff in here is insanely useful and hard to get otherwise (i.e. to the tune of halving ~build/link overheads on Linux), but we can figure out how to walk it forward. I guess I'll need to try the IDE/GUI way to really understand how this is so messed up... it is pretty straight-forward from the CLI. |
|
Yeah, sorry - it's traditional cmake: close enough to make you think it's good but then flawed enough to make you realize nothing will ever be good :P There's some new support I just noticed while fiddling for conditional enablement of configs/builds - that should make it easier to not present msvc on mac and gcc on windows etc and get us a reasonable set of things. Will share some stuff ... after perf... this is too enticing.... |
Yeah, i just thought I already stumbled through the sharp parts. I failed to factor in that it is all sharp parts. |
|
PTAL |
| echo "Building test deps" | ||
| echo "------------------" | ||
| "${CMAKE_BIN?}" --build "${CMAKE_BUILD_DIR?}" --target iree-test-deps -- -k 0 |
There was a problem hiding this comment.
I have a feeling that a few other scripts should also build this new iree-test-deps target.
@GMNGeoffrey can you review that part of this also?
There was a problem hiding this comment.
If they aren't in the CI, we'll just have to be on a voyage of self discovery on that. CTest does show a useful error on these situations (it says that a test input is not available and marks the test as "not run" and counts those as failures).
There was a problem hiding this comment.
Ah, they're in the postsubmit CI:
- https://source.cloud.google.com/results/invocations/5908ee89-14b5-4432-9df4-fdb612ddf4ec/targets/iree%2Fgcp_ubuntu%2Fcmake%2Flinux%2Fx86-turing%2Fmain/log
- https://buildkite.com/iree/iree-android-arm64-v8a/builds/5827#3db40535-3a0d-4086-b4c0-17d64b4c21b1
Should fix `iree/gcp_ubuntu/cmake/linux/x86-turing/main[default]` and `iree/iree-android-arm64-v8a` by adding `"$CMAKE_BIN" --build . --target iree-test-deps -- -k 0` steps to each.
This list of CMake options was moved into their own file in #8423, for inclusion in `llvm-external-projects/iree-compiler-api/CMakeLists.txt`, which used an "out of tree" build setup. The `llvm-external-projects/iree-compiler-api/` directory was then moved back "in tree" to `iree/compiler/API` in #8911. We can now move the options back into the root file, where they will be easier to read alongside other high level project options.
This patch does a few things:
Marks all targets under iree/test/ as EXCLUDE_FROM_ALL.
Configures check-tests to add a dependency to the global iree-test-deps target.
Reworks compiler target selection to distinguish between "default" targets and those not built by default.
Layered CMake options for LLVM so that they are forward and backwards compatible with CMP0126 and work for nested inclusion from another project.
Fixed up some old stuff in iree-compiler-api and brought it up to spec for the above changed.
In several places, we had hard-coded assumptions about the above. Fixes include: