Open3D
Open3D copied to clipboard
Fix build compatibility with fmtlib 8
This PR updates the fmt::formatter specialization as documented in the fmtlib documentation for fmtlib >= 7, and fixes the build errors with fmtlib >= 8.
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.
@roehling could you also change to fmtlib 8 in 3rdparty/fmt/fmt.cmake
? This will make sure that fmtlib 8 is supported in other platforms as well.
I can update the PR after my vacation, which ends July 24th. Feel free to update it yourself if you'd like to merge earlier.
@roehling Is there a complete list of files of version 0.15.1 that would need modification to use FMT version >=8.0 ?
@roehling Is there a complete list of files of version 0.15.1 that would need modification to use FMT version >=8.0 ?
Not sure what you mean, all required changes are part of the pull request. The change to find_dependencies.cmake
would need some simple tweaking to account for the refactoring since the 0.15.1 release, but other than that, the PR should apply cleanly to the release, as well.
What about utility::LogError() ??
Given an example:
File Open3D/cpp/open3d/t/geometry/kernel/NPPImage.cpp
, around line 135~137:
if (it == type_dict.end()) {
utility::LogError("Invalid interpolation type {}.", interp_type);
}
its declaration is in Open3D/Open3D/cpp/open3d/utility/Logging.h
, around line 68:
// Usage : utility::LogError(format_string, arg0, arg1, ...);
// Example: utility::LogError("name: {}, age: {}", "dog", 5);
#define LogError(...) \
Logger::LogError_(__FILE__, __LINE__, \
static_cast<const char *>(OPEN3D_FUNCTION), __VA_ARGS__)
and its definition is aournd line 157~171, same file:
template <typename... Args>
static void LogError_ [[noreturn]] (const char *file,
int line,
const char *function,
const char *format,
Args &&... args) {
if (sizeof...(Args) > 0) {
Logger::GetInstance().VError(
file, line, function,
FormatArgs(format, fmt::make_format_args(args...)));
} else {
Logger::GetInstance().VError(file, line, function,
std::string(format));
}
}
I still failed to build through, with the following ERROR messages:
....../Open3D/cpp/open3d/t/geometry/kernel/NPPImage.cpp:136:18: required from here
/usr/local/include/fmt/core.h:1751:7: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt
1751 | formattable,
| ^~~~~~~~~~~
/usr/local/include/fmt/core.h:1751:7: note: ‘formattable’ evaluates to false
Hi @jiapei100 I cannot reproduce this. Please add your environment information and reference an issue if appropriate.
What about utility::LogError() ??
Given an example:
File
Open3D/cpp/open3d/t/geometry/kernel/NPPImage.cpp
, around line 135~137:if (it == type_dict.end()) { utility::LogError("Invalid interpolation type {}.", interp_type); }
its declaration is in
Open3D/Open3D/cpp/open3d/utility/Logging.h
, around line 68:// Usage : utility::LogError(format_string, arg0, arg1, ...); // Example: utility::LogError("name: {}, age: {}", "dog", 5); #define LogError(...) \ Logger::LogError_(__FILE__, __LINE__, \ static_cast<const char *>(OPEN3D_FUNCTION), __VA_ARGS__)
and its definition is aournd line 157~171, same file:
template <typename... Args> static void LogError_ [[noreturn]] (const char *file, int line, const char *function, const char *format, Args &&... args) { if (sizeof...(Args) > 0) { Logger::GetInstance().VError( file, line, function, FormatArgs(format, fmt::make_format_args(args...))); } else { Logger::GetInstance().VError(file, line, function, std::string(format)); } }
I still failed to build through, with the following ERROR messages:
....../Open3D/cpp/open3d/t/geometry/kernel/NPPImage.cpp:136:18: required from here /usr/local/include/fmt/core.h:1751:7: error: static assertion failed: Cannot format an argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#udt 1751 | formattable, | ^~~~~~~~~~~ /usr/local/include/fmt/core.h:1751:7: note: ‘formattable’ evaluates to false
Thank you @yxlao
Great, thanks Timo. I don’t have permission to update the PR, so will wait for you.
Regards, Sameer
From: Timo Röhling @.> Date: Tuesday, July 12, 2022 at 11:46 PM To: isl-org/Open3D @.> Cc: Sheorey, Sameer @.>, Review requested @.> Subject: Re: [isl-org/Open3D] Fix build compatibility with fmtlib >= 8 (PR #5303)
I can update the PR after my vacation, which ends July 24th. Feel free to update it yourself if you'd like to merge earlier.
— Reply to this email directly, view it on GitHubhttps://github.com/isl-org/Open3D/pull/5303#issuecomment-1182830454, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJZAVYFGDQGRDJKAZFEJFNTVTZQZHANCNFSM53IK7ROQ. You are receiving this because your review was requested.Message ID: @.***>
Hey @ssheorey / @roehling, what's the ETA about this PR getting merged ? Is there anything I can do, to help ?
Hi @roehling can you update the PR with master and look at the CI errors (pushing an update will rerun CI)? I will be happy to fix the CI errors and merge if you allow upstream maintainers to push to your branch.
Hi @roehling can you take a look at the Windows CI errors?
@roehling could you check -DUSE_SYSTEM_FMT=ON configuration? I do see build error when libfmt being shared library. cf https://github.com/isl-org/Open3D/pull/5622#issuecomment-1416768697
Closing in favor of adopted PR #5892.