Skip to content

CMake function to add all subdirectories - #1002

Closed
GMNGeoffrey wants to merge 2 commits into
iree-org:masterfrom
GMNGeoffrey:bazel-to-cmake
Closed

GMNGeoffrey wants to merge 2 commits into
iree-org:masterfrom
GMNGeoffrey:bazel-to-cmake

Conversation

@GMNGeoffrey

@GMNGeoffrey GMNGeoffrey commented Mar 8, 2020 •

Copy link
Copy Markdown
Member

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:

$ 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:

real	0m25.487s
user	0m17.906s
sys	0m7.606s

After:

real	0m25.418s
user	0m17.844s
sys	0m7.599s

Clean build:

$ time ./build_tools/cmake/clean_build.sh

Before:

real	6m36.789s
user	63m54.858s
sys	3m52.994s

After:

real	6m38.352s
user	63m55.938s
sys	3m50.222s

Rebuild (no changes):

$ time ./build_tools/cmake/rebuild.sh

Before:

real	1m36.174s
user	13m7.361s
sys	1m2.658s

After:

real	1m35.235s
user	13m5.488s
sys	1m3.178s

Test

$ time ./build_tools/cmake/test.sh

Before:

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:

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

@GMNGeoffrey
GMNGeoffrey marked this pull request as ready for review March 8, 2020 07:19
@GMNGeoffrey
GMNGeoffrey requested a review from ScottTodd March 8, 2020 07:19
@GMNGeoffrey
GMNGeoffrey force-pushed the bazel-to-cmake branch 2 times, most recently from 69af3cd to 6eaf527 Compare March 8, 2020 07:22
@copybara-service copybara-service Bot closed this in 1b4ac81 Mar 9, 2020
copybara-service Bot pushed a commit that referenced this pull request Mar 9, 2020
Accidentally reverted this line while merging #1002

Closes #1010

COPYBARA_INTEGRATE_REVIEW=#1010 from GMNGeoffrey:bazel-to-cmake 4330264
PiperOrigin-RevId: 299897898
GMNGeoffrey added a commit that referenced this pull request Aug 9, 2022
Part of #9855. Note that unlike
the Kokoro Android build, this *does not* build the benchmark artifacts
for Android. That's actually a totally different thing and is being
added as a separate job in #1002.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants