bluescarni / obake

A C++20 library for the symbolic manipulation of sparse polynomials & co.
https://bluescarni.github.io/obake
Mozilla Public License 2.0
22 stars 8 forks source link

0.8.0: Fails to build due to libfmt issues #150

Open yurivict opened 1 year ago

yurivict commented 1 year ago
===>  Building for obake-0.8.0
[ 25% 2/4] /usr/local/libexec/ccache/c++ -DFMT_SHARED -Dobake_EXPORTS -I/usr/ports/math/obake/work/obake-0.8.0/include -I/usr/ports/math/obake/work/.build/include -isystem /usr/local/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED  -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -ftemplate-depth=1024 -fdiagnostics-show-template-tree -pthread -std=c++20 -MD -MT CMakeFiles/obake.dir/src/polynomials/d_packed_monomial.cpp.o -MF CMakeFiles/obake.dir/src/polynomials/d_packed_monomial.cpp.o.d -o CMakeFiles/obake.dir/src/polynomials/d_packed_monomial.cpp.o -c /usr/ports/math/obake/work/obake-0.8.0/src/polynomials/d_packed_monomial.cpp
FAILED: CMakeFiles/obake.dir/src/polynomials/d_packed_monomial.cpp.o 
/usr/local/libexec/ccache/c++ -DFMT_SHARED -Dobake_EXPORTS -I/usr/ports/math/obake/work/obake-0.8.0/include -I/usr/ports/math/obake/work/.build/include -isystem /usr/local/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED  -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -ftemplate-depth=1024 -fdiagnostics-show-template-tree -pthread -std=c++20 -MD -MT CMakeFiles/obake.dir/src/polynomials/d_packed_monomial.cpp.o -MF CMakeFiles/obake.dir/src/polynomials/d_packed_monomial.cpp.o.d -o CMakeFiles/obake.dir/src/polynomials/d_packed_monomial.cpp.o -c /usr/ports/math/obake/work/obake-0.8.0/src/polynomials/d_packed_monomial.cpp
In file included from /usr/ports/math/obake/work/obake-0.8.0/src/polynomials/d_packed_monomial.cpp:16:
In file included from /usr/ports/math/obake/work/obake-0.8.0/include/obake/polynomials/d_packed_monomial.hpp:30:
/usr/local/include/fmt/core.h:2743:12: error: call to deleted constructor of 'conditional_t<has_formatter<mapped_type, context>::value, formatter<mapped_type, char_type>, fallback_formatter<stripped_type, char_type>>' (aka 'fmt::detail::fallback_formatter<mppp::integer<1>>')
  auto f = conditional_t<has_formatter<mapped_type, context>::value,
           ^
/usr/local/include/fmt/core.h:2954:23: note: in instantiation of function template specialization 'fmt::detail::parse_format_specs<mppp::integer<1>, fmt::detail::compile_parse_context<char>>' requested here
        parse_funcs_{&parse_format_specs<Args, parse_context_type>...},
                      ^
/usr/local/include/fmt/core.h:3159:47: note: in instantiation of member function 'fmt::detail::format_string_checker<char, fmt::detail::error_handler, mppp::integer<1>>::format_string_checker' requested here
      detail::parse_format_string<true>(str_, checker(s, {}));
                                              ^
/usr/ports/math/obake/work/obake-0.8.0/include/obake/polynomials/d_packed_monomial.hpp:436:45: note: in instantiation of function template specialization 'fmt::basic_format_string<char, mppp::integer<1> &>::basic_format_string<char[8], 0>' requested here
                    *cur_oss << fmt::format("^{{{}}}", tmp_mp);
                                            ^
/usr/local/include/fmt/core.h:1124:3: note: 'fallback_formatter' has been explicitly marked deleted here
  fallback_formatter() = delete;
  ^
/usr/local/include/fmt/core.h:1756:3: error: static_assert failed due to requirement 'formattable' "Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt"
  static_assert(
  ^
/usr/local/include/fmt/core.h:1777:10: note: in instantiation of function template specialization 'fmt::detail::make_value<fmt::basic_format_context<fmt::appender, char>, mppp::integer<1> &>' requested here
  return make_value<Context>(val);
         ^
/usr/local/include/fmt/core.h:1899:23: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::basic_format_context<fmt::appender, char>, fmt::detail::type::custom_type, mppp::integer<1> &, 0>' requested here
        data_{detail::make_arg<
                      ^
/usr/local/include/fmt/core.h:1918:10: note: in instantiation of function template specialization 'fmt::format_arg_store<fmt::basic_format_context<fmt::appender, char>, mppp::integer<1>>::format_arg_store<mppp::integer<1> &>' requested here
  return {FMT_FORWARD(args)...};
         ^
/usr/local/include/fmt/core.h:3206:28: note: in instantiation of function template specialization 'fmt::make_format_args<fmt::basic_format_context<fmt::appender, char>, mppp::integer<1> &>' requested here
  return vformat(fmt, fmt::make_format_args(args...));
                           ^
/usr/ports/math/obake/work/obake-0.8.0/include/obake/polynomials/d_packed_monomial.hpp:436:38: note: in instantiation of function template specialization 'fmt::format<mppp::integer<1> &>' requested here
                    *cur_oss << fmt::format("^{{{}}}", tmp_mp);
                                     ^
2 errors generated.
[ 50% 2/4] /usr/local/libexec/ccache/c++ -DFMT_SHARED -Dobake_EXPORTS -I/usr/ports/math/obake/work/obake-0.8.0/include -I/usr/ports/math/obake/work/.build/include -isystem /usr/local/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED  -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -ftemplate-depth=1024 -fdiagnostics-show-template-tree -pthread -std=c++20 -MD -MT CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o -MF CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o.d -o CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o -c /usr/ports/math/obake/work/obake-0.8.0/src/polynomials/packed_monomial.cpp
FAILED: CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o 
/usr/local/libexec/ccache/c++ -DFMT_SHARED -Dobake_EXPORTS -I/usr/ports/math/obake/work/obake-0.8.0/include -I/usr/ports/math/obake/work/.build/include -isystem /usr/local/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED -O2 -pipe -fstack-protector-strong -fno-strict-aliasing  -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED  -DNDEBUG -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -ftemplate-depth=1024 -fdiagnostics-show-template-tree -pthread -std=c++20 -MD -MT CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o -MF CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o.d -o CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o -c /usr/ports/math/obake/work/obake-0.8.0/src/polynomials/packed_monomial.cpp
In file included from /usr/ports/math/obake/work/obake-0.8.0/src/polynomials/packed_monomial.cpp:17:
/usr/local/include/fmt/core.h:2743:12: error: call to deleted constructor of 'conditional_t<has_formatter<mapped_type, context>::value, formatter<mapped_type, char_type>, fallback_formatter<stripped_type, char_type>>' (aka 'fmt::detail::fallback_formatter<mppp::integer<1>>')
  auto f = conditional_t<has_formatter<mapped_type, context>::value,
           ^
/usr/local/include/fmt/core.h:2954:23: note: in instantiation of function template specialization 'fmt::detail::parse_format_specs<mppp::integer<1>, fmt::detail::compile_parse_context<char>>' requested here
        parse_funcs_{&parse_format_specs<Args, parse_context_type>...},
                      ^
/usr/local/include/fmt/core.h:3159:47: note: in instantiation of member function 'fmt::detail::format_string_checker<char, fmt::detail::error_handler, mppp::integer<1>>::format_string_checker' requested here
      detail::parse_format_string<true>(str_, checker(s, {}));
                                              ^
/usr/ports/math/obake/work/obake-0.8.0/src/polynomials/packed_monomial.cpp:172:41: note: in instantiation of function template specialization 'fmt::basic_format_string<char, mppp::integer<1> &>::basic_format_string<char[8], 0>' requested here
                *cur_oss << fmt::format("^{{{}}}", tmp_mp);
                                        ^
/usr/local/include/fmt/core.h:1124:3: note: 'fallback_formatter' has been explicitly marked deleted here
  fallback_formatter() = delete;
  ^
/usr/local/include/fmt/core.h:1756:3: error: static_assert failed due to requirement 'formattable' "Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt"
  static_assert(
  ^
/usr/local/include/fmt/core.h:1777:10: note: in instantiation of function template specialization 'fmt::detail::make_value<fmt::basic_format_context<fmt::appender, char>, mppp::integer<1> &>' requested here
  return make_value<Context>(val);
         ^
/usr/local/include/fmt/core.h:1899:23: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::basic_format_context<fmt::appender, char>, fmt::detail::type::custom_type, mppp::integer<1> &, 0>' requested here
        data_{detail::make_arg<
                      ^
/usr/local/include/fmt/core.h:1918:10: note: in instantiation of function template specialization 'fmt::format_arg_store<fmt::basic_format_context<fmt::appender, char>, mppp::integer<1>>::format_arg_store<mppp::integer<1> &>' requested here
  return {FMT_FORWARD(args)...};
         ^
/usr/local/include/fmt/core.h:3206:28: note: in instantiation of function template specialization 'fmt::make_format_args<fmt::basic_format_context<fmt::appender, char>, mppp::integer<1> &>' requested here
  return vformat(fmt, fmt::make_format_args(args...));
                           ^
/usr/ports/math/obake/work/obake-0.8.0/src/polynomials/packed_monomial.cpp:172:34: note: in instantiation of function template specialization 'fmt::format<mppp::integer<1> &>' requested here
                *cur_oss << fmt::format("^{{{}}}", tmp_mp);
                                 ^
/usr/ports/math/obake/work/obake-0.8.0/src/polynomials/packed_monomial.cpp:204:13: note: in instantiation of function template specialization 'obake::polynomials::detail::(anonymous namespace)::packed_monomial_tex_stream_insert<int>' requested here
    detail::packed_monomial_tex_stream_insert(os, m, s);
            ^
2 errors generated.

libfmt-9.1.0 clang-14 FreeBSD 13.1

bluescarni commented 1 year ago

@yurivict thanks for the report.

I cannot understand what is going on though, since on conda obake was built successfully against fmt 9.1.0 on several configurations. E.g., see here for a build log on OSX using clang-14:

https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=658749&view=logs&j=58ac6aab-c4bc-5de2-2894-98e408cc8ec9&t=933f325c-924e-533d-4d95-e93b5843ce8b

I'll try to set up a local build environment with clang-14 on my machine to see if I can reproduce.

yurivict commented 1 year ago

This error maybe specific to the combination of clang and the C++ library that it uses.

The easiest way to reproduce might be to install a FreeBSD VM.

bluescarni commented 1 year ago

Ok thanks for the heads up, it may take a couple of days but I should be able to set up a FreeBSD environment on VirtualBox.

rfenrich commented 1 year ago

Hello, I confirm I have this same issue. Is there any progress?

gl-yziquel commented 1 year ago

I get the same issue if I use clang 14 and fmt 9.1.0, 9.0.0 on ubuntu. Not freebsd but ubuntu.

Same for gcc 11.4.0-1ubuntu~22.04 (well, the errors are different, but it fails to compile).

Fmt above version 10 also does not compile.

Given that this is a "reproducible build" issue, I'd suggest using FetchContent in cmake. Or get Conan into the loop. Short of going for some Bazel or Buck2 solution which I believe will be considered too heavy.

For gcc 11.4, ubuntu 22.04, fmt 9.1.0, one gets the following error:

In file included from /home/mini-me/home/cellar/obake/src/polynomials/packed_monomial.cpp:17:
/usr/local/include/fmt/core.h: In instantiation of ‘constexpr decltype (ctx.begin()) fmt::v9::detail::parse_format_specs(ParseContext&) [with T = mppp::integer<1>; ParseContext = fmt::v9::detail::compile_parse_context<char, fmt::v9::detail::error_handler>; decltype (ctx.begin()) = const char*]’:
/usr/local/include/fmt/core.h:2954:9:   required from ‘constexpr fmt::v9::detail::format_string_checker<Char, ErrorHandler, Args>::format_string_checker(fmt::v9::basic_string_view<Char>, ErrorHandler) [with Char = char; ErrorHandler = fmt::v9::detail::error_handler; Args = {mppp::integer<1>}]’
/home/mini-me/home/cellar/obake/src/polynomials/packed_monomial.cpp:172:40:   required from ‘void obake::polynomials::detail::{anonymous}::packed_monomial_tex_stream_insert(std::ostream&, const obake::polynomials::packed_monomial<T>&, const symbol_set&) [with T = int; std::ostream = std::basic_ostream<char>; obake::symbol_set = boost::container::flat_set<std::__cxx11::basic_string<char> >]’
/home/mini-me/home/cellar/obake/src/polynomials/packed_monomial.cpp:204:46:   required from here
/home/mini-me/home/cellar/obake/src/polynomials/packed_monomial.cpp:172:40:   in ‘constexpr’ expansion of ‘fmt::v9::basic_format_string<char, mppp::integer<1>&>("^{{{}}}")’
/usr/local/include/fmt/core.h:2743:12: error: use of deleted function ‘fmt::v9::detail::fallback_formatter<T, Char, Enable>::fallback_formatter() [with T = mppp::integer<1>; Char = char; Enable = void]’
 2743 |   auto f = conditional_t<has_formatter<mapped_type, context>::value,
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2744 |                          formatter<mapped_type, char_type>,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2745 |                          fallback_formatter<stripped_type, char_type>>();
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/fmt/core.h:1124:3: note: declared here
 1124 |   fallback_formatter() = delete;
      |   ^~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/obake.dir/build.make:230: CMakeFiles/obake.dir/src/polynomials/packed_monomial.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/obake.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
andrewcorrigan commented 9 months ago

I just tried the latest obake+mppp+fmtlib and am seeing the following error using Xcode (Apple clang version 14.0.0 (clang-1400.0.29.202))

In file included from /third_party/obake/include/obake/polynomials/d_packed_monomial.hpp:30:
/third_party/fmt/include/fmt/core.h:2582:45: error: implicit instantiation of undefined template 'fmt::detail::type_is_unformattable_for<mppp::integer<1>, char>'
    type_is_unformattable_for<T, char_type> _;
                                            ^
/third_party/fmt/include/fmt/core.h:2645:23: note: in instantiation of function template specialization 'fmt::detail::parse_format_specs<mppp::integer<1>, fmt::detail::compile_parse_context<char>>' requested here
        parse_funcs_{&parse_format_specs<Args, parse_context_type>...} {}
                      ^
/third_party/fmt/include/fmt/core.h:2776:47: note: in instantiation of member function 'fmt::detail::format_string_checker<char, mppp::integer<1>>::format_string_checker' requested here
      detail::parse_format_string<true>(str_, checker(s));
                                              ^
/third_party/obake/include/obake/polynomials/d_packed_monomial.hpp:436:45: note: in instantiation of function template specialization 'fmt::basic_format_string<char, mppp::integer<1> &>::basic_format_string<char[8], 0>' requested here
                    *cur_oss << fmt::format("^{{{}}}", tmp_mp);

Different error, but also triggered by the code fmt::format("^{{{}}}",

andrewcorrigan commented 5 months ago

I just tried updating to latest obake+mppp+fmtlib again and it's all working for me now.

gl-yziquel commented 5 months ago

@andrewcorrigan

I tried building all dependencies living on HEAD, and no, it still is not solved for me.

Could you please provide the exact versions of obake, mppp, abseil and fmt that worked for you ? So that I may try replicating the build ?

andrewcorrigan commented 5 months ago

It was latest trunk of each repository as of yesterday. Perhaps the issue I encountered is not the same as yours.

bluescarni commented 4 months ago

@andrewcorrigan @gl-yziquel sorry for dropping the ball on this, I completely forgot about this report.

The conda recipe for obake incorporates a fix for this issue:

https://github.com/conda-forge/obake-feedstock/blob/main/recipe/fmt_fix.diff

I will try to include the patch in the next obake version, hopefully next week if I have time. Of course if you want to help, testing the patch and PRs are always welcome :)

gl-yziquel commented 4 months ago

I unfortunately struggle to find time for this. Which is a shame as it is a dependency for the genetic algorithm backpropagation library I had my eyes on. Hope I'll find time to come back to it.

h-vetinari commented 1 month ago

Unfortunately, the fmt problems keep coming back even with the patch in the conda-forge feedstock: Building obake 0.8.0 (+ the patch) against fmt 11 fails in conda-forge.