diff options
author | Bazaah | 2023-08-20 20:52:46 +0000 |
---|---|---|
committer | Bazaah | 2023-09-09 17:10:43 +0000 |
commit | 279af4c4e82d9fef65c4927e8dabbdd8d09022fe (patch) | |
tree | 559509d6a5adbf09e48f47492abeff7636ea17d2 | |
parent | c1d084de4c396c62c6122266d99d6c451cb519c9 (diff) | |
download | aur-279af4c4e82d9fef65c4927e8dabbdd8d09022fe.tar.gz |
repo: add ceph-18.2.0-fmt10-fixes.patch
This is fairly wide ranging series of patches, fixing multiple compile
errors owing changes in fmtlib 9 and 10.
Care was taken to attempt to not introduce #includes for fmtlib headers
in the public headers of the project, largely through defining a sister
<header file>_fmt.h header that just contains the necessary fmtlib
definitions, along with importing these files into src/... files as
needed. This appears to be the convention (at least, in some parts) of
the upstream codebase.
Briefly outlined, these are issues fixed:
1. Missing fmt::ostream_formatter definitions for types
These used to be implicit, but now fmtlib requires that types
specifically opt into this behavior.
~ src/common/LogEntry.h: clog_type, LogEntry
+ src/include/neorados/RADOS_fmt.hpp: neorados::Object
+ src/include/types_fmt.h: shard_id_t
2. Missing format_to() interface for ceph_le<T>
According to the upstream docs, it should be possible to just use the
explicit cast to the underlying T for formatting, but for whatever
reason, this doesn't work.
Therefore, define a templated format_to() for ceph_le<T> casting to
the underlying T, explicitly.
This is a fmtlib 10 feature -- previously format_to() was reserved for
enums. However, this is the simplest method I can see to avoid needing
to #include fmtlib headers in this header tree.
~ src/include/byteorder.h: ceph_le<T>
3. Make fmt::formatter.format definitions const
Required since fmtlib 8, but seemingly only became an issue in 10.
~ src/osd/osd_types_fmt.h: chunk_info_t, pg_info_t, SnapSet,
ScrubMap::object, ScrubMap
4. Explicitly from snapid_t to uint64_t for fmt::sprintf calls
As the fmt::formatter.parse implementation for snapid_t does not
handle the formatting qualifier used (or any at all).
I think previously this implicitly was casted to uint64_t anyway, so
we're just making the behavior explicit.
~ src/osd/SnapMapper.cc: snapid_t
5. Adding a fmt::formatter implementation for EntityName
Appears to have another casualty in the "no longer try implicit casts"
behavior change of fmtlib 10
~ src/common/LogEntry.h: EntityName
In addition to the above, we defer LogEntry's formatter to the ostream
implementation rather than duplicating the same output, separately in
the fmt::formatter.format definition.
References: https://github.com/fmtlib/fmt/releases/tag/10.0.0
References: https://github.com/fmtlib/fmt/releases/tag/8.0.0
-rw-r--r-- | ceph-18.2.0-fmt10-fixes.patch | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/ceph-18.2.0-fmt10-fixes.patch b/ceph-18.2.0-fmt10-fixes.patch new file mode 100644 index 000000000000..10ae19ee36e1 --- /dev/null +++ b/ceph-18.2.0-fmt10-fixes.patch @@ -0,0 +1,206 @@ +diff --git a/src/common/LogEntry.h b/src/common/LogEntry.h +index 3ddebbd3043..b9096e2850a 100644 +--- a/src/common/LogEntry.h ++++ b/src/common/LogEntry.h +@@ -15,7 +15,11 @@ + #ifndef CEPH_LOGENTRY_H + #define CEPH_LOGENTRY_H + ++#include <fmt/core.h> + #include <fmt/format.h> ++#if FMT_VERSION >= 90000 ++#include <fmt/ostream.h> ++#endif + + #include "include/utime.h" + #include "msg/msg_fmt.h" +@@ -194,19 +198,17 @@ inline std::ostream& operator<<(std::ostream& out, const LogEntry& e) + << e.channel << " " << e.prio << " " << e.msg; + } + +-template <> struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> { +- template <typename FormatContext> +- auto format(const EntityName& e, FormatContext& ctx) { +- return formatter<std::string_view>::format(e.to_str(), ctx); +- } +-}; ++template <> ++struct fmt::formatter<clog_type>: fmt::ostream_formatter {}; + +-template <> struct fmt::formatter<LogEntry> : fmt::formatter<std::string_view> { +- template <typename FormatContext> +- auto format(const LogEntry& e, FormatContext& ctx) { +- return fmt::format_to(ctx.out(), "{} {} ({}) {} : {} {} {}", +- e.stamp, e.name, e.rank, e.seq, e.channel, e.prio, e.msg); ++template <> ++struct fmt::formatter<EntityName> : fmt::formatter<std::string_view> { ++ auto format(const EntityName& e, format_context& ctx) { ++ return fmt::formatter<std::string_view>::format(e.to_str(), ctx); + } + }; + ++template <> ++struct fmt::formatter<LogEntry> : fmt::ostream_formatter {}; ++ + #endif +diff --git a/src/include/byteorder.h b/src/include/byteorder.h +index eb6d5e102b4..9a4d0be877a 100644 +--- a/src/include/byteorder.h ++++ b/src/include/byteorder.h +@@ -53,3 +53,8 @@ inline ceph_les16 init_les16(__s16 x) { + v = x; + return v; + } ++ ++template <typename T> ++auto format_as(ceph_le<T> c) { ++ return (T)c; ++} +diff --git a/src/include/neorados/RADOS_fmt.hpp b/src/include/neorados/RADOS_fmt.hpp +new file mode 100644 +index 00000000000..1512ec965fe +--- /dev/null ++++ b/src/include/neorados/RADOS_fmt.hpp +@@ -0,0 +1,16 @@ ++// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- ++// vim: ts=8 sw=2 smarttab ++#pragma once ++/** ++ * \file fmtlib formatters for some neorados types ++ */ ++ ++#include <fmt/core.h> ++#if FMT_VERSION >= 90000 ++#include <fmt/ostream.h> ++#endif ++ ++#include <include/neorados/RADOS.hpp> ++ ++template <> ++struct fmt::formatter<neorados::Object> : fmt::ostream_formatter {}; +diff --git a/src/include/types_fmt.h b/src/include/types_fmt.h +new file mode 100644 +index 00000000000..3d40085f0b2 +--- /dev/null ++++ b/src/include/types_fmt.h +@@ -0,0 +1,16 @@ ++// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- ++// vim: ts=8 sw=2 smarttab ++#pragma once ++/** ++ * \file fmtlib formatters for some types.h classes ++ */ ++ ++#include <fmt/core.h> ++#if FMT_VERSION >= 90000 ++#include <fmt/ostream.h> ++#endif ++ ++#include <include/types.h> ++ ++template <> ++struct fmt::formatter<shard_id_t> : fmt::ostream_formatter {}; +diff --git a/src/osd/SnapMapper.cc b/src/osd/SnapMapper.cc +index 7893bc08fdc..e8d34cd25bc 100644 +--- a/src/osd/SnapMapper.cc ++++ b/src/osd/SnapMapper.cc +@@ -211,7 +211,7 @@ string SnapMapper::get_prefix(int64_t pool, snapid_t snap) + return fmt::sprintf("%s%lld_%.16X_", + MAPPING_PREFIX, + pool, +- snap); ++ (uint64_t)snap); + } + + string SnapMapper::to_raw_key( +@@ -650,7 +650,7 @@ string SnapMapper::make_purged_snap_key(int64_t pool, snapid_t last) + return fmt::sprintf("%s_%lld_%016llx", + PURGED_SNAP_PREFIX, + pool, +- last); ++ (uint64_t)last); + } + + void SnapMapper::make_purged_snap_key_value( +@@ -866,7 +866,7 @@ string SnapMapper::get_legacy_prefix(snapid_t snap) + { + return fmt::sprintf("%s%.16X_", + LEGACY_MAPPING_PREFIX, +- snap); ++ (uint64_t)snap); + } + + string SnapMapper::to_legacy_raw_key( +diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h +index afed5fa8351..e374369e8ba 100644 +--- a/src/osd/osd_types.h ++++ b/src/osd/osd_types.h +@@ -35,6 +35,7 @@ + #include "msg/msg_types.h" + #include "include/compat.h" + #include "include/types.h" ++#include "include/types_fmt.h" + #include "include/utime.h" + #include "include/CompatSet.h" + #include "common/ceph_context.h" +diff --git a/src/osd/osd_types_fmt.h b/src/osd/osd_types_fmt.h +index 8d48134106e..65a751469f7 100644 +--- a/src/osd/osd_types_fmt.h ++++ b/src/osd/osd_types_fmt.h +@@ -57,7 +57,7 @@ struct fmt::formatter<chunk_info_t> { + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + + template <typename FormatContext> +- auto format(const chunk_info_t& ci, FormatContext& ctx) ++ auto format(const chunk_info_t& ci, FormatContext& ctx) const + { + return fmt::format_to(ctx.out(), "(len: {} oid: {} offset: {} flags: {})", + ci.length, ci.oid, ci.offset, +@@ -169,7 +169,7 @@ struct fmt::formatter<pg_info_t> { + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + + template <typename FormatContext> +- auto format(const pg_info_t& pgi, FormatContext& ctx) ++ auto format(const pg_info_t& pgi, FormatContext& ctx) const + { + fmt::format_to(ctx.out(), "{}({}", pgi.pgid, (pgi.dne() ? " DNE" : "")); + if (pgi.is_empty()) { +@@ -211,7 +211,7 @@ struct fmt::formatter<SnapSet> { + } + + template <typename FormatContext> +- auto format(const SnapSet& snps, FormatContext& ctx) ++ auto format(const SnapSet& snps, FormatContext& ctx) const + { + if (verbose) { + // similar to SnapSet::dump() +@@ -265,7 +265,7 @@ struct fmt::formatter<ScrubMap::object> { + + ///\todo: consider passing the 'D" flag to control snapset dump + template <typename FormatContext> +- auto format(const ScrubMap::object& so, FormatContext& ctx) ++ auto format(const ScrubMap::object& so, FormatContext& ctx) const + { + fmt::format_to(ctx.out(), + "so{{ sz:{} dd:{} od:{} ", +@@ -308,7 +308,7 @@ struct fmt::formatter<ScrubMap> { + } + + template <typename FormatContext> +- auto format(const ScrubMap& smap, FormatContext& ctx) ++ auto format(const ScrubMap& smap, FormatContext& ctx) const + { + fmt::format_to(ctx.out(), + "smap{{ valid:{} incr-since:{} #:{}", +diff --git a/src/tools/neorados.cc b/src/tools/neorados.cc +index 24966d2aee5..44ee1cf199c 100644 +--- a/src/tools/neorados.cc ++++ b/src/tools/neorados.cc +@@ -36,6 +36,7 @@ + #include "include/buffer.h" // :( + + #include "include/neorados/RADOS.hpp" ++#include "include/neorados/RADOS_fmt.hpp" + + using namespace std::literals; + |