← Back to Pull requests

Build with C++20 and use std::format #1229

Closed
unknown closed this pull request without merging on Nov 24, 2026 06:40 UTC
View on GitHub
unknown unknown commented on Nov 10, 2026 18:29 UTC
Author

<!--

Thank you for contributing to cuCIM :)

Here are some guidelines to help the review process go smoothly.

1. Please write a description in this text box of the changes that are being
made.

2. Please ensure that you have written units tests for the changes made/features
added.

3. If you are closing an issue please use one of the automatic closing words as
noted here: https://help.github.com/articles/closing-issues-using-keywords/

4. If your pull request is not ready for review but you want to make use of the
continuous integration testing facilities please label it with [WIP].

5. If your pull request is ready to be reviewed without requiring additional
work on top of it, then remove the [WIP] label (if present) and replace
it with [REVIEW]. If assistance is required to complete the functionality,
for example when the C/C++ code of a feature is complete but Python bindings
are still required, then add the label [HELP-REQ] so that others can triage
and assist. The additional changes then can be implemented on top of the
same PR. If the assistance is done by members of the rapidsAI team, then no
additional actions are required by the creator of the original PR for this,
otherwise the original author of the PR needs to give permission to the
person(s) assisting to commit to their personal fork of the project. If that
doesn't happen then a new PR based on the code of the original PR can be
opened by the person assisting, which then will be the PR that will be
merged.

6. Once all work has been done and review has taken place please do not add
features or make changes out of the scope of those requested by the reviewer
(doing this just add delays as already reviewed code ends up having to be
re-reviewed/it is hard to tell what is new etc!). Further, please do not
rebase your branch on main/force push/rewrite history, doing any of these
causes the context of any comments made by reviewers to be lost. If
conflicts occur against main they should be resolved by merging main
into the branch used for making the pull request.

Many thanks in advance for your cooperation!

-->

This PR builds cuCIM as C++20, as #1191 proposes, and moves cuCIM's own sources from fmt to the C++20 standard library, so fmt is no longer a dependency. The rest of RAPIDS and Holoscan already build as C++20.

Closes #1191.

Who is affected

  • People who build cuCIM need a C++20 compiler and a standard library with <format>, which GCC provides from version 13. The conda recipes pin GCC 14, and the CI wheel image uses gcc-toolset-14.

  • C++ code that uses the installed libcucim now needs C++20 and <format> as well:

  • - The exported cucim::cucim CMake target requires cxx_std_20, so CMake compiles targets that link it as C++20 or newer.
    - The installed headers cucim/util/cuda.h and cucim/memory/dlpack.h, and the new cucim/util/print.h, include <format>.
    - The install no longer ships fmt headers under include/cucim/3rdparty or exports cucim::fmt-header-only. Code that got fmt from cuCIM's install has to get it elsewhere.

    Commits

    1. Build with C++20. Every first-party CMake project (libcucim, the GDS stub, the three plugins, the Python bindings, and their tests, benchmarks, and examples) moves from C++17 to C++20. The libcucim compile feature stays PRIVATE in this commit. Three small fixes keep the -Werror build passing:
    - Timer::print passes a runtime format string to fmt::print, which fmt only accepts through fmt::runtime in C++20 mode.
    - cuCIM's libcuckoo.patch replaces std::is_pod, which C++20 deprecates, with std::is_standard_layout and std::is_trivial. Commit 7 drops this hunk again.
    - cuslide2's TIFF::construct_ifds shrinks a non-empty vector with erase instead of resize(1), which avoids a false GCC 14 -Warray-bounds error.
    2. Use std::format instead of fmt::format. 164 calls in 35 files change. This commit leaves fmt::print, fmt::join, and the fmt::format calls in the installed headers on fmt.
    3. Remove the fmt dependency.
    - Adds cucim/util/print.h with cucim::print and cucim::vprint, which format with std::vformat and write with std::fwrite, because C++20 has no std::print. 319 fmt::print calls in 24 files move to these helpers, including the two in Timer::print that needed fmt::runtime.
    - Converts the installed headers cucim/util/cuda.h and cucim/memory/dlpack.h to std::format and cucim::print, and makes libcucim's cxx_std_20 compile feature PUBLIC.
    - Replaces fmt::join in cuslide2's nvimgcodec_tiff_parser.cpp and in examples/cpp/tiff_image/main.cpp with small loops over std::format_to.
    - Removes the remaining <fmt/...> includes, adds <cstring> to two files that got it through fmt, and removes fmt from every CMake project, the install, and the third-party license files.
    4. Find Git before applying cuslide dependency patches. The cuslide plugin patches libjpeg-turbo, libopenjpeg, and libtiff with ${GIT_EXECUTABLE}, which was set only because fmt was the first dependency the plugin fetched. Each of the three files now calls find_package(Git REQUIRED), as libcucim's dependency files already do.
    5. Report failed writes from cucim::print. cucim::vprint throws std::system_error when fwrite writes fewer bytes than were formatted, as fmt::print did. The new cpp/tests/test_print.cpp covers a normal write and an unbuffered write to /dev/full.
    6. Update C++17 references in nvcc comments to C++20. 16 CMake comments quoted nvcc's error for -std=c++17. No other C++17 references remain.
    7. Upgrade libcuckoo to v0.3.1. v0.3.1 contains the std::is_pod fix from commit 1, so libcuckoo.patch drops that hunk. The CMake hunk is regenerated for v0.3.1, and the Boost.Interprocess hunks are unchanged.
    8. Note the planned move to std::print in print.h. The comment points to #1258.
    9. Update commented-out fmt calls to cucim::print and std::format. The commented-out debug code in cufile_driver.cpp, image_cache_shared_memory.cpp, and test_metadata.cpp no longer names fmt.

    Follow-up issues

  • #1258: replace cucim::print with std::print once cuCIM builds with C++23.

  • #1260: recheck whether the Boost.Interprocess hunks of libcuckoo.patch are still needed with libcuckoo v0.3.1.
  • Validation

    The branch is based on release/26.12 at 938324c4. It merges cleanly with the current release/26.12 (8e879475), whose only newer commit, #1196, changes Python files that this PR does not touch.

    CI on 71332ca8. Run 45316708818 passed all 39 checks:

  • the style checks and the docs build

  • conda C++ and Python package builds, and wheel builds, for CUDA 12.9 and 13.4 on amd64 and arm64

  • conda Python tests on 3 configurations and wheel tests on 4, covering CUDA 12.2 to 13.4, Python 3.12 to 3.14, amd64 and arm64, and the earliest and latest drivers
  • Local checks on 71332ca8. These ran on x86_64 with GCC 14, CUDA 13.3, and CMake 4.4.

  • Builds. libcucim, cuslide, cumed, cuslide2 (against nvImageCodec 0.10.1), and the Python bindings build all targets in new build folders. The only first-party warnings are four -Wclobbered warnings in cuslide's libjpeg_turbo.cpp, which predate this PR. CMake compiles that file with -Wno-error.

  • C++ tests. Both cucim::print test cases pass. Before commit 5, the /dev/full case failed.

  • Python tests. tests/unit/clara gives 153 passed and 16 skipped. Fifteen of the skipped tests need the cuslide2 plugin, which was left out because the local environment has nvImageCodec 0.9 and cuslide2 needs 0.10. The other skipped test is marked as failing (gh-626).

  • Shared-memory cache. Reading the same tiles twice through a shared_memory cache serves the second pass from the cache. The pixels match tifffile and an uncached read.
  • libcuckoo v0.3 and v0.3.1. On the previous base, tests/unit/clara gave the same outcome for each of its 153 tests with both versions, and the shared-memory check passed with both.

    Not covered: the C++ test binaries other than the cucim::print tests (CI does not run them either), the shared-memory cache used from more than one process (see #1260), compilers other than GCC 14, and a C++ program that consumes the new install. Some converted calls are not compiled by any target: those in cuslide2's tests/test_read_rawtiff.cpp, which no CMake target lists, those in macro bodies in cuslide's tests/test_read_rawtiff.cpp that are never expanded, and those in cuslide2's tiff/ifd.cpp in the branch for builds without nvImageCodec.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: gigony Review duration: 19451m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1229"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository