commit:     c5c974e5296e07618194b761a750e112fe80dded
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Mar  1 02:21:04 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Mar  7 03:22:44 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c5c974e5

dev-libs/libfmt: add static assert patch

Failed to build watchman w/o this upstream patch.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/libfmt-8.1.1-fix-static-assert.patch     | 76 ++++++++++++++++++++++
 dev-libs/libfmt/libfmt-8.1.1-r1.ebuild             | 40 ++++++++++++
 2 files changed, 116 insertions(+)

diff --git a/dev-libs/libfmt/files/libfmt-8.1.1-fix-static-assert.patch 
b/dev-libs/libfmt/files/libfmt-8.1.1-fix-static-assert.patch
new file mode 100644
index 000000000000..9f29d7fb111c
--- /dev/null
+++ b/dev-libs/libfmt/files/libfmt-8.1.1-fix-static-assert.patch
@@ -0,0 +1,76 @@
+https://github.com/fmtlib/fmt/commit/8f8a1a02d5c5cb967d240feee3ffac00d66f22a2.patch
+https://github.com/facebook/folly/issues/1705
+
+From 8f8a1a02d5c5cb967d240feee3ffac00d66f22a2 Mon Sep 17 00:00:00 2001
+From: Victor Zverovich <v...@fb.com>
+Date: Fri, 14 Jan 2022 13:08:14 -0800
+Subject: [PATCH] Fix handling of formattable types implicitly convertible to
+ pointers
+
+---
+ include/fmt/core.h |  5 +++--
+ test/core-test.cc  | 21 ++++++++++++++++++++-
+ 2 files changed, 23 insertions(+), 3 deletions(-)
+
+diff --git a/include/fmt/core.h b/include/fmt/core.h
+index f2d21e5c5a..12571ce0da 100644
+--- a/include/fmt/core.h
++++ b/include/fmt/core.h
+@@ -1398,10 +1398,11 @@ template <typename Context> struct arg_mapper {
+   template <
+       typename T,
+       FMT_ENABLE_IF(
+-          std::is_member_pointer<T>::value ||
++          std::is_pointer<T>::value || std::is_member_pointer<T>::value ||
+           std::is_function<typename std::remove_pointer<T>::type>::value ||
+           (std::is_convertible<const T&, const void*>::value &&
+-           !std::is_convertible<const T&, const char_type*>::value))>
++           !std::is_convertible<const T&, const char_type*>::value &&
++           !has_formatter<T, Context>::value))>
+   FMT_CONSTEXPR auto map(const T&) -> unformattable_pointer {
+     return {};
+   }
+diff --git a/test/core-test.cc b/test/core-test.cc
+index b2f2097ea1..c9eea8ffd8 100644
+--- a/test/core-test.cc
++++ b/test/core-test.cc
+@@ -737,6 +737,24 @@ struct convertible_to_pointer {
+   operator const int*() const { return nullptr; }
+ };
+ 
++struct convertible_to_pointer_formattable {
++  operator const int*() const { return nullptr; }
++};
++
++FMT_BEGIN_NAMESPACE
++template <> struct formatter<convertible_to_pointer_formattable> {
++  auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) {
++    return ctx.begin();
++  }
++
++  auto format(convertible_to_pointer_formattable, format_context& ctx) const
++      -> decltype(ctx.out()) {
++    auto test = string_view("test");
++    return std::copy_n(test.data(), test.size(), ctx.out());
++  }
++};
++FMT_END_NAMESPACE
++
+ enum class test_scoped_enum {};
+ 
+ TEST(core_test, is_formattable) {
+@@ -770,11 +788,12 @@ TEST(core_test, is_formattable) {
+ #endif
+ 
+   static_assert(!fmt::is_formattable<convertible_to_pointer>::value, "");
++  const auto f = convertible_to_pointer_formattable();
++  EXPECT_EQ(fmt::format("{}", f), "test");
+ 
+   static_assert(!fmt::is_formattable<void (*)()>::value, "");
+ 
+   struct s;
+-
+   static_assert(!fmt::is_formattable<int(s::*)>::value, "");
+   static_assert(!fmt::is_formattable<int (s::*)()>::value, "");
+   static_assert(!fmt::is_formattable<test_scoped_enum>::value, "");
+

diff --git a/dev-libs/libfmt/libfmt-8.1.1-r1.ebuild 
b/dev-libs/libfmt/libfmt-8.1.1-r1.ebuild
new file mode 100644
index 000000000000..1c6b0f4fa2dc
--- /dev/null
+++ b/dev-libs/libfmt/libfmt-8.1.1-r1.ebuild
@@ -0,0 +1,40 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+CMAKE_ECLASS=cmake
+inherit cmake-multilib
+
+DESCRIPTION="Small, safe and fast formatting library"
+HOMEPAGE="https://github.com/fmtlib/fmt";
+
+LICENSE="MIT"
+IUSE="test"
+SLOT="0/${PV}"
+
+if [[ ${PV} == *9999 ]] ; then
+       EGIT_REPO_URI="https://github.com/fmtlib/fmt.git";
+       inherit git-r3
+else
+       SRC_URI="https://github.com/fmtlib/fmt/archive/${PV}.tar.gz -> 
${P}.tar.gz"
+       KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
+       S="${WORKDIR}/fmt-${PV}"
+fi
+
+DEPEND=""
+RDEPEND=""
+RESTRICT="!test? ( test )"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-fix-static-assert.patch
+)
+
+multilib_src_configure() {
+       local mycmakeargs=(
+               -DFMT_CMAKE_DIR="$(get_libdir)/cmake/fmt"
+               -DFMT_LIB_DIR="$(get_libdir)"
+               -DFMT_TEST=$(usex test)
+       )
+       cmake_src_configure
+}

Reply via email to