Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: set CMake as default build system #20188

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Aug 17, 2024

Switch the default build system from native Ninja generation to CMake.

This is a major step in our CMake migration initiative that:

  • Enables CMake builds by default via --use-cmake flag
  • Prepares for future removal of configure.py's native build.ninja generation
  • Streamlines our build system to use CMake exclusively
  • Updates the document on build system

We can still use --no-use-cmake flag to use the legacy build system.

Note: The native Ninja generation in configure.py will be removed after a grace period to ensure smooth transition.

I compared the compilation databases generated by CMake and configure.py using this comparison script, I analyzed the differences between the two build systems. The full comparison results show some variations in compile options.
I've audited all discrepancies and can confirm that:

  • None of the differences impact build functionality
  • The variations mostly represent cleanup opportunities in the CMake configuration

Refs #2717


this change should only impact the developer's workflow, no impact to production, so no need to backport.

@tchaikov tchaikov added documentation Requires documentation backport/none Backport is not required area/build labels Aug 17, 2024
@tchaikov tchaikov requested a review from lersek August 17, 2024 07:43
@lersek
Copy link
Member

lersek commented Aug 19, 2024

@tchaikov I think we need a larger documentation surgery for this.

The section you are currently modifying is under heading Example: development on Fedora 25. That "example" chapter seems irrelevant for the significant "generate ninja build files with cmake" feature. I suggest removing the current cmake references in HACKING.md altogether, and writing a more comprehensive / substantial description elsewhere.

  1. The short example here might want to name cmake.
  2. This document knows nothing about cmake, but it will not work when configuration occurred with cmake. For example, it contains a command ninja <mode>-build, which will not work when using cmake for configuration.
  3. In this section there are again commands like ninja-build release, which will not work with cmake (to my understanding).

I'd like to see documentation that advertises the following command (with each part unpacked and explained):

ninja -C build {scylla,tests}:{Debug,Dev,RelWithDebInfo}

Currently, none of the above-mentioned three documents (README.md, HACKING.md, docs/dev/building.md) contain RelWithDebInfo, for example.

In fact, if I grep the entire scylla tree for --use-cmake, the only hit is in configure.py itself; there is zero documentation on it.

A new developer should be able to read a single .md file and understand the complete CMake-based workflow:

  • configuration,
  • building the scylla server in all, or in some, configs,
  • building the entire unit test suite, or some of the tests, in all, or in some, configs,
  • running the test suite (all of it, or just some of it).

We have lots of stale build documentation scattered all over the place, and little up-to-date documentation. I'd rather see all of the old build docs being deleted, and a single new document explaining { dbuild, native build } x { with cmake, without cmake }.

@tchaikov tchaikov marked this pull request as draft August 19, 2024 12:29
@tchaikov
Copy link
Contributor Author

tchaikov commented Aug 19, 2024

@lersek hi László, thank you for the detailed suggestion. before making the CMake-based building system the formal one, we need to provide a more informative document to cover, for instance the <target>:<config> notation. i will try to address some of your comments. as i don't intend to maintain both building system at the same time in the long run, i'd prefer removing the "without cmake" part from the my change. but i won't remove the document for the "without cmake" building process, and i will fix it when it's obvious wrong or outdated. i think the first steps would be

  1. add the CMake based document so that it is at least be able to provide enough support to a new developer to build scylla and its tests with CMake. in which, "running the test suite (all of it, or just some of it)." should have been taken care of by test.py. so unless you think the current document does not apply to configure.py or is not sufficient, i will skip this one.
  2. fix Migrate to the CMake build system #2717 , so that our CI starts using CMake for building scylla and tests.
  3. revisit the related documents and restructure them if necessary

please note, i am for this proposal:

removing the current cmake references in HACKING.md altogether, and writing a more comprehensive / substantial description elsewhere.

but i wanted to start with something simple and updated. and then expand it to a more comprehensive document.

@lersek
Copy link
Member

lersek commented Aug 19, 2024

@tchaikov

as i don't intend to maintain both building system at the same time in the long run, i'd prefer removing the "without cmake" part from the my change. but i won't remove the document for the "without cmake" building process, and i will fix it when it's obvious wrong or outdated.

Sounds good. We can drop that documentation when CMake has altogether obsoleted the old build.ninja generator system.

i think the first steps would be

1. add the CMake based document so that it is at least be able to provide enough support to a new developer to build scylla and its tests with CMake.

This sounds good as well. And I do agree that, if your current pull request is the "first step of the first step", then it's fine (i.e., it should be OK to first clean up the obviously stale statements on CMake, even if we don't just yet have the complete CMake write-up in place). I guess I was concerned that this small docs update was going to be the only one, for CMake's sake. :)

in which, "running the test suite (all of it, or just some of it)." should have been taken care of by test.py. so unless you think the current document does not apply to configure.py or is not sufficient, i will skip this one.

I agree that this document covers running tests. However, it does not cover building individual tests (nor do the other three documents I referenced before); I believe. From our previous discussions, there is for example a difference between rebuilding a single test binary:

# without cmake:
ninja build/{dev,debug,release}/test/boost/sstable_test

# with cmake (full syntax):
ninja -C build test/boost/{Dev,Debug,RelWithDebInfo}/sstable_test

# with cmake (shorthand; builds the binary in all modes that were not disabled at ./configure time):
ninja -C build sstable_test

I think we should capture this somewhere; it can save a lot of time, for getting a single test binary to pass.

2. fix [Migrate to the CMake build system #2717](https://github.com/scylladb/scylladb/issues/2717) , so that our CI starts using CMake for building scylla and tests.

3. revisit the related documents and restructure them if necessary

please note, i am for this proposal:

removing the current cmake references in HACKING.md altogether, and writing a more comprehensive / substantial description elsewhere.

but i wanted to start with something simple and updated. and then expand it to a more comprehensive document.

Sounds great. Thanks!

@tchaikov tchaikov force-pushed the hacking-with-cmake branch from f84c8d3 to b72b448 Compare August 28, 2024 12:00
@lersek
Copy link
Member

lersek commented Aug 28, 2024

@tchaikov do you want me to review this version? (with it being a draft)

@tchaikov
Copy link
Contributor Author

@lersek just wanted to update you: i am still working on this. it turns out to be messy if we keep two copies of the almost-same instructions side-by-side. so i think probably the better way is to wait until i #20261 gets merged and then i make cmake the default in configure.py.

@tchaikov
Copy link
Contributor Author

tchaikov commented Aug 28, 2024

@tchaikov do you want me to review this version? (with it being a draft)

no, not until i make cmake the default. by then, the document will reflect the status quo. now it is a bit ahead of time.

and thank you for asking.

@lersek
Copy link
Member

lersek commented Aug 28, 2024

OK, ping me anytime. I agree it's better if the code settles first (and cmake becomes the default).

@tchaikov tchaikov marked this pull request as ready for review October 23, 2024 08:29
@tchaikov tchaikov changed the title HACKING.md: update the CMake related remarks build: set CMake as default build system Oct 23, 2024
@tchaikov
Copy link
Contributor Author

@lersek ping. the change migrating our CI to CMake has been merged.

@tchaikov tchaikov requested review from lersek and denesb October 23, 2024 08:49
Copy link
Member

@lersek lersek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the only "change" I'm requesting is to document the CMAKE_CXX_COMPILER_LAUNCHER env var; the rest is just asking for confirmation/information. Thanks!

configure.py Show resolved Hide resolved
HACKING.md Show resolved Hide resolved
README.md Show resolved Hide resolved
docs/dev/building.md Show resolved Hide resolved
docs/dev/building.md Show resolved Hide resolved
docs/dev/building.md Show resolved Hide resolved
docs/dev/building.md Outdated Show resolved Hide resolved
docs/dev/building.md Show resolved Hide resolved
@tchaikov
Copy link
Contributor Author

v2:

  • document CMAKE_CXX_COMPILER_LAUNCHER and CMAKE_C_COMPILER_LAUNCHER en vars
  • remove extraneous empty line

@scylladb-promoter
Copy link
Contributor

🟢 CI State: SUCCESS

✅ - Build
✅ - Container Test
✅ - dtest
✅ - dtest with topology changes
✅ - dtest with tablets
✅ - Unit Tests

Build Details:

  • Duration: 4 hr 26 min
  • Builder: i-0942547bf01b36eac (m5d.12xlarge)

Copy link
Member

@lersek lersek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@@ -753,7 +753,7 @@ def find_ninja():
help='List all available build artifacts, that can be passed to --with')
arg_parser.add_argument('--date-stamp', dest='date_stamp', type=str,
help='Set datestamp for SCYLLA-VERSION-GEN')
arg_parser.add_argument('--use-cmake', action=argparse.BooleanOptionalAction, default=False, help='Whether to use CMake as the build system')
arg_parser.add_argument('--use-cmake', action=argparse.BooleanOptionalAction, default=True, help='Whether to use CMake as the build system')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need proof that cmake passes the same compile options as the traditional system.

Copy link
Contributor Author

@tchaikov tchaikov Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I compared the compilation databases generated by CMake and configure.py after applying these changes:

Using this comparison script, I analyzed the differences between the two build systems. The full comparison results show some variations in compile options.
I've audited all discrepancies and can confirm that:

  • None of the differences impact build functionality
  • The variations mostly represent cleanup opportunities in the CMake configuration

Please review and let me know if you have any questions or concerns about these differences.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the diff and the only significant difference is this:

=== wasmtime_bindings.cc:
-{'W': set(), 'I': {'build/gen'}, 'f': set(), 'D': set()}
+{'W': {'error=unused-result'}, 'I': {'build/Dev/seastar/gen/include', 'seastar/include'}, 'f': {'stack-clash-protection'}, 'D': {'SEASTAR_SCHEDULING_GROUPS_COUNT=16', 'SEASTAR_LOGGER_TYPE_STDOUT', 'SEASTAR_API_LEVEL=7', 'SEASTAR_SSTRING', 'SEASTAR_TYPE_ERASE_MORE', 'WITH_GZFILEOP', 'SEASTAR_LOGGER_COMPILE_TIME_FMT', 'FMT_SHARED'}}

=== inc.cc:
-{'W': set(), 'I': {'build/gen'}, 'f': set(), 'D': set()}
+{'W': {'error=unused-result'}, 'I': {'build/Dev/seastar/gen/include', 'seastar/include'}, 'f': {'stack-clash-protection'}, 'D': {'SEASTAR_SCHEDULING_GROUPS_COUNT=16', 'SEASTAR_LOGGER_TYPE_STDOUT', 'SEASTAR_API_LEVEL=7', 'SEASTAR_SSTRING', 'SEASTAR_TYPE_ERASE_MORE', 'WITH_GZFILEOP', 'SEASTAR_LOGGER_COMPILE_TIME_FMT', 'FMT_SHARED'}}

Can you explain this?

BTW which is - and which is +?

This 'I': {'build/gen'}, is present everywhere, why is that?

Copy link
Contributor Author

@tchaikov tchaikov Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@denesb Hi Botond, replied inline.

I looked at the diff and the only significant difference is this:

=== wasmtime_bindings.cc:
-{'W': set(), 'I': {'build/gen'}, 'f': set(), 'D': set()}
+{'W': {'error=unused-result'}, 'I': {'build/Dev/seastar/gen/include', 'seastar/include'}, 'f': {'stack-clash-protection'}, 'D': {'SEASTAR_SCHEDULING_GROUPS_COUNT=16', 'SEASTAR_LOGGER_TYPE_STDOUT', 'SEASTAR_API_LEVEL=7', 'SEASTAR_SSTRING', 'SEASTAR_TYPE_ERASE_MORE', 'WITH_GZFILEOP', 'SEASTAR_LOGGER_COMPILE_TIME_FMT', 'FMT_SHARED'}}

=== inc.cc:
-{'W': set(), 'I': {'build/gen'}, 'f': set(), 'D': set()}
+{'W': {'error=unused-result'}, 'I': {'build/Dev/seastar/gen/include', 'seastar/include'}, 'f': {'stack-clash-protection'}, 'D': {'SEASTAR_SCHEDULING_GROUPS_COUNT=16', 'SEASTAR_LOGGER_TYPE_STDOUT', 'SEASTAR_API_LEVEL=7', 'SEASTAR_SSTRING', 'SEASTAR_TYPE_ERASE_MORE', 'WITH_GZFILEOP', 'SEASTAR_LOGGER_COMPILE_TIME_FMT', 'FMT_SHARED'}}

Can you explain this?

sure. these two files are both rust's C++ bindings generated using cxxbridge.

i guess you noticed that seastar flags only exist in the line starting with +. rust binding does not use Seastar headers or link against Seastar libraries, so there is no need to build with Seastar cflags. this is also why i claimed

The variations mostly represent cleanup opportunities in the CMake configuration

in previous comment in this thread.

BTW which is - and which is +?

i wanted to mimic the format of diff when comparing two building command databases. the two building command databases are generated using configure.py and CMake repectively, and the command is

../compare-compile-commands.py -ppppp {cmake-,}compile_commands.json

so the lines started with - is the command line options only found in the rules generated by CMake, and the lines started with + are those only found in the rules generated by configure.py. as you noticed, configure.py tends to pass more cflags when building object files even when they are not used at all.

This 'I': {'build/gen'}, is present everywhere, why is that?

actually, both of them have build/gen. but i am too lazy to normalize them.

  • the one from CMake looks like -I/home/kefu/dev/scylladb/master -I/home/kefu/dev/scylladb/master/build/gen
  • the one from configure.py looks like -iquote. -iquote build/dev/gen.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it indeed looks like the generated build rules are identical where it counts. I'll queue this. 🤞

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking gating, I assume because we need this change together with some change in scylla-pkg

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scylladb/scylla-maint can you please dequeue this patch? it's breaking gating

@tchaikov
Copy link
Contributor Author

@scylladb/scylla-maint hello maintainers, could you help review this change?

denesb added a commit that referenced this pull request Nov 13, 2024
Switch the default build system from native Ninja generation to CMake.

This is a major step in our CMake migration initiative that:

- Enables CMake builds by default via `--use-cmake` flag
- Prepares for future removal of configure.py's native build.ninja generation
- Streamlines our build system to use CMake exclusively
- Updates the document on build system

We can still use `--no-use-cmake` flag to use the legacy build system.

Note: The native Ninja generation in configure.py will be removed after a grace period to ensure smooth transition.

Refs #2717

---

this change should only impact the developer's workflow, no impact to production, so no need to backport.

Closes #20188

* github.com:scylladb/scylladb:
  {HACKING,README}.md: update the CMake related remarks
  build: set CMake as default build system
@avikivity
Copy link
Member

Dequeued since it broke promotion.

@tchaikov the proof it doesn't change flags should be in the cover letter, not hidden in a comment.

@scylladb-promoter
Copy link
Contributor

🟢 CI State: SUCCESS

✅ - Build
✅ - Docker Test
✅ - dtest with topology changes
✅ - dtest
✅ - dtest with tablets
✅ - Offline-installer Artifact Tests
✅ - Unit Tests

Build Details:

  • Duration: 4 hr 0 min
  • Builder: spider2.cloudius-systems.com

@tchaikov
Copy link
Contributor Author

v3:

  • noted that i've compared the build commands generated by configure.py and those generated by CMake building system in the commit message and in the cover letter.

@tchaikov
Copy link
Contributor Author

@denesb hi Botond, could you help re-review this change? i've switched the CI pipelines to CMake in https://github.com/scylladb/scylla-pkg/commit/4df8b8b54f9e8599f367ccbb4917ff881c6452a6 .

@avikivity
Copy link
Member

@tchaikov let's wait until the build system changes are merged from enterprise. These are so large they would invalidate the comparison results.

@tchaikov
Copy link
Contributor Author

@tchaikov let's wait until the build system changes are merged from enterprise. These are so large they would invalidate the comparison results.

okay. let's put this change on hold then.

@tchaikov tchaikov marked this pull request as draft December 23, 2024 07:18
@mykaul mykaul added this to the 2025.2.0 milestone Dec 23, 2024
Switch the default build system from native Ninja generation to CMake.

This is a major step in our CMake migration initiative that:

- Enables CMake builds by default via `--use-cmake` flag
- Prepares for future removal of configure.py's native build.ninja generation
- Streamlines our build system to use CMake exclusively

We can still use `--no-use-cmake` flag to use the legacy build system.

The compilation databases generated by CMake and configure.py were
compared. And the differences between them were analyzed, I can confirm
that

- None of the differences impact build functionality
- The variations mostly represent cleanup opportunities in the CMake configuration

Note: The native Ninja generation in configure.py will be removed after
a grace period to ensure smooth transition.

Refs scylladb#2717
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov tchaikov marked this pull request as ready for review January 10, 2025 09:50
the rules generated with CMake script is feature-wise on par with the
one generated directly with `configure.py`, so the existing document
is now stale.

in this change, we update the document to reflect the current status of
CMake support.

Fixes scylladb#22212

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov
Copy link
Contributor Author

v4:

@tchaikov
Copy link
Contributor Author

@avikivity and @denesb, i

  1. regenerate the compare result at https://gist.github.com/tchaikov/ebeadaaf6ea6bbcebc20feae10555cd8 with the latest master HEAD.
  2. checked it. no significant issues identified.

could you take another look?

@scylladb-promoter
Copy link
Contributor

🔴 CI State: FAILURE

✅ - Build
✅ - Docker Test
✅ - dtest with tablets
✅ - dtest
✅ - dtest with topology changes
✅ - Offline-installer Artifact Tests
❌ - Unit Tests

Build Details:

  • Duration: 8 hr 21 min
  • Builder: i-05d8fb3b868e811e5 (m5ad.8xlarge)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build backport/none Backport is not required documentation Requires documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants