fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
20.4k stars 2.45k forks source link

Problems compiling with Intel C++ (OneAPI) #3390

Closed gkthiruvathukal closed 1 year ago

gkthiruvathukal commented 1 year ago

I'm working with Intel's OneAPI compiler and running into a handful of errors when building fmt. The language level supported is C++ 17. This is the 2023.1 release of the Intel tools.

$ cmake -S . -B build
-- The CXX compiler identification is IntelLLVM 2023.1.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/intel/oneapi/compiler/latest/linux/bin/icpx - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Module support is disabled.
-- Version: 9.1.0
-- Build type:
-- CXX_STANDARD: 17
-- Performing Test has_std_17_flag
-- Performing Test has_std_17_flag - Success
-- Performing Test has_std_1z_flag
-- Performing Test has_std_1z_flag - Success
-- Required features: cxx_variadic_templates
-- Build spdlog: 1.9.2
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Build type: Release
-- scn version: 1.1.2
-- SCN_PEDANTIC: OFF
-- SCN_WERROR: OFF
-- The C compiler identification is IntelLLVM 2023.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/intel/oneapi/compiler/latest/linux/bin/icx - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python: /home/linuxbrew/.linuxbrew/bin/python3.11 (found version "3.11.3") found components: Interpreter
-- Configuring done (20.9s)
-- Generating done (0.1s)
-- Build files have been written to: /home/gkt/Work/unoapi-dpcpp-examples/build

# gkt @ linode5 in ~/Work/unoapi-dpcpp-examples on git:main x [15:47:21]
$ cmake --build build
[  2%] Building CXX object _deps/fmt-build/CMakeFiles/fmt.dir/src/format.cc.o
In file included from /home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/src/format.cc:8:
In file included from /home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format-inl.h:29:
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3122:38: error: implicit instantiation of undefined template 'fmt::detail::dragonbox::float_info<long double>'
    const auto f = basic_fp<typename info::carrier_uint>(converted_value);
                                     ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3230:13: note: in instantiation of function template specialization 'fmt::detail::format_float<long double>' requested here
  int exp = format_float(convert_float(value), precision, fspecs, buffer);
            ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3394:20: note: in instantiation of function template specialization 'fmt::detail::write<char, fmt::appender, long double, 0>' requested here
    return detail::write(out, value, specs, locale);
                   ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:4082:10: note: in instantiation of member function 'fmt::detail::vformat_to(buffer<char> &, basic_string_view<char>, basic_format_args<basic_format_context<detail::buffer_appender<type_identity_t<char>>, type_identity_t<char>>>, locale_ref)::format_handler::on_format_specs' requested here
  struct format_handler : error_handler {
         ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/src/format.cc:34:23: note: in instantiation of function template specialization 'fmt::detail::vformat_to<char>' requested here
template FMT_API void vformat_to(buffer<char>&, string_view,
                      ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1289:54: note: template is declared here
template <typename T, typename Enable = void> struct float_info;
                                                     ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1408:46: error: implicit instantiation of undefined template 'fmt::detail::dragonbox::float_info<long double>'
    using carrier_uint = typename dragonbox::float_info<Float>::carrier_uint;
                                             ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1401:63: note: in instantiation of function template specialization 'fmt::detail::basic_fp<unsigned long long>::assign<long double, 0>' requested here
  template <typename Float> FMT_CONSTEXPR basic_fp(Float n) { assign(n); }
                                                              ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3145:31: note: in instantiation of function template specialization 'fmt::detail::basic_fp<unsigned long long>::basic_fp<long double>' requested here
    fp normalized = normalize(fp(converted_value));
                              ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3230:13: note: in instantiation of function template specialization 'fmt::detail::format_float<long double>' requested here
  int exp = format_float(convert_float(value), precision, fspecs, buffer);
            ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3394:20: note: in instantiation of function template specialization 'fmt::detail::write<char, fmt::appender, long double, 0>' requested here
    return detail::write(out, value, specs, locale);
                   ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:4082:10: note: in instantiation of member function 'fmt::detail::vformat_to(buffer<char> &, basic_string_view<char>, basic_format_args<basic_format_context<detail::buffer_appender<type_identity_t<char>>, type_identity_t<char>>>, locale_ref)::format_handler::on_format_specs' requested here
  struct format_handler : error_handler {
         ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/src/format.cc:34:23: note: in instantiation of function template specialization 'fmt::detail::vformat_to<char>' requested here
template FMT_API void vformat_to(buffer<char>&, string_view,
                      ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1289:54: note: template is declared here
template <typename T, typename Enable = void> struct float_info;
                                                     ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1412:48: warning: overflow in expression; result is 2147483647 with type 'int' [-Winteger-overflow]
    const auto significand_mask = implicit_bit - 1;
                                               ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1413:14: error: no matching function for call to 'bit_cast'
    auto u = bit_cast<carrier_uint>(n);
             ^~~~~~~~~~~~~~~~~~~~~~
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:297:22: note: candidate template ignored: requirement 'sizeof(int) == sizeof(long double)' was not satisfied [with To = carrier_uint, From = long double]
FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {
                     ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:450:13: note: candidate template ignored: requirement 'sizeof(int) > sizeof(long double)' was not satisfied [with To = carrier_uint, From = long double]
inline auto bit_cast(const From& from) -> To {
            ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1415:43: error: no matching function for call to 'exponent_mask'
    auto biased_e = static_cast<int>((u & exponent_mask<Float>()) >>
                                          ^~~~~~~~~~~~~~~~~~~~
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1355:16: note: candidate template ignored: substitution failure [with Float = long double]: implicit instantiation of undefined template 'fmt::detail::dragonbox::float_info<long double>'
constexpr auto exponent_mask() ->
          ~~~~ ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1411:47: warning: shift count >= width of type [-Wshift-count-overflow]
    const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
                                              ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1408:46: error: implicit instantiation of undefined template 'fmt::detail::dragonbox::float_info<long double>'
    using carrier_uint = typename dragonbox::float_info<Float>::carrier_uint;
                                             ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3164:42: note: in instantiation of function template specialization 'fmt::detail::basic_fp<unsigned __int128>::assign<long double, 0>' requested here
                                     : f.assign(converted_value);
                                         ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3230:13: note: in instantiation of function template specialization 'fmt::detail::format_float<long double>' requested here
  int exp = format_float(convert_float(value), precision, fspecs, buffer);
            ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:3394:20: note: in instantiation of function template specialization 'fmt::detail::write<char, fmt::appender, long double, 0>' requested here
    return detail::write(out, value, specs, locale);
                   ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:4082:10: note: in instantiation of member function 'fmt::detail::vformat_to(buffer<char> &, basic_string_view<char>, basic_format_args<basic_format_context<detail::buffer_appender<type_identity_t<char>>, type_identity_t<char>>>, locale_ref)::format_handler::on_format_specs' requested here
  struct format_handler : error_handler {
         ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/src/format.cc:34:23: note: in instantiation of function template specialization 'fmt::detail::vformat_to<char>' requested here
template FMT_API void vformat_to(buffer<char>&, string_view,
                      ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1289:54: note: template is declared here
template <typename T, typename Enable = void> struct float_info;
                                                     ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1412:48: warning: overflow in expression; result is 2147483647 with type 'int' [-Winteger-overflow]
    const auto significand_mask = implicit_bit - 1;
                                               ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1413:14: error: no matching function for call to 'bit_cast'
    auto u = bit_cast<carrier_uint>(n);
             ^~~~~~~~~~~~~~~~~~~~~~
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:297:22: note: candidate template ignored: requirement 'sizeof(int) == sizeof(long double)' was not satisfied [with To = carrier_uint, From = long double]
FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {
                     ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:450:13: note: candidate template ignored: requirement 'sizeof(int) > sizeof(long double)' was not satisfied [with To = carrier_uint, From = long double]
inline auto bit_cast(const From& from) -> To {
            ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1415:43: error: no matching function for call to 'exponent_mask'
    auto biased_e = static_cast<int>((u & exponent_mask<Float>()) >>
                                          ^~~~~~~~~~~~~~~~~~~~
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1355:16: note: candidate template ignored: substitution failure [with Float = long double]: implicit instantiation of undefined template 'fmt::detail::dragonbox::float_info<long double>'
constexpr auto exponent_mask() ->
          ~~~~ ^
/home/gkt/Work/unoapi-dpcpp-examples/build/_deps/fmt-src/include/fmt/format.h:1411:47: warning: shift count >= width of type [-Wshift-count-overflow]
    const auto implicit_bit = carrier_uint(1) << num_float_significand_bits;
                                              ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings and 7 errors generated.
gmake[2]: *** [_deps/fmt-build/CMakeFiles/fmt.dir/build.make:76: _deps/fmt-build/CMakeFiles/fmt.dir/src/format.cc.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:372: _deps/fmt-build/CMakeFiles/fmt.dir/all] Error 2
gmake: *** [Makefile:156: all] Error 2
gkthiruvathukal commented 1 year ago

I neglected to mention that version 8.1.0 worked for me just fine. I was trying to upgrade to 9.1.0 and am seeing the above errors.

mfuntowicz commented 1 year ago

@gkthiruvathukal thanks for opening up this issue, I'm running into the exact same on my side 😁.

gkthiruvathukal commented 1 year ago

@mfuntowicz My pleasure! Thank you for following up. I need this to work for an online resource I am creating for OneAPI.

vitaut commented 1 year ago

What is the long double format on your platform?

gkthiruvathukal commented 1 year ago

@vitaut Are you looking for sizeof? Or are you asking something architectural in nature?

gkthiruvathukal commented 1 year ago

@vitaut Happy to run a minimum viable example to get whatever info you need.

vitaut commented 1 year ago

Either the documentation of the format (is it IEEE754 type and which one) or the output of the program from https://github.com/fmtlib/fmt/issues/3365#issuecomment-1484047187 which prints various numeric "limits".

gkthiruvathukal commented 1 year ago
$ dpcpp -o nlimits nlimits.cpp
icpx: warning: use of 'dpcpp' is deprecated and will be removed in a future release. Use 'icpx -fsycl' [-Wdeprecated]

# gkt @ linode5 in ~/Work/unoapi-dpcpp-examples on git:main x [22:43:05]
$ ./nlimits
e
1
size:16

1
1
0
0
1
1
1
1
0
1
1
1
0
64
18
21
2
-16381
-4931
16384
4932
0
0
vitaut commented 1 year ago

This looks like normal IEEE754 binary128 which is supported. Have you tried building on the latest commit (https://github.com/fmtlib/fmt/commit/c03938922344d90fa067a32ec54d553f61d877dd)?

mfuntowicz commented 1 year ago

Thanks @vitaut I confirm it works on my side with latest commit (c039389)

gkthiruvathukal commented 1 year ago

@vitaut Will there be be an updated release?

vitaut commented 1 year ago

Yes, we are working on a new release.