Repository navigation
doc: update dev note examples for CMake - #30739
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
94e0b43 to
7de0c99
Compare
|
Do you want to add sedited@17f6ecd? I guess we should update all scripts and examples to use the |
|
|
||
| ```sh | ||
| git diff | ( cd ./src/ && clang-tidy-diff -p2 -j $(nproc) ) | ||
| git diff | ( cd ./src/ && clang-tidy-diff -p2 -path ../build -j $(nproc) ) |
There was a problem hiding this comment.
Out-of-scope-feel-free-to-disregard:
On Fedora 40, I don't have the binary clang-tidy-diff, but I tested that the invocation added here works if I do:
| git diff | ( cd ./src/ && clang-tidy-diff -p2 -path ../build -j $(nproc) ) | |
| git diff | ( cd ./src/ && /usr/share/clang/clang-tidy-diff.py -p2 -path ../build -j $(nproc) ) |
There was a problem hiding this comment.
There will always be a distro where it doesn't work and other command may be needed. Generally, I think the commands target Debian/Ubuntu. If they happen to work on all distros, great, and I am sure developers are able to figure out their distro's way of calling the command.
| make clean && bear --config src/.bear-tidy-config -- make -j $(nproc) | ||
| cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | ||
| cmake --build build -j $(nproc) | ||
| ``` |
There was a problem hiding this comment.
Feel free to disregard alternative:
Configure with clang as the compiler to produce the `compile_commands.json` that
`clang-tidy` needs:
```sh
cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake --build build -j $(nproc)
```
|
Tested ACK 7de0c99 Used the invocation provided here on a clean This bit of the docs is also helpful for anyone wanting to use their ide/editor's lsp client with the
clang-tidy-diffI had the same issue with This actually seems like it might be partly llvm's issue, as there's a ~10 year old |
tdb3
left a comment
There was a problem hiding this comment.
Initially running into issues building with Debian (12.6) default clang 14.0.6 and with 18.1.8. Fresh clone. Hope to revisit soon. No issues seen with gcc (following https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md#to-build).
cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build build -j 18
-- Found Boost: /usr/include (found suitable version "1.74.0", minimum required is "1.73.0")
...
$ clang --version
Debian clang version 18.1.8 (++20240731024826+3b5b5c1ec4a3-1~exp1~20240731144843.145)
Target: x86_64-pc-linux-gnu
With 18.1.8
In file included from /usr/include/boost/mpl/integral_c.hpp:32:
/usr/include/boost/mpl/aux_/integral_wrapper.hpp:73:31: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'udt_builtin_mixture_enum' [-Wenum-constexpr-conversion]
73 | typedef AUX_WRAPPER_INST( BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (value - 1)) ) prior;
| ^
/usr/include/boost/mpl/aux_/static_cast.hpp:24:47: note: expanded from macro 'BOOST_MPL_AUX_STATIC_CAST'
24 | # define BOOST_MPL_AUX_STATIC_CAST(T, expr) static_cast<T>(expr)
| ^
In file included from ../../../src/test/validation_chainstatemanager_tests.cpp:8:
In file included from ../../../src/node/chainstatemanager_args.h:9:
In file included from ../../../src/validation.h:28:
In file included from ../../../src/txmempool.h:26:
In file included from /usr/include/boost/multi_index/hashed_index.hpp:38:
In file included from /usr/include/boost/multi_index/detail/node_handle.hpp:22:
In file included from /usr/include/boost/multi_index_container_fwd.hpp:18:
In file included from /usr/include/boost/multi_index/indexed_by.hpp:17:
In file included from /usr/include/boost/mpl/vector.hpp:36:
In file included from /usr/include/boost/mpl/vector/vector20.hpp:18:
In file included from /usr/include/boost/mpl/vector/vector10.hpp:18:
In file included from /usr/include/boost/mpl/vector/vector0.hpp:24:
In file included from /usr/include/boost/mpl/vector/aux_/clear.hpp:18:
In file included from /usr/include/boost/mpl/vector/aux_/vector0.hpp:22:
In file included from /usr/include/boost/mpl/vector/aux_/iterator.hpp:19:
In file included from /usr/include/boost/mpl/plus.hpp:19:
In file included from /usr/include/boost/mpl/aux_/arithmetic_op.hpp:17:
In file included from /usr/include/boost/mpl/integral_c.hpp:32:
/usr/include/boost/mpl/aux_/integral_wrapper.hpp:73:31: error: integer value -1 is outside the valid range of values [0, 3] for the enumeration type 'int_float_mixture_enum' [-Wenum-constexpr-conversion]
/usr/include/boost/mpl/aux_/static_cast.hpp:24:47: note: expanded from macro 'BOOST_MPL_AUX_STATIC_CAST'
24 | # define BOOST_MPL_AUX_STATIC_CAST(T, expr) static_cast<T>(expr)
| ^
2 errors generated.
That is just a boost issue, unrelated to cmake. It should happen with autotools as well. I think you can fix it by upgrading your distro (or boost) |
Opened an issue to track this: #30751 , as it needs fixing in some way (also for 28.x). |
|
It may not be clear to all readers of this document that
On the command line, invoking the underlying commands explicitly is both easier to understand and faster to type: mkdir build
cd build
cmake -GNinja ..
ninjaUsers that prefer using clang, may set |
I would advise against this approach, as it may inadvertently lead to the use of an incorrect build tool. For instance, on macOS, when GNU Make is installed via Homebrew, two build tools become available: While CMake selects |
7de0c99 doc: update dev note examples for CMake (fanquake) Pull request description: Update the examples in the developer notes to work with CMake. Also added an explicit `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` for clarity. ACKs for top commit: davidgumberg: Tested ACK bitcoin@7de0c99 TheCharlatan: ACK 7de0c99 jonatack: Tested ACK 7de0c99 on arm64 macOS 14.6.1 Tree-SHA512: 561fe5e777c5b29a4f26309700c03a730c5bbb2f838630abfaa4174112ced66e733c2109cb429a1927f1f3692bf1945f6386bcaffe604a76ea24633932d39171
6b365d2 doc: update dev note examples for CMake (fanquake) Pull request description: Update the examples in the developer notes to work with CMake. Also added an explicit `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` for clarity. ACKs for top commit: davidgumberg: Tested ACK bitcoin/bitcoin@6b365d2 TheCharlatan: ACK 6b365d2 jonatack: Tested ACK 6b365d2 on arm64 macOS 14.6.1 Tree-SHA512: 561fe5e777c5b29a4f26309700c03a730c5bbb2f838630abfaa4174112ced66e733c2109cb429a1927f1f3692bf1945f6386bcaffe604a76ea24633932d39171
5364a58 doc: update dev note examples for CMake (fanquake) Pull request description: Update the examples in the developer notes to work with CMake. Also added an explicit `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` for clarity. ACKs for top commit: davidgumberg: Tested ACK bitcoin/bitcoin@5364a58 TheCharlatan: ACK 5364a58 jonatack: Tested ACK 5364a58 on arm64 macOS 14.6.1 Tree-SHA512: 561fe5e777c5b29a4f26309700c03a730c5bbb2f838630abfaa4174112ced66e733c2109cb429a1927f1f3692bf1945f6386bcaffe604a76ea24633932d39171
Update the examples in the developer notes to work with CMake.
Also added an explicit
-DCMAKE_EXPORT_COMPILE_COMMANDS=ONfor clarity.