Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fmt to v11.0.2 #1457

Merged
merged 5 commits into from
Jul 23, 2024
Merged

Update fmt to v11.0.2 #1457

merged 5 commits into from
Jul 23, 2024

Conversation

tchaikov
Copy link
Contributor

this changeset fixes the build with fmt 11:

  • prevent fmt from formatting StringView as a sequence
  • include fmt/ranges.h for using fmt::join()

@tchaikov
Copy link
Contributor Author

@microsoft-github-policy-service agree

@tchaikov

This comment was marked as resolved.

in fmt 11, fmt/ranges.h tries to format sequence-like containers as
a sequence. but we already have a specialization for `StringView`,
this confuses compiler:

```
/usr/bin/g++ -DFMT_SHARED -DVCPKG_BASE_VERSION=2024-06-10 -DVCPKG_VERSION=2.fc41 -D_FILE_OFFSET_BITS=64 -I/builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include -I/builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/redhat-linux-build/_cmrc/include -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -mbranch-protection=standard -fasynchronous-unwind-tables -fstack-clash-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -DNDEBUG -std=c++17 -MD -MT CMakeFiles/vcpkg.dir/src/vcpkg.cpp.o -MF CMakeFiles/vcpkg.dir/src/vcpkg.cpp.o.d -o CMakeFiles/vcpkg.dir/src/vcpkg.cpp.o -c /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/src/vcpkg.cpp
In file included from /usr/include/c++/14/bits/char_traits.h:50,
                 from /usr/include/c++/14/string:42,
                 from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/lineinfo.h:5,
                 from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/checks.h:3,
                 from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/optional.h:5,
                 from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/chrono.h:5,
                 from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/src/vcpkg.cpp:3:
/usr/include/c++/14/type_traits: In substitution of ‘template<class _Tp, class ... _Args> using std::__is_constructible_impl = std::__bool_constant<__is_constructible(_Tp, _Args ...)> [with _Tp = fmt::v11::formatter<vcpkg::StringView, char, void>; _Args = {}]’:
/usr/include/c++/14/type_traits:1115:12:   required from ‘struct std::is_constructible<fmt::v11::formatter<vcpkg::StringView, char, void> >’
 1115 |     struct is_constructible
      |            ^~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:1509:66:   required from ‘struct fmt::v11::detail::arg_mapper<fmt::v11::context>::formattable<const vcpkg::StringView, vcpkg::StringView>’
 1509 |                                      (has_formatter<U, Context>::value &&
      |                                                                  ^~~~~
/usr/include/fmt/base.h:1516:25:   required by substitution of ‘template<class T, typename std::enable_if<(! fmt::v11::detail::arg_mapper<fmt::v11::context>::formattable<T, typename std::remove_const<_Tp>::type>::value), int>::type <anonymous> > constexpr fmt::v11::detail::unformattable fmt::v11::detail::arg_mapper<fmt::v11::context>::do_map(T&) [with T = const vcpkg::StringView; typename std::enable_if<(! fmt::v11::detail::arg_mapper<fmt::v11::context>::formattable<T, typename std::remove_const<_Tp>::type>::value), int>::type <anonymous> = <missing>]’
 1516 |   template <typename T, FMT_ENABLE_IF(!formattable<T>::value)>
      |                         ^
/usr/include/fmt/base.h:1529:68:   required by substitution of ‘template<class T, class U, typename std::enable_if<((((((((std::is_class<U>::value || std::is_enum<_Tp2>::value) || std::is_union<U>::value) || std::is_fundamental<U>::value) && (! fmt::v11::detail::has_to_string_view<U, void>::value)) && (! fmt::v11::is_char<U>::value)) && (! fmt::v11::detail::is_named_arg<T>::value)) && (! std::is_integral<_Size>::value)) && (! std::is_arithmetic<typename fmt::v11::detail::format_as_result<U>::type>::value)), int>::type <anonymous> > constexpr decltype (((fmt::v11::detail::arg_mapper<fmt::v11::context>*)this)->fmt::v11::detail::arg_mapper<fmt::v11::context>::do_map(val)) fmt::v11::detail::arg_mapper<fmt::v11::context>::map(T&) [with T = const vcpkg::StringView; U = vcpkg::StringView; typename std::enable_if<((((((((std::is_class<U>::value || std::is_enum<_Tp2>::value) || std::is_union<U>::value) || std::is_fundamental<U>::value) && (! fmt::v11::detail::has_to_string_view<U, void>::value)) && (! fmt::v11::is_char<U>::value)) && (! fmt::v11::detail::is_named_arg<T>::value)) && (! std::is_integral<_Size>::value)) && (! std::is_arithmetic<typename fmt::v11::detail::format_as_result<U>::type>::value)), int>::type <anonymous> = 0]’
 1529 |   FMT_MAP_API auto map(T& val) -> decltype(FMT_DECLTYPE_THIS do_map(val)) {
      |                                                              ~~~~~~^~~~~
/usr/include/fmt/base.h:1545:53:   required by substitution of ‘template<class T, class Context> using fmt::v11::detail::mapped_type_constant = fmt::v11::detail::type_constant<decltype (fmt::v11::detail::arg_mapper<Context>().map(declval<const T&>())), typename Context::char_type> [with T = vcpkg::StringView; Context = fmt::v11::context]’
 1545 |     type_constant<decltype(arg_mapper<Context>().map(std::declval<const T&>())),
      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:1584:68:   required from ‘constexpr long long unsigned int fmt::v11::detail::encode_types() [with Context = fmt::v11::context; Arg = vcpkg::StringView; Args = {}]’
 1584 |   return static_cast<unsigned>(mapped_type_constant<Arg, Context>::value) |
      |                                                                    ^~~~~
/usr/include/fmt/base.h:1590:67:   required from ‘constexpr long long unsigned int fmt::v11::detail::make_descriptor() [with Context = fmt::v11::context; T = {vcpkg::StringView}; long unsigned int NUM_ARGS = 1]’
 1590 |   return NUM_ARGS <= max_packed_args ? encode_types<Context, T...>()
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/fmt/base.h:2011:53:   required by substitution of ‘template<class Context, class ... T, long unsigned int NUM_NAMED_ARGS, long long unsigned int DESC, typename std::enable_if<(NUM_NAMED_ARGS != 0), int>::type <anonymous> > constexpr fmt::v11::detail::format_arg_store<Context, sizeof... (T), NUM_NAMED_ARGS, DESC> fmt::v11::make_format_args(T& ...) [with Context = fmt::v11::context; T = {vcpkg::StringView}; long unsigned int NUM_NAMED_ARGS = 0; long long unsigned int DESC = <missing>; typename std::enable_if<(NUM_NAMED_ARGS != 0), int>::type <anonymous> = <missing>]’
 2011 |               detail::make_descriptor<Context, T...>() |
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/fmt/format.h:4357:44:   required from ‘std::string fmt::v11::format(format_string<T ...>, T&& ...) [with T = {vcpkg::StringView&}; std::string = std::__cxx11::basic_string<char>; format_string<T ...> = basic_format_string<char, vcpkg::StringView&>]’
 4357 |   return vformat(fmt, fmt::make_format_args(args...));
      |                       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/json.h:256:65:   required from here
  256 |                 Checks::unreachable(VCPKG_LINE_INFO, fmt::format("JSON object missing key {}", key));
      |                                                      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/type_traits:1110:25: error: ambiguous template instantiation for ‘struct fmt::v11::formatter<vcpkg::StringView, char, void>’
 1110 |       = __bool_constant<__is_constructible(_Tp, _Args...)>;
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/fmt.h:17,
                 from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/messages.h:5,
                 from /builddir/build/BUILD/vcpkg-2024.06.10-build/vcpkg-tool-2024-06-10/include/vcpkg/base/checks.h:4:
/usr/include/fmt/ranges.h:517:8: note: candidates are: ‘template<class R, class Char> struct fmt::v11::formatter<R, Char, typename std::enable_if<fmt::v11::conjunction<std::integral_constant<bool, ((((fmt::v11::range_format_kind<R, Char, void>::value != fmt::v11::range_format::disabled) && (fmt::v11::range_format_kind<R, Char, void>::value != fmt::v11::range_format::map)) && (fmt::v11::range_format_kind<R, Char, void>::value != fmt::v11::range_format::string)) && (fmt::v11::range_format_kind<R, Char, void>::value != fmt::v11::range_format::debug_string))>, fmt::v11::detail::is_formattable_delayed<R, Char> >::value, void>::type> [with R = vcpkg::StringView; Char = char]’
  517 | struct formatter<
      |        ^~~~~~~~~~
  518 |     R, Char,
      |     ~~~~~~~~
  519 |     enable_if_t<conjunction<
      |     ~~~~~~~~~~~~~~~~~~~~~~~~
  520 |         bool_constant<
      |         ~~~~~~~~~~~~~~
  521 |             range_format_kind<R, Char>::value != range_format::disabled &&
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  522 |             range_format_kind<R, Char>::value != range_format::map &&
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  523 |             range_format_kind<R, Char>::value != range_format::string &&
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  524 |             range_format_kind<R, Char>::value != range_format::debug_string>
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  525 | // Workaround a bug in MSVC 2015 and earlier.
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  526 | #if !FMT_MSC_VERSION || FMT_MSC_VERSION >= 1910
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  527 |         ,
      |         ~
  528 |         detail::is_formattable_delayed<R, Char>
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  529 | #endif
      | ~~~~~~
  530 |         >::value>> {
      |         ~~~~~~~~~~
```

so in order to disambiguate the resolution, let's explicitly
disable the range formatter.

Fixes microsoft/vcpkg#39946
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
fmt::join() was moved into fmt/ranges.h in fmt 11, so let's include
this header file for using it.

Fixes microsoft/vcpkg#39946
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
@tchaikov
Copy link
Contributor Author

@WangWeiLin-MV in case you are interested.

@ras0219-msft ras0219-msft self-assigned this Jul 19, 2024
@BillyONeal BillyONeal changed the title Fix build with fmt 11 Update fmt to v11.0.2 Jul 23, 2024
Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

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

Thanks!

@BillyONeal BillyONeal enabled auto-merge (squash) July 23, 2024 20:45
@BillyONeal BillyONeal merged commit d67080f into microsoft:main Jul 23, 2024
5 checks passed
@tchaikov tchaikov deleted the fmt-11 branch July 25, 2024 13:27
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.

[vcpkg-tool] vcpkg-tool build failure against fmt 11
3 participants