iwyu: Fix warnings in `src/bench` and treat them as error #35414

pull hebasto wants to merge 3 commits into bitcoin:master from hebasto:260529-iwyu-bench changing 58 files +201 −98
  1. hebasto commented at 2:53 PM on May 29, 2026: member

    This PR addresses this comment:

    I had the impression I already fixed bench in #30716 two years ago, but I guess it isn't yet enforced.

    Could do that as a next step?

    The first two commits act as prerequisites. See the commit messages for details.

    The third commit additionally ensures that our drop-in header replacements are used instead of system headers:

  2. DrahtBot commented at 2:53 PM on May 29, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35414.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34909 (wallet, refactor: modularise wallet by extracting out legacy wallet migration by rkrux)
    • #34625 (cluster_linearize: add tests and benchmarks for chain and tree-shaped clusters by HowHsu)
    • #34360 (bench: add WalletBalanceManySpent for high-history wallet scenario by w0xlt)
    • #33663 (net: Filter addrman during address selection via AddrPolicy to avoid underfill by waketraindev)
    • #33421 (node: add BlockTemplateCache by ismaelsadeeq)
    • #32554 (bench: replace embedded raw block with configurable block generator by l0rinc)
    • #32317 (kernel: Separate UTXO set access from validation functions by sedited)
    • #31260 (scripted-diff: Type-safe settings retrieval by ryanofsky)
    • #30342 (kernel, logging: Pass Logger instances to kernel objects by ryanofsky)
    • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. in src/bench/bench.cpp:70 in c74b9660f9 outdated
      66 | @@ -68,9 +67,9 @@ BenchRunner::BenchmarkMap& BenchRunner::benchmarks()
      67 |      return benchmarks_map;
      68 |  }
      69 |  
      70 | -BenchRunner::BenchRunner(std::string name, BenchFunction func)
      71 | +BenchRunner::BenchRunner(std::string_view name, BenchFunction func)
    


    fanquake commented at 3:19 PM on May 29, 2026:

    In 02ac6a68db2bc62faa74a3629caf6210e5df1026:

    eliminating the need to include <string> everywhere the BENCHMARK() macro is used.

    Why is that a problem (that we need to refactor the source to address)?


    hebasto commented at 3:31 PM on May 29, 2026:

    On the master branch, the BENCHMARK() macro hides the actual usage of std::string, which leads to confusing code like this:

    #include <bench/bench.h>
    #include <string>  // Appears unused, but required by BENCHMARK().
    #include <util/time.h>
    
    static void BenchTimeDeprecated(benchmark::Bench& bench)
    {
        bench.run([&] { (void)GetTime(); });
    }
    
    BENCHMARK(BenchTimeDeprecated);
    
  4. fanquake commented at 4:23 PM on May 29, 2026: member

    https://github.com/bitcoin/bitcoin/actions/runs/26644389739/job/78537895187?pr=35414#step:11:2209:

    [ 83%] Linking CXX executable ../../bin/bench_bitcoin
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/wallet_create.cpp.o: in function `wallet::WalletCreate(ankerl::nanobench::Bench&, bool)':
    /home/runner/work/_temp/src/bench/nanobench.h:1281:(.text+0x928): undefined reference to `ankerl::nanobench::detail::IterationLogic::moveResultTo(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> >&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/bench.cpp.o: in function `benchmark::BenchRunner::RunAll(benchmark::Args const&)':
    /home/runner/work/_temp/src/bench/bench.cpp:124:(.text+0xb0e): undefined reference to `ankerl::nanobench::operator<<(std::ostream&, std::__debug::vector<ankerl::nanobench::BigO, std::allocator<ankerl::nanobench::BigO> > const&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/bench.cpp.o: in function `(anonymous namespace)::GenerateTemplateResults(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> > const&, fs::path const&, char const*)':
    /home/runner/work/_temp/src/bench/bench.cpp:53:(.text+0x119a): undefined reference to `ankerl::nanobench::render(char const*, std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> > const&, std::ostream&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/addrman.cpp.o: in function `AddrManAddThenGood(ankerl::nanobench::Bench&)':
    /home/runner/work/_temp/src/bench/nanobench.h:1281:(.text+0x1507): undefined reference to `ankerl::nanobench::detail::IterationLogic::moveResultTo(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> >&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/addrman.cpp.o: in function `ankerl::nanobench::Bench& ankerl::nanobench::Bench::run<AddrManAdd(ankerl::nanobench::Bench&)::$_0>(AddrManAdd(ankerl::nanobench::Bench&)::$_0&&)':
    /home/runner/work/_temp/src/bench/nanobench.h:1281:(.text+0x1abf): undefined reference to `ankerl::nanobench::detail::IterationLogic::moveResultTo(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> >&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/addrman.cpp.o: in function `ankerl::nanobench::Bench& ankerl::nanobench::Bench::run<AddrManSelect(ankerl::nanobench::Bench&)::$_0>(AddrManSelect(ankerl::nanobench::Bench&)::$_0&&)':
    /home/runner/work/_temp/src/bench/nanobench.h:1281:(.text+0x1f95): undefined reference to `ankerl::nanobench::detail::IterationLogic::moveResultTo(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> >&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/addrman.cpp.o: in function `ankerl::nanobench::Bench& ankerl::nanobench::Bench::run<AddrManSelectFromAlmostEmpty(ankerl::nanobench::Bench&)::$_0>(AddrManSelectFromAlmostEmpty(ankerl::nanobench::Bench&)::$_0&&)':
    /home/runner/work/_temp/src/bench/nanobench.h:1281:(.text+0x2255): undefined reference to `ankerl::nanobench::detail::IterationLogic::moveResultTo(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> >&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/addrman.cpp.o: in function `ankerl::nanobench::Bench& ankerl::nanobench::Bench::run<AddrManSelectByNetwork(ankerl::nanobench::Bench&)::$_0>(AddrManSelectByNetwork(ankerl::nanobench::Bench&)::$_0&&)':
    /home/runner/work/_temp/src/bench/nanobench.h:1281:(.text+0x24ed): undefined reference to `ankerl::nanobench::detail::IterationLogic::moveResultTo(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> >&)'
    /usr/bin/ld: CMakeFiles/bench_bitcoin.dir/addrman.cpp.o:/home/runner/work/_temp/src/bench/nanobench.h:1281: more undefined references to `ankerl::nanobench::detail::IterationLogic::moveResultTo(std::__debug::vector<ankerl::nanobench::Result, std::allocator<ankerl::nanobench::Result> >&)' follow
    
  5. DrahtBot added the label CI failed on May 29, 2026
  6. DrahtBot commented at 5:48 PM on May 29, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task i686, no IPC: https://github.com/bitcoin/bitcoin/actions/runs/26644389739/job/78537895187</sub> <sub>LLM reason (✨ experimental): CI failed due to a build linker error (undefined references to ankerl::nanobench symbols when linking bench_bitcoin).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  7. cmake: Factor out `bitcoin_nanobench` static library
    This allows us to exclude Nanobench's 3rd-party code from static
    analysis, either directly via CMake's mechanisms or indirectly through a
    compilation database.
    45de76f9c8
  8. bench, refactor: Use `std::string_view` for `BenchRunner` ctor parameter
    This avoids implicit conversions from string literals to `std::string`,
    eliminating the need to include `<string>` everywhere the `BENCHMARK()`
    macro is used.
    f1973f7456
  9. iwyu: Fix warnings in `src/bench` and treat them as error f8654d5052
  10. hebasto force-pushed on May 29, 2026
  11. DrahtBot removed the label CI failed on May 29, 2026

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: 2026-05-31 17:50 UTC

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