Skip to content

cmake: Adjust build option defaults#196

Merged
hebasto merged 2 commits into
cmake-stagingfrom
240509-cmake-EZ
May 24, 2024
Merged

cmake: Adjust build option defaults#196
hebasto merged 2 commits into
cmake-stagingfrom
240509-cmake-EZ

Conversation

@hebasto
Copy link
Copy Markdown
Owner

@hebasto hebasto commented May 9, 2024

This PR adjusts build option defaults per the discussion during today's call.

@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 9, 2024

@hebasto hebasto added this to the UI, 23th May milestone May 9, 2024
Comment thread CMakeLists.txt
option(BUILD_UTIL "Build bitcoin-util executable." ON)

option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This expands BUILD_TESTS to control (by default) whether to build test_bitcoin, bitcoin-tx, bitcoin-util, bitcoin-wallet, bench_bitcoin and fuzz.

Those are beyond the scope of "tests" and so using BUILD_TESTS to control them is confusing. One way to avoid this is to not have the dependency and have each option be independent of the others (ditch this PR, I think it is like this with autotools?).

Or if we insist on having all those being controlled by one option (for convenience?), then maybe introduce a new meta option BUILD_EXTRA that turns ON/OFF all of BUILD_TESTS (maybe BUILD_UNIT_TESTS is a better name because there are also functional tests and benchmark tests and fuzz tests), BUILD_TX, BUILD_UTIL, BUILD_WALLET_TOOL, BUILD_BENCH, BUILD_FUZZ_BINARY.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We decided (on this week's call) on this approach because the functional tests depend on these binaries and silently skip tests if they're not present. It's not ideal, but we agreed it's better than the alternative.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ok

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A new angle on this:

Having in mind the problem that if the user compiles without e.g. bitcoin-tx, then some functional tests will be skipped.

Before this PR: BUILD_TX is ON, so the problem does not exist if the user uses the defaults and does not fiddle with the options. The problem arises if they explicitly set BUILD_TX is OFF.

After this PR: same as above, so this PR brings no improvement?

However, there is an undesirable side effect with this PR: if BUILD_TESTS is set to OFF, then automatically BUILD_TX will be turned to OFF as well.

Maybe it would be better if each option is kept independent. Then if BUILD_TX is explicitly changed from its default ON to OFF, then emit a warning during configure: "some functional tests will be skipped without bitcoin-tx".

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two other objections to this:

  • In bitcoind we have some options turn on/off other options. This is oftentimes complicated and difficult to asses what will happen if a given option is changed. It is hard on both ends - from the user's perspective and from developer's perspective when changing the code. I think it is better to keep it simple stupid and avoid having one option flip the value of another, which is more aligned with https://en.wikipedia.org/wiki/Principle_of_least_astonishment.

  • "Full execution of functional tests" and "Whether to build unit tests executable" are unrelated and tying them together would be odd.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I do agree with @vasild on this:

Maybe it would be better if each option is kept independent. Then if BUILD_TX is explicitly changed from its default ON to OFF, then emit a warning during configure: "some functional tests will be skipped without bitcoin-tx".

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I still disagree with this as I'd rather err on the side of "whoops, I built an extra binary but all the tests got run".

Comment thread CMakeLists.txt
@@ -65,8 +65,11 @@ include(CMakeDependentOption)
option(BUILD_DAEMON "Build bitcoind executable." ON)
option(BUILD_GUI "Build bitcoin-qt executable." OFF)
option(BUILD_CLI "Build bitcoin-cli executable." ON)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bitcoin-cli is also referenced from the functional tests. Shouldn't it also be treated like the others, e.g. bitcoin-tx?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd keep it ON by default and, as you said, independently from tests.

Comment thread CMakeLists.txt
option(BUILD_UTIL "Build bitcoin-util executable." ON)

option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_TX "Build bitcoin-tx executable." ${BUILD_TESTS})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

A new angle on this:

Having in mind the problem that if the user compiles without e.g. bitcoin-tx, then some functional tests will be skipped.

Before this PR: BUILD_TX is ON, so the problem does not exist if the user uses the defaults and does not fiddle with the options. The problem arises if they explicitly set BUILD_TX is OFF.

After this PR: same as above, so this PR brings no improvement?

However, there is an undesirable side effect with this PR: if BUILD_TESTS is set to OFF, then automatically BUILD_TX will be turned to OFF as well.

Maybe it would be better if each option is kept independent. Then if BUILD_TX is explicitly changed from its default ON to OFF, then emit a warning during configure: "some functional tests will be skipped without bitcoin-tx".

Comment thread CMakeLists.txt
@@ -65,8 +65,11 @@ include(CMakeDependentOption)
option(BUILD_DAEMON "Build bitcoind executable." ON)
option(BUILD_GUI "Build bitcoin-qt executable." OFF)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Currently, in master, we build bitcoin-qt by default, what's the reasoning behind this to be changed?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

During our calls, we discussed the concept of build options. We have reached a rough consensus to make them "opt-in" rather than "opt-out" as much as possible.

@hebasto hebasto force-pushed the 240509-cmake-EZ branch 2 times, most recently from 4d4cf13 to 8bb7538 Compare May 21, 2024 19:40
Comment thread CMakePresets.json Outdated
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows",
"BUILD_GUI": "ON",
"BUILD_BENCH": "ON",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why on for Windows?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Thanks!. Moved to the CI script.

@theuni
Copy link
Copy Markdown

theuni commented May 22, 2024

I'm afraid we could bikeshed these forever. IMO it's good enough for a first pass, and we'll learn quickly post-merge if people are upset/confused.

@hebasto hebasto force-pushed the 240509-cmake-EZ branch from 8bb7538 to b1b4977 Compare May 23, 2024 10:12
@hebasto
Copy link
Copy Markdown
Owner Author

hebasto commented May 23, 2024

Rebased to resolve a conflict.

@theuni's #196 (comment) has been addressed.

Copy link
Copy Markdown

@theuni theuni left a comment

Choose a reason for hiding this comment

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

ACK b1b4977

@hebasto hebasto merged commit 06872ef into cmake-staging May 24, 2024
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.

4 participants