Repository navigation
CMake rebuild script - #1003
CMake rebuild script#1003GMNGeoffrey wants to merge 3 commits into
Conversation
|
LGTM 👍 |
| # This uses previously cached build results and does not clear the build | ||
| # directory. For a clean build, use build_tools/cmake/clean_build.sh |
There was a problem hiding this comment.
Are there enough logs between set -x, the build environments, and CMake itself here? Want to include something explicit on whether there are or are not cached results?
There was a problem hiding this comment.
Good idea. Added logging.
| # Build the IREE project with CMake. Designed for CI, but can be run manually. | ||
| # This is equivalent to the build_tools/cmake/rebuild.sh script except it | ||
| # first deletes the build directory to deal with any faulty caching. |
There was a problem hiding this comment.
Wouldn't we want to use caching on CI if possible? If we switch from on-demand VM instances to persistent instances that keep local caches, we could see some big speedups to Bazel and CMake...
Are there specific instances of "faulty caching" that we've seen? I'd like to understand any such cases better.
How do other CMake projects handle caching on CI?
There was a problem hiding this comment.
We haven't up to this point, so I think that should be a separate decision. For now I just wanted to stop copy-pasting cmake commands from the script :-D
I seem to recall faulty caching at some point previously when working locally, but maybe that was when build options changed and rebuilding from modified source with the same options would be fine.
@marbre, what's your experience with cmake caching?
There was a problem hiding this comment.
Well the cmake projects where I had a CI available, I always triggered clean builds. Caching does works most times from my experiences, but I already had several cases locally where something wasn't rebuild as I expected. As a result, the clean build was broken which was only discovered because the build in the CI was broken... Furthermore, I am seeing Illegal Glob errer messages or something like this (cannot remember the exact message) locally from time to time, which might be a problem with the way we add the lit tests. So far the only thing that worked out for me to solve this was to perform a clean build...
There was a problem hiding this comment.
Yeah this is confirming my reluctance to try and use cmake caching
| # we can still run the other tests. | ||
| echo "Building with cmake" | ||
| ./build_tools/cmake/build.sh | ||
| ./build_tools/cmake/clean_build.sh |
There was a problem hiding this comment.
Relating to my comment above, you could comment here on why we don't want to use caching (or why it matters / doesn't matter).
There was a problem hiding this comment.
I think which script the CI uses can be a separate decision (PR) than splitting the scripts. For now this maintains the current behavior.
Rather than doing this as part of generating the files with bazel_to_cmake, we can just have each file add all its subdirectories. Only adds directories that have a CMakeLists.txt file (same as the current bazel_to_cmake logic). Depends on #1003 This has a few advantages: 1. We don't have to remember to update the CMakeLists file (or rerun bazel_to_cmake) when adding a directory. 2. Any directory's CMakeLists file is dependent only on the corresponding BUILD file (plus the previous version of the CMakeLists for instructions like "DO NOT EDIT" and the correct license year). 3. As a consequence of (2), there is no ordering dependence on the directories processed by bazel_to_cmake, so we can always only run it on directory's with modified BUILD files. 4. This makes it possible to integrate bazel_to_cmake as a hermetic genrule with in bazel (with a few additional tweaks). It shifts more work onto the cmake side (away from generation), however. To make sure it doesn't increase build times as a result, I tested out the comparative build times on my workstation. There is no substantial difference. Also it still runs the same number of tests (and they all pass). Configure only: ```shell $ rm -rf build/ && mkdir build && cd build && time cmake -G Ninja -DCMAKE_BUILD_TYPE=FastBuild -DIREE_BUILD_COMPILER=ON -DIREE_BUILD_TESTS=ON -DIREE_BUILD_SAMPLES=OFF -DIREE_BUILD_DEBUGGER=OFF .. ``` Before: ```shell real 0m25.487s user 0m17.906s sys 0m7.606s ``` After: ```shell real 0m25.418s user 0m17.844s sys 0m7.599s ``` Clean build: ```shell $ time ./build_tools/cmake/clean_build.sh ``` Before: ```shell real 6m36.789s user 63m54.858s sys 3m52.994s ``` After: ```shell real 6m38.352s user 63m55.938s sys 3m50.222s ``` Rebuild (no changes): ```shell $ time ./build_tools/cmake/rebuild.sh ``` Before: ```shell real 1m36.174s user 13m7.361s sys 1m2.658s ``` After: ```shell real 1m35.235s user 13m5.488s sys 1m3.178s ``` Test ```shell $ time ./build_tools/cmake/test.sh ``` Before: ```shell 100% tests passed, 0 tests failed out of 211 Total Test time (real) = 4.10 sec real 0m4.140s user 0m16.732s sys 0m13.647s ``` After: ```shell 100% tests passed, 0 tests failed out of 211 Total Test time (real) = 4.04 sec real 0m4.089s user 0m16.738s sys 0m13.516s ``` Closes #1002 COPYBARA_INTEGRATE_REVIEW=#1002 from GMNGeoffrey:bazel-to-cmake 8c38f88 PiperOrigin-RevId: 299888098
When iterating locally, it's useful to rebuild and rely on CMake's caching rather than doing a full clean build. CMake's caching is a bit sketchy sometimes, so it's also useful to do a full clean build. Split things out so we have a script for each.
Depends on #1001