$ sudo apt update
$ sudo apt install git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev
$ git clone https://github.com/bitcoin/bitcoin.git && cd bitcoin
$ cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON
$ cmake --build build -j $(nproc)
<snip>
[ 76%] Building CXX object src/test/kernel/CMakeFiles/test_kernel.dir/test_kernel.cpp.o
/bitcoin/src/test/kernel/test_kernel.cpp:17:10: fatal error: format: No such file or directory
17 | #include <format>
| ^~~~~~~~
compilation terminated.
gmake[2]: *** [src/test/kernel/CMakeFiles/test_kernel.dir/build.make:76: src/test/kernel/CMakeFiles/test_kernel.dir/test_kernel.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1251: src/test/kernel/CMakeFiles/test_kernel.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[ 76%] Linking CXX static library ../lib/libbitcoin_node.a
[ 76%] Built target bitcoin_node
gmake: *** [Makefile:146: all] Error 2
`test_kernel` fails to build on Ubuntu 22.04 #33846
issue hebasto opened this issue on November 10, 2025-
hebasto commented at 5:01 PM on November 10, 2025: member
-
hebasto commented at 5:01 PM on November 10, 2025: member
-
kevkevinpal commented at 4:06 AM on November 11, 2025: contributor
If you want to reproduce using docker here is the docker file
FROM ubuntu:22.04 RUN apt update && \ apt install -y git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev WORKDIR /bitcoin RUN git clone https://github.com/bitcoin/bitcoin.git . RUN cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON && \ cmake --build build -j $(nproc) -
maflcko commented at 7:48 AM on November 11, 2025: member
Please remove the include. See https://github.com/bitcoin/bitcoin/actions/runs/19176694315/job/54823183155?pr=33810#step:9:18532 :
/home/admin/actions-runner/_work/_temp/src/test/kernel/test_kernel.cpp should remove these lines: - #include <boost/test/included/unit_test.hpp> // lines 9-9 - #include <cstdlib> // lines 15-15 - #include <format> // lines 17-17 - maflcko added the label Refactoring on Nov 11, 2025
- maflcko added the label Tests on Nov 11, 2025
-
fanquake commented at 3:30 PM on November 11, 2025: member
Note that this will still fail:
[ 74%] Building CXX object src/test/kernel/CMakeFiles/test_kernel.dir/test_kernel.cpp.o /bitcoin/src/test/kernel/test_kernel.cpp: In member function 'void btck_transaction_tests::test_method()': /bitcoin/src/test/kernel/test_kernel.cpp:448:34: error: no match for 'operator|' (operand types are 'btck::Range<btck::Transaction, &btck::TransactionApi<btck::Transaction>::CountOutputs, &btck::TransactionApi<btck::Transaction>::GetOutput>' and 'std::ranges::views::__adaptor::_Partial<std::ranges::views::_Filter, btck_transaction_tests::test_method()::<lambda(const auto:22&)> >') 448 | auto amount = *(tx.Outputs() | std::ranges::views::filter([](const auto& output) { | ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | | | std::ranges::views::__adaptor::_Partial<std::ranges::views::_Filter, btck_transaction_tests::test_method()::<lambda(const auto:22&)> > | btck::Range<btck::Transaction, &btck::TransactionApi<btck::Transaction>::CountOutputs, &btck::TransactionApi<btck::Transaction>::GetOutput> 449 | return output.Amount() == 42130042; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 450 | }) | | ~~ -
maflcko commented at 4:00 PM on November 11, 2025: member
The unused format include is removed in https://github.com/bitcoin/bitcoin/pull/33853/files and the rvalue ranges thing (ref https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113154) is "fixed" in #33842.
An alternative could be to use an lvalue. However, I am not sure if this is worth it:
diff --git a/src/test/kernel/test_kernel.cpp b/src/test/kernel/test_kernel.cpp index d9875ee..6ef494b 100644 --- a/src/test/kernel/test_kernel.cpp +++ b/src/test/kernel/test_kernel.cpp @@ -14,7 +14,7 @@ #include <cstdint> #include <cstdlib> #include <filesystem> -#include <format> +//#include <format> #include <iostream> #include <memory> #include <optional> @@ -446,12 +446,14 @@ BOOST_AUTO_TEST_CASE(btck_transaction_tests) } BOOST_CHECK_EQUAL(total_amount, 62867453); - auto amount = *(tx.Outputs() | std::ranges::views::filter([](const auto& output) { + auto amount = [&](){ + auto tx_outputs{tx.Outputs()}; + return *(tx_outputs | std::ranges::views::filter([](const auto& output) { return output.Amount() == 42130042; }) | std::views::transform([](const auto& output) { return output.Amount(); - })).begin(); + })).begin();}(); BOOST_REQUIRE(amount); BOOST_CHECK_EQUAL(amount, 42130042); @@ -735,9 +737,9 @@ void chainman_mainnet_validation_test(TestDirectory& test_directory) for (auto transaction : block.Transactions()) { BOOST_CHECK_EQUAL(transaction.CountInputs(), 1); } - auto output_counts = *(block.Transactions() | std::views::transform([](const auto& tx) { + auto output_counts = [&](){auto txs{block.Transactions()};return *(txs | std::views::transform([](const auto& tx) { return tx.CountOutputs(); - })).begin(); + })).begin();}(); BOOST_CHECK_EQUAL(output_counts, 1); validation_interface->m_expected_valid_block.emplace(raw_block); -
kevkevinpal commented at 11:18 PM on November 11, 2025: contributor
An alternative could be to use an lvalue. However, I am not sure if this is worth it:
I think it might make most sense to continue with #33842 and to bump the min version of g++ to 12 and above as you mentioned
- maflcko added this to the milestone 31.0 on Nov 12, 2025
- maflcko closed this on Nov 12, 2025
-
kevkevinpal commented at 3:33 PM on November 12, 2025: contributor
Just tested on master commit d4e2a458330512c227b475531e1617d25366be54 and the build still failed with this docker file
FROM ubuntu:22.04 RUN apt update RUN apt install -y git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev COPY . /bitcoin WORKDIR /bitcoin RUN cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON RUN cmake --build build -j1 -
fanquake commented at 3:50 PM on November 12, 2025: member
Just tested on master commit https://github.com/bitcoin/bitcoin/commit/d4e2a458330512c227b475531e1617d25366be54 and the build still failed with this docker file
The minimum required GCC is now 12; however that Dockerfile will install 11. If you install and use 12, it will work.
-
kevkevinpal commented at 4:35 PM on November 12, 2025: contributor
-
kevkevinpal commented at 4:58 PM on November 12, 2025: contributor
thanks! I was able to get it to build with GCC 12 with this Docker build script
FROM ubuntu:22.04 RUN apt update RUN apt install -y git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev gcc-12 g++-12 COPY . /bitcoin WORKDIR /bitcoin RUN cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12 RUN cmake --build build -j1