Skip to content

rgw: replace FMT_STRING by fmt::runtime - #66928

Merged
anrao19 merged 1 commit into
ceph:mainfrom
clan:fmt
Aug 3, 2026
Merged

anrao19 merged 1 commit into
ceph:mainfrom
clan:fmt

Conversation

@clan

@clan clan commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Fix a build failure with Clang 20+ where fmt's compile-time format parsing fails in a consteval context.

The following error is triggered when building rgw_auth_s3.cc:

src/rgw/rgw_auth_s3.cc:600:22: error: call to consteval function
'fmt::basic_format_string<...>' is not a constant expression

Use fmt::runtime() to avoid compile-time format string parsing and restore buildability across toolchains.

@clan
clan requested a review from a team as a code owner January 14, 2026 15:41
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

14 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@github-actions github-actions Bot added the rgw label Jan 14, 2026
Comment thread src/rgw/rgw_auth_s3.cc Outdated
return fmt::format(FMT_STRING("{:d}{:02d}{:02d}/{:s}/{:s}/aws4_request"),
return fmt::format(fmt::runtime("{:d}{:02d}{:02d}/{:s}/{:s}/aws4_request"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't see why this can't be a compile-time format string - does it still not work with FMT_STRING removed?

@clan clan Jan 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my test shows only clang 20/21 is failed, no problem with gcc & clang below 20

and yes, it still works with FMT_STRING removed.

@tchaikov tchaikov Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, i am able to reproduce the build failure with -std=c++20, see https://godbolt.org/z/jnqcnW8Eo, where six combinations are tested:

compiler fmt build?
gcc 15.2 9.1.0 yes
clang 21 9.1.0 no
gcc 15.2 11.0.0 yes
clang 21 11.0.0 no
gcc 15.2 12.0.0 yes
clang 21 12.0.0 yes

this is a known issue, see fmtlib/fmt#4552 , which was fixed by fmt 12.0.0.

i think the right fix is to remove FMT_STRING(). like:

return fmt::format("{:d}{:02d}{:02d}/{:s}/{:s}/aws4_request",

as per https://fmt.dev/latest/api/#compile-time-checks,

Compile-time format string checks are enabled by default on compilers that support C++20 consteval. On older compilers you can use the FMT_STRING macro defined in fmt/format.h instead.

but we are now using C++23. and require a compiler which is C++23 compliant. and the minimal fmt version we require is 8.1.1, fmt enabled the compile-time format check by default in 8.0, see fmtlib/fmt#2022. so we can safely drop it.

@clan clan Jan 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, force pushed.

@clan

clan commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor Author

I think this is a problem of libfmt, build is ok after switch libfmt to 11.1.4 (which is the version used in main branch). I did the test on ceph 19.2.2 where libfmt is 9.1.0.

#include <fmt/format.h>

std::string gen_v4_scope(const std::string& region)
{
  return fmt::format(FMT_STRING("{:s}"), region);
}

clang -isystem src/fmt/include -std=c++20 -c test.cc

@tchaikov tchaikov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd suggest just drop FMT_STRING. IMHO, fmt::runtime() is not designed to be used in this use case. as "{:d}{:02d}{:02d}/{:s}/{:s}/aws4_request" is a compile-time constexpr.

@tchaikov

tchaikov commented Jan 16, 2026 •

Copy link
Copy Markdown
Contributor

Fix a build failure with Clang 20+ where fmt (v9.1.0, v11.0.0, and
possibly other versions) fails to parse format strings at compile-time
in a consteval context.

the build failure is a known issue, and documented upstream. please reference it in the commit message.

v9.1.0, v11.0.0, and possibly other versions

per the upstream release note, it's fixed in v12.0.0.

@clan
clan force-pushed the fmt branch 3 times, most recently from 6828267 to 60872ed Compare January 16, 2026 02:55
Fix a build failure with Clang 20+ using -std=c++20, where fmt
(v9.1.0, v11.0.0, and possibly other versions) fails to parse
format strings at compile-time in a consteval context. This is
a known issue in fmt, fixed in fmt v11.1.0 (see
fmtlib/fmt@6797f0c).

The following error occurs when building rgw_auth_s3.cc:

  src/rgw/rgw_auth_s3.cc:600:22: error: call to consteval function
  'fmt::basic_format_string<...>' is not a constant expression

Removing FMT_STRING avoids compile-time format string parsing
and restores buildability across different toolchains.

Test case:

  #include <fmt/format.h>

  std::string gen_v4_scope(const std::string& region)
  {
    return fmt::format(FMT_STRING("{:s}"), region);
  }

Compile with:

  clang -isystem fmt/include -std=c++20 -c test.cc

Signed-off-by: Z. Liu <[email protected]>
@clan

clan commented Jan 16, 2026

Copy link
Copy Markdown
Contributor Author

v9.1.0, v11.0.0, and possibly other versions

per the upstream release note, it's fixed in v12.0.0.

Just did a test with different release of fmt, build is ok since fmt v11.1.0, i'll update the commit message.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Mar 18, 2026
@clan

clan commented Mar 18, 2026

Copy link
Copy Markdown
Contributor Author

ping

@github-actions github-actions Bot removed the stale label Mar 18, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label May 17, 2026
@tchaikov tchaikov removed the stale label May 17, 2026
@tchaikov

Copy link
Copy Markdown
Contributor

ok to test

@tchaikov

Copy link
Copy Markdown
Contributor

jenkins test make check

@tchaikov

Copy link
Copy Markdown
Contributor

jenkins test make check arm64

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Jul 16, 2026
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

2 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@clan

clan commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

ping

@adamemerson

Copy link
Copy Markdown
Contributor

@anrao19 Could you include this in the next run, please?

@anrao19

anrao19 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

@anrao19 Could you include this in the next run, please?

sure @adamemerson

@anrao19

anrao19 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-07-17-06:18.

@anrao19

anrao19 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-07-17-06:18.

pr testing completed and approved by @ivancich

@anrao19
anrao19 merged commit 0cf7508 into ceph:main Aug 3, 2026
@clan
clan deleted the fmt branch August 3, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants