Skip to content

chore(c): Update to C++20#4506

Open
fornwall wants to merge 6 commits into
apache:mainfrom
fornwall:cpp-20
Open

chore(c): Update to C++20#4506
fornwall wants to merge 6 commits into
apache:mainfrom
fornwall:cpp-20

Conversation

@fornwall

@fornwall fornwall commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Raise the C++ language standard for the whole ADBC C++ project (the c/ directory) from C++17 to C++20.

This also migrates from fmt to std::format.

Other changes using C++20 can come gradually over time once someone has a need for it.

Raise the C++ language standard for the whole ADBC C++ project from
C++17 to C++20.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall
fornwall requested a review from lidavidm as a code owner July 13, 2026 09:31
@fornwall
fornwall marked this pull request as draft July 13, 2026 09:35
@fornwall

fornwall commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

CI found some issues, will look at them. Meanwhile converted to draft. EDIT: Fixed by the fmt bump.

@fornwall fornwall changed the title chore(c): build the C/C++ project as C++20 chore(c): build the C++ project as C++20 Jul 13, 2026
Update vendored fmt to support C++20.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@lidavidm

Copy link
Copy Markdown
Member

Sorry - while we can do this, I didn't necessarily want to. At the very least, since this will (IIRC) raise the manylinux target on wheels, I would want to announce in the next release that this is coming, and only after make the change.

@lidavidm

Copy link
Copy Markdown
Member

Also, like, instead of upgrading {fmt} I'd rather get rid of it in favor of std::format (etc.)

@fornwall

fornwall commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Sorry - while we can do this, I didn't necessarily want to

👍 Absolutely. Let me know if you think it makes sense to continue this PR, or if we should close it for now.

At the very least, since this will (IIRC) raise the manylinux target on wheels, I would want to announce in the next release that this is coming, and only after make the change.

It doesn't seem to raise the manylinux target - that will only happen by specific code causing references to new symbols (such as std::format on chrono types). There is an existing test here, so that does not slip by silently.

Also, like, instead of upgrading {fmt} I'd rather get rid of it in favor of std::format (etc.)

Let me know if you want to proceed with this C++20 update, and I can have a look at it!

@fornwall
fornwall marked this pull request as ready for review July 13, 2026 11:26
@lidavidm

Copy link
Copy Markdown
Member

It doesn't seem to raise the manylinux target - that will only happen by specific code causing references to new symbols (such as std::format on chrono types). There is an existing test here, so that does not slip by silently.

IIRC, the C++ compilers available on the manylinux2014 build image only have minimal C++20 support - so while an initial compile may work, there would be no point just raising the standard if we can't actually use it. And so I'd rather just hold off in that case.

@fornwall

fornwall commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

C++ compilers available on the manylinux2014 build image only have minimal C++20 support

Are we not using manylinux_2_28 here, which gets resolved to quay.io/pypa/manylinux_2_28:latest in the Dockerfile?

That seems (docker run quay.io/pypa/manylinux_2_28:latest gcc --version) to have a quite complete C++20 supporting toolchain (see New C++ features in GCC 14):

gcc (GCC) 14.2.1 20250110 (Red Hat 14.2.1-11)
gcc-toolset installed: gcc-toolset-14

Tried a simple concepts + ranges + std::format program, and it compiled and ran.

@lidavidm

Copy link
Copy Markdown
Member

Oh, I forgot I had bumped it a while back...I thought we were still on 2014

@lidavidm

Copy link
Copy Markdown
Member

Even so, I'd want to announce that we are doing this before we actually do it

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall
fornwall requested review from kou and paleolimbot as code owners July 13, 2026 12:56
@fornwall

Copy link
Copy Markdown
Contributor Author

Even so, I'd want to announce that we are doing this before we actually do it

Absolutely, makes sense.

Let me know if I can help with anything (changes/investigation/communication).

@fornwall

Copy link
Copy Markdown
Contributor Author

Pushed a (disclaimer: AI generated) migration from fmt to std::format:

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall
fornwall requested a review from zeroshade as a code owner July 13, 2026 13:15
@fornwall

fornwall commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Migrating fmt -> std::format seems to require bumping macOS deployment target to 13.3:

If that is a blocker fmt could be kept around even on C++20 for now.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
Biggest change is linking libstdc++ statically on jammy.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
@fornwall

fornwall commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

The fmt -> std::format transition seems to require statically linking libstdc++ on ubuntu jammy (22.04):

That is a unfortunate.. Let me know what you think about this PR:

  1. Drop it for now.
  2. Go for the C++20 transition, but not do the fmt -> std::format transition now (avoids statically linking with libstd++ on ubuntu 22.04).
  3. Do both C++20 and fmt -> std::format, dropping support for ubuntu 22.04 (EOL: 2027-04).
  4. Do both C++20 and fmt -> std::format, using a statically linked libstdc++ for jammy (current PR).

@fornwall fornwall changed the title chore(c): build the C++ project as C++20 chore(c): Update to C++20 Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants