Skip to content

[Build] Error building ArrayFire with fmt 11.2.0 #3692

Description

@nots1dd

Note

This is similar to #3596 in nature.

Description

ArrayFire is failing to compile with fmt 11.2.0 (in ArrayFireTypesIO.hpp).

It seems to be a mismatch between ArrayFire’s custom fmt::formatter specialization and the version of fmt on arch (which is 11)

Something to note as well, if I just add const to the format functions I will get this error:

[ 1%] Building CXX object third_party/arrayfire/src/backend/cpu/CMakeFiles/afcpu.dir/ __/common/DependencyModule.cpp.o 
In file included from /home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/co mmon/DependencyModule.cpp:10: 
/home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/common/ArrayFireTypesIO. hpp: 
In member function ‘decltype (ctx.out()) fmt::v11::formatter<arrayfire::common::V ersion>::format(const arrayfire::common::Version&, FormatContext&) const’: 
/home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/common/ArrayFireTypesIO. hpp:80:43: 
error: assignment of member ‘fmt::v11::formatter<arrayfire::common::Version >::show_minor’ in read-only object [-Wtemplate-body] 80 | if (ver.minor() == -1) show_minor = false; | ~~~~~~~~~~~^~~~~~~ 
/home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/common/ArrayFireTypesIO. hpp:81:43: 
error: assignment of member ‘fmt::v11::formatter<arrayfire::common::Version >::show_patch’ in read-only object [-Wtemplate-body] 81 | if (ver.patch() == -1) show_patch = false; | ~~~~~~~~~~~^~~~~~~ 
At global scope: 
cc1plus: note: unrecognized command-line option ‘-Wno-unqualified-std-cast-call’ may h ave been intended to silence earlier diagnostics

There is a fix I have in mind to have it work for older (9<) and newer fmt versions (like 11).

Error Log

In file included from /usr/include/fmt/format.h:41,
                 from /usr/include/fmt/chrono.h:23,
                 from /usr/include/fmt/ostream.h:23,
                 from /usr/include/spdlog/fmt/ostr.h:21,
                 from /home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/co
mmon/ArrayFireTypesIO.hpp:12,
                 from /home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/co
mmon/DependencyModule.cpp:10:
/usr/include/fmt/base.h: In instantiation of ‘static void fmt::v11::detail::value<Cont
ext>::format_custom(void*, fmt::v11::parse_context<typename Context::char_type>&, Cont
ext&) [with T = arrayfire::common::Version; Formatter = fmt::v11::formatter<arrayfire:
:common::Version>; Context = fmt::v11::context; typename Context::char_type = char]’:
/usr/include/fmt/base.h:2255:19:   required from ‘constexpr fmt::v11::detail::value<Co
ntext>::value(T&, fmt::v11::detail::custom_tag) [with T = arrayfire::common::Version; 
typename std::enable_if<has_formatter<T, typename Context::char_type>(), int>::type <a
nonymous> = 0; Context = fmt::v11::context]’
 2255 |     custom.format = format_custom<value_type, formatter<value_type, char_type>
>;
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~
/usr/include/fmt/base.h:2235:65:   required from ‘fmt::v11::detail::value<Context>::va
lue(T&) [with T = arrayfire::common::Version; typename std::enable_if<(std::integral_c
onstant<bool, (((((((std::is_class<T>::value || std::is_enum<T>::value) || std::is_uni
on<T>::value) || std::is_array<T>::value) && (! fmt::v11::detail::has_to_string_view<T
, void>::value)) && (! fmt::v11::detail::is_named_arg<T>::value)) && (! fmt::v11::deta
il::use_format_as<T>::value)) && (! fmt::v11::detail::use_format_as_member<typename st
d::remove_const<T>::type, std::integral_constant<bool, true> >::value))>::value || (!1
)), int>::type <anonymous> = 0; Context = fmt::v11::context]’
 2235 |   FMT_CONSTEXPR20 FMT_INLINE value(T& x) : value(x, custom_tag()) {}
      |                                                                 ^
/usr/include/fmt/base.h:2808:20:   required from ‘constexpr fmt::v11::detail::format_a
rg_store<Context, NUM_ARGS, NUM_NAMED_ARGS, DESC> fmt::v11::make_format_args(T& ...) [
with Context = context; T = {std::__cxx11::basic_string<char, std::char_traits<char>, 
std::allocator<char> >, arrayfire::common::Version}; int NUM_ARGS = 2; int NUM_NAMED_A
RGS = 0; long long unsigned int DESC = 253]’
 2808 |   return {{args...}};
      |                    ^
/usr/include/spdlog/logger.h:328:75:   required from ‘void spdlog::logger::log_(spdlog
::source_loc, spdlog::level::level_enum, spdlog::string_view_t, Args&& ...) [with Args
 = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, 
arrayfire::common::Version&}; spdlog::string_view_t = fmt::v11::basic_string_view<char
>]’
  328 |     fmt::vformat_to(fmt::appender(buf), fmt, fmt::make_format_args(args...));
      |                                              ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/spdlog/logger.h:80:13:   required from ‘void spdlog::logger::log(spdlog::
source_loc, spdlog::level::level_enum, fmt::v11::format_string<T ...>, Args&& ...) [wi
th Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<cha
r> >&, arrayfire::common::Version&}; fmt::v11::format_string<T ...> = fmt::v11::fstrin
g<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, ar
rayfire::common::Version&>]’
   80 |         log_(loc, lvl, details::to_string_view(fmt), std::forward<Args>(args).
..);
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
/usr/include/spdlog/logger.h:85:12:   required from ‘void spdlog::logger::log(spdlog::
level::level_enum, fmt::v11::format_string<T ...>, Args&& ...) [with Args = {std::__cx
x11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, arrayfire::co
mmon::Version&}; fmt::v11::format_string<T ...> = fmt::v11::fstring<std::__cxx11::basi
c_string<char, std::char_traits<char>, std::allocator<char> >&, arrayfire::common::Ver
sion&>]’
   85 |         log(source_loc{}, lvl, fmt, std::forward<Args>(args)...);
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/spdlog/logger.h:130:12:   required from ‘void spdlog::logger::trace(fmt::
v11::format_string<T ...>, Args&& ...) [with Args = {std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> >&, arrayfire::common::Version&}; fmt::v1
1::format_string<T ...> = fmt::v11::fstring<std::__cxx11::basic_string<char, std::char
_traits<char>, std::allocator<char> >&, arrayfire::common::Version&>]’
  130 |         log(level::trace, fmt, std::forward<Args>(args)...);
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/common/DependencyModule.
cpp:137:33:   required from here
   67 |     getLogger()->trace("[ " __FILE__ \
      |     ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
   68 |                        ":" AF_STR_HELPER(__LINE__) " ] " __VA_ARGS__)
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/fmt/base.h:2275:29: error: passing ‘const fmt::v11::formatter<arrayfire::
common::Version>’ as ‘this’ argument discards qualifiers [-fpermissive]
 2275 |     ctx.advance_to(cf.format(*static_cast<qualified_type*>(arg), ctx));
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/s1dd/dev/rcai/cppgrad/third_party/arrayfire/src/backend/common/ArrayFireTypesIO.
hpp:76:10: note:   in call to ‘decltype (ctx.out()) fmt::v11::formatter<arrayfire::com
mon::Version>::format(const arrayfire::common::Version&, FormatContext&) [with FormatC
ontext = fmt::v11::context; decltype (ctx.out()) = fmt::v11::basic_appender<char>]’
   76 |     auto format(const arrayfire::common::Version& ver, FormatContext& ctx)
      |          ^~~~~~
cc1plus: note: unrecognized command-line option ‘-Wno-unqualified-std-cast-call’ may h
ave been intended to silence earlier diagnostics
make[2]: *** [third_party/arrayfire/src/backend/cpu/CMakeFiles/afcpu.dir/build.make:39
29: third_party/arrayfire/src/backend/cpu/CMakeFiles/afcpu.dir/__/common/DependencyMod
ule.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2791: third_party/arrayfire/src/backend/cpu/CMakeFi
les/afcpu.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Build Environment

Compiler version: gcc version 15.2.1 20250813 (GCC)
Operating system: Arch Linux (kernel: 6.16.1-zen1-1-zen)
Build environment: fmt 11.2.0, ArrayFire at commit hash (a699cb9)
CMake variables:

AF_BACKEND:STRING=cpu
AF_BUILD_CPU:BOOL=ON
AF_BUILD_CUDA:BOOL=OFF
AF_BUILD_DOCS:BOOL=ON
AF_BUILD_EXAMPLES:BOOL=ON
AF_BUILD_FORGE:BOOL=OFF
AF_BUILD_ONEAPI:BOOL=OFF
AF_BUILD_OPENCL:BOOL=OFF
AF_BUILD_UNIFIED:BOOL=ON
AF_COMPUTE_LIBRARY:STRING=FFTW/LAPACK/BLAS
AF_CTEST_SEPARATED:BOOL=OFF
AF_SKIP_UNSUPPORTED_TESTS:BOOL=OFF
AF_STACKTRACE_TYPE:STRING=Basic
AF_WITH_CUDNN:BOOL=OFF
AF_WITH_EXTERNAL_PACKAGES_ONLY:BOOL=OFF
AF_WITH_FAST_MATH:BOOL=OFF
AF_WITH_FMT_HEADER_ONLY:BOOL=OFF
AF_WITH_SPDLOG_HEADER_ONLY:BOOL=OFF
AF_WITH_STATIC_CUDA_NUMERIC_LIBS:BOOL=OFF
BENCHMARK_BUILD_32_BITS:BOOL=OFF
BENCHMARK_DOWNLOAD_DEPENDENCIES:BOOL=OFF
BENCHMARK_ENABLE_ASSEMBLY_TESTS:BOOL=ON
BENCHMARK_ENABLE_DOXYGEN:BOOL=OFF
BENCHMARK_ENABLE_EXCEPTIONS:BOOL=ON
BENCHMARK_ENABLE_GTEST_TESTS:BOOL=ON
BENCHMARK_ENABLE_LIBPFM:BOOL=OFF
BENCHMARK_ENABLE_LTO:BOOL=OFF
BENCHMARK_ENABLE_WERROR:BOOL=ON
BENCHMARK_FORCE_WERROR:BOOL=OFF
BENCHMARK_INSTALL_DOCS:BOOL=ON
BENCHMARK_USE_BUNDLED_GTEST:BOOL=ON
BENCHMARK_USE_LIBCXX:BOOL=OFF
BUILD_TESTING:BOOL=ON
CATCH_DEVELOPMENT_BUILD:BOOL=OFF
CATCH_ENABLE_REPRODUCIBLE_BUILD:BOOL=ON
CATCH_INSTALL_DOCS:BOOL=ON
CATCH_INSTALL_EXTRAS:BOOL=ON
CLBlast_DIR:PATH=CLBlast_DIR-NOTFOUND
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_INSTALL_PREFIX:PATH=/usr/local
CXXFEATURECHECK_DEBUG:BOOL=OFF
FETCHCONTENT_UPDATES_DISCONNECTED_SPAN-LITE:BOOL=OFF
GTest_DIR:PATH=/lib/cmake/GTest
LLVM_FILECHECK_EXE:PATH=/sbin/FileCheck
MKL_Core_LINK_LIBRARY:FILEPATH=MKL_Core_LINK_LIBRARY-NOTFOUND
MKL_DIR:PATH=MKL_DIR-NOTFOUND
MKL_FFTW_INCLUDE_DIR:PATH=MKL_FFTW_INCLUDE_DIR-NOTFOUND
MKL_INCLUDE_DIR:PATH=MKL_INCLUDE_DIR-NOTFOUND
MKL_Interface_LINK_LIBRARY:FILEPATH=MKL_Interface_LINK_LIBRARY-NOTFOUND
MKL_RT_LINK_LIBRARY:FILEPATH=MKL_RT_LINK_LIBRARY-NOTFOUND
MKL_THREAD_LAYER:STRING=Intel OpenMP
MKL_ThreadLayer_LINK_LIBRARY:FILEPATH=MKL_ThreadLayer_LINK_LIBRARY-NOTFOUND
MKL_ThreadingLibrary_LINK_LIBRARY:FILEPATH=MKL_ThreadingLibrary_LINK_LIBRARY-NOTFOUND
MKL_mkl_avx2_LINK_LIBRARY:FILEPATH=MKL_mkl_avx2_LINK_LIBRARY-NOTFOUND
MKL_mkl_avx512_LINK_LIBRARY:FILEPATH=MKL_mkl_avx512_LINK_LIBRARY-NOTFOUND
MKL_mkl_avx_LINK_LIBRARY:FILEPATH=MKL_mkl_avx_LINK_LIBRARY-NOTFOUND
MKL_mkl_def_LINK_LIBRARY:FILEPATH=MKL_mkl_def_LINK_LIBRARY-NOTFOUND
MKL_mkl_mc3_LINK_LIBRARY:FILEPATH=MKL_mkl_mc3_LINK_LIBRARY-NOTFOUND
MKL_mkl_mc_LINK_LIBRARY:FILEPATH=MKL_mkl_mc_LINK_LIBRARY-NOTFOUND
USE_PREBUILT_ARRAYFIRE:BOOL=OFF

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions