[MDEV-31963] MariaDB fails to build with libfmt 10.1.0 Created: 2023-08-20  Updated: 2023-10-24  Resolved: 2023-08-28

Status: Closed
Project: MariaDB Server
Component/s: Compiling
Affects Version/s: 10.9.8, 10.10.6, 10.11.5, 11.0.3
Fix Version/s: 10.10.7, 10.11.6, 11.0.4, 11.1.3, 11.2.2

Type: Bug Priority: Major
Reporter: Ruoyu Zhong Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None
Environment:

{macOS (

{11, 12, 13}

and

{x86_64, arm64}

), GNU Linux (x86_64)}
fmt 10.1.0


Attachments: Text File item_strfunc.log    
Issue Links:
Duplicate
is duplicated by MDEV-32564 Mariadb not detect libfmt libs existi... Closed

 Description   

MariaDB fails to build with the latest libfmt 10.1.0 (https://github.com/fmtlib/fmt/releases/tag/10.1.0). CMake configuration fails with the following:

  CMake Error at cmake/libfmt.cmake:45 (MESSAGE):
    system libfmt library is not found or unusable

The underlying error is that the code snippet in cmake/libfmt.cmake fails to compile (compiler explorer: https://godbolt.org/z/bWGoW55x3 ):

#define FMT_STATIC_THOUSANDS_SEPARATOR ','
#define FMT_HEADER_ONLY 1
#include <fmt/format-inl.h>
#include <iostream>
int main() {
  fmt::format_args::format_arg arg=
    fmt::detail::make_arg<fmt::format_context>(42);
    std::cout << fmt::vformat("The answer is {}.",
                              fmt::format_args(&arg, 1));
}

<source>: In function 'int main()':
<source>:7:47: error: no matching function for call to 'make_arg<fmt::v10::format_context>(int)'
    7 |     fmt::detail::make_arg<fmt::format_context>(42);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
In file included from /opt/compiler-explorer/libs/fmt/trunk/include/fmt/format.h:49,
                 from /opt/compiler-explorer/libs/fmt/trunk/include/fmt/format-inl.h:25,
                 from <source>:3:
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1588:20: note: candidate: 'constexpr fmt::v10::basic_format_arg<Context> fmt::v10::detail::make_arg(T&) [with Context = fmt::v10::basic_format_context<fmt::v10::appender, char>; T = int]' (near match)
 1588 | FMT_CONSTEXPR auto make_arg(T& val) -> basic_format_arg<Context> {
      |                    ^~~~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1588:20: note:   conversion of argument 1 would be ill-formed:
<source>:7:48: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
    7 |     fmt::detail::make_arg<fmt::format_context>(42);
      |                                                ^~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1559:31: note: candidate: 'template<bool PACKED, class Context, class T, typename std::enable_if<PACKED, int>::type <anonymous> > constexpr fmt::v10::detail::value<Context> fmt::v10::detail::make_arg(T&)'
 1559 | FMT_CONSTEXPR FMT_INLINE auto make_arg(T& val) -> value<Context> {
      |                               ^~~~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1559:31: note:   template argument deduction/substitution failed:
<source>:7:47: error: type/value mismatch at argument 1 in template parameter list for 'template<bool PACKED, class Context, class T, typename std::enable_if<PACKED, int>::type <anonymous> > constexpr fmt::v10::detail::value<Context> fmt::v10::detail::make_arg(T&)'
    7 |     fmt::detail::make_arg<fmt::format_context>(42);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
<source>:7:47: note:   expected a constant of type 'bool', got 'fmt::v10::format_context' {aka 'fmt::v10::basic_format_context<fmt::v10::appender, char>'}
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1596:27: note: candidate: 'template<bool PACKED, class Context, class T, typename std::enable_if<(! PACKED), int>::type <anonymous> > constexpr fmt::v10::basic_format_arg<Context> fmt::v10::detail::make_arg(T&)'
 1596 | FMT_CONSTEXPR inline auto make_arg(T& val) -> basic_format_arg<Context> {
      |                           ^~~~~~~~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/core.h:1596:27: note:   template argument deduction/substitution failed:
<source>:7:47: error: type/value mismatch at argument 1 in template parameter list for 'template<bool PACKED, class Context, class T, typename std::enable_if<(! PACKED), int>::type <anonymous> > constexpr fmt::v10::basic_format_arg<Context> fmt::v10::detail::make_arg(T&)'
    7 |     fmt::detail::make_arg<fmt::format_context>(42);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
<source>:7:47: note:   expected a constant of type 'bool', got 'fmt::v10::format_context' {aka 'fmt::v10::basic_format_context<fmt::v10::appender, char>'}
Compiler returned: 1

sql/item_strfunc.cc also fails to compile, with basically the same error. Error output can be found in the attachment item_strfunc.log.

The reason behind this is that fmt::detail::make_arg does not accept temporaries, as mentioned in https://github.com/fmtlib/fmt/issues/3596#issuecomment-1679244746.

This error was observed while packaging MariaDB 10.9.8 (https://github.com/Homebrew/homebrew-core/pull/139568), 10.10.6 (https://github.com/Homebrew/homebrew-core/pull/139563), 10.11.5 (https://github.com/Homebrew/homebrew-core/pull/139564), and 11.0.3 (https://github.com/Homebrew/homebrew-core/pull/139562) for Homebrew. I believe that this also affects all other versions where libfmt is used, including the newest 11.3 that's still under development.



 Comments   
Comment by Ruoyu Zhong [ 2023-08-20 ]

I have proposed a fix at https://github.com/MariaDB/server/pull/2732 .

Generated at Thu Feb 08 10:27:47 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.