Open3D icon indicating copy to clipboard operation
Open3D copied to clipboard

Fix build compatibility with fmtlib 8

Open roehling opened this issue 2 years ago • 8 comments

This PR updates the fmt::formatter specialization as documented in the fmtlib documentation for fmtlib >= 7, and fixes the build errors with fmtlib >= 8.


This change is Reviewable

roehling avatar Jul 11 '22 18:07 roehling

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

update-docs[bot] avatar Jul 11 '22 18:07 update-docs[bot]

@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.

yxlao avatar Jul 12 '22 21:07 yxlao

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 avatar Jul 13 '22 06:07 roehling

@roehling Is there a complete list of files of version 0.15.1 that would need modification to use FMT version >=8.0 ?

nkapgate avatar Jul 18 '22 14:07 nkapgate

@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.

roehling avatar Jul 18 '22 16:07 roehling

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

jiapei100 avatar Jul 24 '22 00:07 jiapei100

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

ssheorey avatar Jul 26 '22 00:07 ssheorey

Thank you @yxlao

roehling avatar Aug 04 '22 13:08 roehling

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: @.***>

ssheorey avatar Oct 11 '22 09:10 ssheorey

Hey @ssheorey / @roehling, what's the ETA about this PR getting merged ? Is there anything I can do, to help ?

NokiDev avatar Jan 18 '23 16:01 NokiDev

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.

ssheorey avatar Jan 18 '23 18:01 ssheorey

Hi @roehling can you take a look at the Windows CI errors?

ssheorey avatar Jan 27 '23 00:01 ssheorey

@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

cielavenir avatar Feb 04 '23 15:02 cielavenir

Closing in favor of adopted PR #5892.

ssheorey avatar Feb 11 '23 01:02 ssheorey