test_kernel fails to build on Ubuntu 22.04 #33846

issue hebasto openend this issue on November 10, 2025
  1. hebasto commented at 5:01 pm on November 10, 2025: member
     0$ sudo apt update
     1$ sudo apt install git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev
     2$ git clone https://github.com/bitcoin/bitcoin.git && cd bitcoin
     3$ cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON
     4$ cmake --build build -j $(nproc)
     5<snip>
     6[ 76%] Building CXX object src/test/kernel/CMakeFiles/test_kernel.dir/test_kernel.cpp.o
     7/bitcoin/src/test/kernel/test_kernel.cpp:17:10: fatal error: format: No such file or directory
     8   17 | #include <format>
     9      |          ^~~~~~~~
    10compilation terminated.
    11gmake[2]: *** [src/test/kernel/CMakeFiles/test_kernel.dir/build.make:76: src/test/kernel/CMakeFiles/test_kernel.dir/test_kernel.cpp.o] Error 1
    12gmake[1]: *** [CMakeFiles/Makefile2:1251: src/test/kernel/CMakeFiles/test_kernel.dir/all] Error 2
    13gmake[1]: *** Waiting for unfinished jobs....
    14[ 76%] Linking CXX static library ../lib/libbitcoin_node.a
    15[ 76%] Built target bitcoin_node
    16gmake: *** [Makefile:146: all] Error 2
    
  2. hebasto commented at 5:01 pm on November 10, 2025: member
  3. kevkevinpal commented at 4:06 am on November 11, 2025: contributor

    If you want to reproduce using docker here is the docker file

    0FROM ubuntu:22.04
    1
    2RUN apt update && \
    3    apt install -y git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev
    4
    5WORKDIR /bitcoin
    6RUN git clone https://github.com/bitcoin/bitcoin.git .
    7
    8RUN cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON && \
    9    cmake --build build -j $(nproc)
    
  4. 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 :

    0 /home/admin/actions-runner/_work/_temp/src/test/kernel/test_kernel.cpp should remove these lines:
    1- #include <boost/test/included/unit_test.hpp>  // lines 9-9
    2- #include <cstdlib>  // lines 15-15
    3- #include <format>  // lines 17-17
    
  5. maflcko added the label Refactoring on Nov 11, 2025
  6. maflcko added the label Tests on Nov 11, 2025
  7. fanquake commented at 3:30 pm on November 11, 2025: member

    Note that this will still fail:

     0[ 74%] Building CXX object src/test/kernel/CMakeFiles/test_kernel.dir/test_kernel.cpp.o
     1/bitcoin/src/test/kernel/test_kernel.cpp: In member function 'void btck_transaction_tests::test_method()':
     2/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&)> >')
     3  448 |     auto amount = *(tx.Outputs() | std::ranges::views::filter([](const auto& output) {
     4      |                     ~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     5      |                               |                              |
     6      |                               |                              std::ranges::views::__adaptor::_Partial<std::ranges::views::_Filter, btck_transaction_tests::test_method()::<lambda(const auto:22&)> >
     7      |                               btck::Range<btck::Transaction, &btck::TransactionApi<btck::Transaction>::CountOutputs, &btck::TransactionApi<btck::Transaction>::GetOutput>
     8  449 |                         return output.Amount() == 42130042;
     9      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    10  450 |                     }) |
    11      |                     ~~       
    
  8. 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:

     0diff --git a/src/test/kernel/test_kernel.cpp b/src/test/kernel/test_kernel.cpp
     1index d9875ee..6ef494b 100644
     2--- a/src/test/kernel/test_kernel.cpp
     3+++ b/src/test/kernel/test_kernel.cpp
     4@@ -14,7 +14,7 @@
     5 #include <cstdint>
     6 #include <cstdlib>
     7 #include <filesystem>
     8-#include <format>
     9+//#include <format>
    10 #include <iostream>
    11 #include <memory>
    12 #include <optional>
    13@@ -446,12 +446,14 @@ BOOST_AUTO_TEST_CASE(btck_transaction_tests)
    14     }
    15     BOOST_CHECK_EQUAL(total_amount, 62867453);
    16 
    17-    auto amount = *(tx.Outputs() | std::ranges::views::filter([](const auto& output) {
    18+    auto amount = [&](){
    19+           auto tx_outputs{tx.Outputs()};
    20+           return *(tx_outputs | std::ranges::views::filter([](const auto& output) {
    21                         return output.Amount() == 42130042;
    22                     }) |
    23                     std::views::transform([](const auto& output) {
    24                         return output.Amount();
    25-                    })).begin();
    26+                    })).begin();}();
    27     BOOST_REQUIRE(amount);
    28     BOOST_CHECK_EQUAL(amount, 42130042);
    29 
    30@@ -735,9 +737,9 @@ void chainman_mainnet_validation_test(TestDirectory& test_directory)
    31     for (auto transaction : block.Transactions()) {
    32         BOOST_CHECK_EQUAL(transaction.CountInputs(), 1);
    33     }
    34-    auto output_counts = *(block.Transactions() | std::views::transform([](const auto& tx) {
    35+    auto output_counts = [&](){auto txs{block.Transactions()};return *(txs | std::views::transform([](const auto& tx) {
    36                                return tx.CountOutputs();
    37-                           })).begin();
    38+                           })).begin();}();
    39     BOOST_CHECK_EQUAL(output_counts, 1);
    40 
    41     validation_interface->m_expected_valid_block.emplace(raw_block);
    
  9. 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

  10. maflcko added this to the milestone 31.0 on Nov 12, 2025
  11. maflcko closed this on Nov 12, 2025

  12. 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

    0FROM ubuntu:22.04
    1
    2RUN apt update
    3RUN apt install -y git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev
    4
    5COPY . /bitcoin
    6WORKDIR /bitcoin
    7
    8RUN cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON
    9RUN cmake --build build -j1
    

    are we sure #33853 closes this issue? @fanquake

  13. hebasto commented at 3:49 pm on November 12, 2025: member
    0RUN cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON
    

    It should be now:

    0cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12
    
  14. 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.

  15. kevkevinpal commented at 4:35 pm on November 12, 2025: contributor

    Just tested on master commit d4e2a45 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.

    ok gotcha I assumed #33853 alone closed the issue, will attempt to build again using GCC 12

  16. 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

    0FROM ubuntu:22.04
    1
    2RUN apt update
    3RUN apt install -y git build-essential cmake pkgconf python3 libevent-dev libboost-dev libsqlite3-dev gcc-12 g++-12
    4
    5COPY . /bitcoin
    6WORKDIR /bitcoin
    7
    8RUN cmake -B build -DENABLE_IPC=OFF -DBUILD_KERNEL_LIB=ON -DCMAKE_C_COMPILER=gcc-12 -DCMAKE_CXX_COMPILER=g++-12
    9RUN cmake --build build -j1
    

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-11-12 21:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me