Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve reappearing compilation issue on PPC machines with NVCC due to FMT bug #2759

Merged
merged 9 commits into from
Oct 26, 2023
19 changes: 19 additions & 0 deletions src/coreComponents/common/Format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,23 @@ struct fmt::formatter< T, std::enable_if_t< std::is_enum< T >::value > >
*/
#define GEOS_FMT_TO( iter, size, msg, ... ) *GEOS_FMT_NS::format_to_n( iter, size - 1, msg, __VA_ARGS__ ).out = '\0'

// The following workaround is needed to fix compilation with NVCC on some PowerPC machines.
// The issue causes the following assertion error message:
// "Cannot format an argument. To make type T formattable provide a formatter<T> specialization"
// The standard definition of the has_const_formatter check of fmt fails due to a compiler bug, see the issue below:
// https://github.com/fmtlib/fmt/issues/2746
// The workaround was originally implemented in fmt:
// https://github.com/fmtlib/fmt/commit/70de324aa801eaf52e94c402d526a3849797c620
// but later removed:
// https://github.com/fmtlib/fmt/commit/466e0650ec2d153d255a40ec230eb77d7f1c3334
// This workaround bypasse the check for a const formatter whenever the foramt context GEOS_FMT_NS::format_context is used
#ifdef GEOS_USE_FMT_CONST_FORMATTER_WORKAROUND
template< >
constexpr auto GEOS_FMT_NS::detail::has_const_formatter_impl< GEOS_FMT_NS::format_context >( ... ) -> bool
{
return true;
}
#endif
// End of the workaround for fmt compilation issues

#endif //GEOS_COMMON_FORMAT_HPP_
22 changes: 0 additions & 22 deletions src/coreComponents/dataRepository/DataContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,26 +223,4 @@ struct GEOS_FMT_NS::formatter< geos::dataRepository::DataContext > : GEOS_FMT_NS
}
};

// The following workaround is needed to fix compilation with NVCC on some PowerPC machines.
// The issue causes the following assertion error message:
// "Cannot format an argument. To make type T formattable provide a formatter<T> specialization"
// The standard definition of the has_const_formatter check of fmt fails due to a compiler bug, see the issue below:
// https://github.com/fmtlib/fmt/issues/2746
// The workaround was originally implemented in fmt:
// https://github.com/fmtlib/fmt/commit/70de324aa801eaf52e94c402d526a3849797c620
// but later removed:
// https://github.com/fmtlib/fmt/commit/466e0650ec2d153d255a40ec230eb77d7f1c3334
// This workaround provides a specialization of the const formatter check for the DataContext object.
// The formatter is defined within this file, and therefore the check is not needed.
// The scope of the check override is as small as possible to solve the current issue.
#ifdef GEOS_USE_FMT_CONST_FORMATTER_WORKAROUND
template<>
constexpr auto GEOS_FMT_NS::detail::has_const_formatter< geos::dataRepository::DataContext, GEOS_FMT_NS::format_context >() -> bool
{
return true;
}
#endif
// End of the workaround for fmt compilation issues


#endif /* GEOS_DATAREPOSITORY_DATACONTEXT_HPP_ */