tt-metal: [Bug Report] `fmt::print` logger fails to compile during runtime under C++20

Describe the bug Metalium applications fails to compile with GCC 13.2.1 under C++20 mode. This is due to libfmt enabling constexpr check when C++20 is detected.

I’ve attached an one line fix. Can we just merge it?

To Reproduce Steps to reproduce the behavior:

  1. Build metalium as usual
  2. Clone my vector addition example git clone https://github.com/marty1885/ttVecAdd
  3. Set C++ mode to C++20 (edit CMakeLists.txt, make is say set(CMAKE_CXX_STANDARD 20)
  4. Compile and see the error
In file included from /home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:15,
                 from /home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/core_coord.h:14:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {long unsigned int}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:216:33:   required from ‘void tt::log_info(LogType, const char*, Args&& ...) [with Args = {long unsigned int}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/bfloat16.hpp:123:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, long unsigned int>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
  123 |             fmt::print(*fd, fmt, std::forward<Args>(args)...);
      |             ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {long unsigned int, float&, unsigned int&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:216:33:   required from ‘void tt::log_info(LogType, const char*, Args&& ...) [with Args = {long unsigned int, float&, unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/bfloat16.hpp:199:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, long unsigned int, float&, unsigned int&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {int&, int&, long unsigned int}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:216:33:   required from ‘void tt::log_info(LogType, const char*, Args&& ...) [with Args = {int&, int&, long unsigned int}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/bfloat16.hpp:212:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, int&, int&, long unsigned int>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {char [42], std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/core_coord.h:80:9:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, const std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {const char*}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/core_coord.h:245:15:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {const unsigned int&, const unsigned int&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {const unsigned int&, const unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {const unsigned int&, const unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {unsigned int, unsigned int}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {char [93], unsigned int, unsigned int}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/impl/buffers/circular_buffer_types.hpp:40:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, const unsigned int&, const unsigned int&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {const unsigned char&, const unsigned int&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {const unsigned char&, const unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {const unsigned char&, const unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {unsigned char, unsigned int}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {char [71], unsigned char, unsigned int}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/impl/buffers/circular_buffer_types.hpp:51:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, const unsigned char&, const unsigned int&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {const unsigned char&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {const unsigned char&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {const unsigned char&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {unsigned char}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {char [119], unsigned char}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/impl/buffers/circular_buffer_types.hpp:57:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, const unsigned char&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {const unsigned int&, const long unsigned int&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {const unsigned int&, const long unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {const unsigned int&, const long unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {unsigned int, long unsigned int}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {char [90], unsigned int, long unsigned int}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/impl/buffers/circular_buffer_types.hpp:115:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, const unsigned int&, const long unsigned int&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {const unsigned int&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {const unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {const unsigned int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {unsigned int}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {char [66], unsigned int}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/core_descriptor.hpp:86:9:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, const unsigned int&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp: In instantiation of ‘void tt::Logger::log_level_type(Level, tt::LogType, const char*, Args&& ...) [with Args = {const int&}]’:
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:246:33:   required from ‘void tt::log_fatal(LogType, const char*, Args&& ...) [with Args = {const int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:251:14:   required from ‘void tt::log_fatal(const char*, Args&& ...) [with Args = {const int&}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:118:14:   required from ‘void tt::assert::tt_assert_log_message(const char*, const Ts& ...) [with Ts = {int}]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/assert.hpp:133:30:   required from ‘void tt::assert::tt_throw(const char*, int, const std::string&, const char*, const Ts& ...) [with Ts = {char [46], int}; std::string = std::__cxx11::basic_string<char>]’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/impl/dispatch/dispatch_core_manager.hpp:162:13:   required from here
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23:   in ‘constexpr’ expansion of ‘fmt::v10::basic_format_string<char, const int&>(fmt)’
/home/marty/Documents/not-my-projects/tt-metal/tt_metal/common/logger.hpp:123:23: error: ‘fmt’ is not a constant expression
make[2]: *** [CMakeFiles/ttvecadd.dir/build.make:76: CMakeFiles/ttvecadd.dir/ttvecadd.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/ttvecadd.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

Expected behavior It should compile normally.

Screenshots If applicable, add screenshots to help explain your problem.

Please complete the following environment information:

  • OS: Arch Linux
  • Commit: 5e0d2b8b94670710701fed556bf07f900b454ac7
  • Compiler GCC 13.2.1

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@marty1885 We are currently in the middle of upgrading our C++ version to C++20. We will also use a much newer version of Clang (17 or higher) for compilation.

Please continue using what’s in main branch for now. We will update this issue once this is done: https://github.com/tenstorrent/tt-metal/pull/9070/files

It compiles for me. Let me install an Ubuntu installation and see what happens