Skip to content

Commit

Permalink
Adds patch for nvcc error with using namespace std and fmt
Browse files Browse the repository at this point in the history
Bugfix adapted from Ryan Quinlan's solution

Co-Authored-By: Ryan Quinlan <[email protected]>
  • Loading branch information
kennyweiss and Ryan Quinlan committed Jan 24, 2023
1 parent c4024d4 commit 332f3d7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/thirdparty/axom/fmt/README
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ We also put fmt in the axom namespace to isolate it from other libraries that mi
* Add `} \` to `AXOM_FMT_END_NAMESPACE` in `fmt/core.h`
* Apply `src/thirdparty/axom/fmt/xl_printf.patch` -- bugfix for XL compiler
* Apply `src/thirdparty/axom/fmt/hipcc_long_double.patch` -- bugfix for dealing with `long double` type on EAS architecture with hip compiler
* Apply `src/thirdparty/axom/fmt/runtime_error.patch` -- workaround for dealing with `std::runtime_error` bug in nvcc
14 changes: 11 additions & 3 deletions src/thirdparty/axom/fmt/format-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ template <typename Char> AXOM_FMT_FUNC Char decimal_point_impl(locale_ref) {
AXOM_FMT_API AXOM_FMT_FUNC format_error::~format_error() noexcept = default;
#endif

AXOM_FMT_FUNC std::system_error vsystem_error(int error_code, string_view format_str,
// BEGIN AXOM BUGFIX
// NVCC's preprocessor converts 'std::error_code' to `class std::error_code'
// and then complains that `return class std::error_code' isn't valid!
using axom_fmt_system_error = std::system_error;

AXOM_FMT_FUNC axom_fmt_system_error vsystem_error(int error_code, string_view format_str,
format_args args) {
auto ec = std::error_code(error_code, std::generic_category());
return std::system_error(ec, vformat(format_str, args));
return axom_fmt_system_error(ec, vformat(format_str, args));
}
// END AXOM BUGFIX

namespace detail {

Expand Down Expand Up @@ -1449,16 +1455,18 @@ AXOM_FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) {
buffer_.push_back(0);
}

// BEGIN AXOM BUGFIX
AXOM_FMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,
const char* message) noexcept {
AXOM_FMT_TRY {
auto ec = std::error_code(error_code, std::generic_category());
write(std::back_inserter(out), std::system_error(ec, message).what());
write(std::back_inserter(out), axom_fmt_system_error(ec, message).what());
return;
}
AXOM_FMT_CATCH(...) {}
format_error_code(out, error_code, message);
}
// END AXOM BUGFIX

AXOM_FMT_FUNC void report_system_error(int error_code,
const char* message) noexcept {
Expand Down
44 changes: 44 additions & 0 deletions src/thirdparty/axom/fmt/runtime_error.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/src/thirdparty/axom/fmt/format-inl.h b/src/thirdparty/axom/fmt/format-inl.h
index ff6e6323f..efdbeb40a 100644
--- a/src/thirdparty/axom/fmt/format-inl.h
+++ b/src/thirdparty/axom/fmt/format-inl.h
@@ -121,11 +121,17 @@ template <typename Char> AXOM_FMT_FUNC Char decimal_point_impl(locale_ref) {
AXOM_FMT_API AXOM_FMT_FUNC format_error::~format_error() noexcept = default;
#endif

-AXOM_FMT_FUNC std::system_error vsystem_error(int error_code, string_view format_str,
+// BEGIN AXOM BUGFIX
+// NVCC's preprocessor converts 'std::error_code' to `class std::error_code'
+// and then complains that `return class std::error_code' isn't valid!
+using axom_fmt_system_error = std::system_error;
+
+AXOM_FMT_FUNC axom_fmt_system_error vsystem_error(int error_code, string_view format_str,
format_args args) {
auto ec = std::error_code(error_code, std::generic_category());
- return std::system_error(ec, vformat(format_str, args));
+ return axom_fmt_system_error(ec, vformat(format_str, args));
}
+// END AXOM BUGFIX

namespace detail {

@@ -1449,16 +1455,18 @@ AXOM_FMT_FUNC detail::utf8_to_utf16::utf8_to_utf16(string_view s) {
buffer_.push_back(0);
}

+// BEGIN AXOM BUGFIX
AXOM_FMT_FUNC void format_system_error(detail::buffer<char>& out, int error_code,
const char* message) noexcept {
AXOM_FMT_TRY {
auto ec = std::error_code(error_code, std::generic_category());
- write(std::back_inserter(out), std::system_error(ec, message).what());
+ write(std::back_inserter(out), axom_fmt_system_error(ec, message).what());
return;
}
AXOM_FMT_CATCH(...) {}
format_error_code(out, error_code, message);
}
+// END AXOM BUGFIX

AXOM_FMT_FUNC void report_system_error(int error_code,
const char* message) noexcept {

0 comments on commit 332f3d7

Please sign in to comment.