Skip to content

Fix build on latest AppleClang#629

Merged
hcho3 merged 2 commits intodmlc:release_4.5from
hcho3:macos_patch
Oct 9, 2025
Merged

Fix build on latest AppleClang#629
hcho3 merged 2 commits intodmlc:release_4.5from
hcho3:macos_patch

Conversation

@hcho3
Copy link
Collaborator

@hcho3 hcho3 commented Oct 9, 2025

Currently, the UBJSON parser in Treelite uses std::basic_string_view<std::uint8_t>, and it fails to compile on latest MacOS.

From the release note of XCode 16.3:

The base template for std::char_traits has been removed. If you are using std::char_traits with types other than char, wchar_t, char8_t, char16_t, char32_t or a custom character type for which you specialized std::char_traits, your code will stop working. The Standard does not mandate that a base template is provided, and such a base template is bound to be incorrect for some types, which could previously cause unexpected behavior while going undetected.

Example error:

In file included from $SRC_DIR/src/c_api/model_loader.cc:10:
In file included from $BUILD_PREFIX/bin/../include/c++/v1/string:647:
$BUILD_PREFIX/bin/../include/c++/v1/string_view:300:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>'
  300 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
      |                                          ^
$SRC_DIR/src/c_api/model_loader.cc:85:7: note: in instantiation of template class 'std::basic_string_view<unsigned char>' requested here
   85 |       std::basic_string_view<std::uint8_t>{ubjson_str, length}, config_json);
      |       ^

Fix. Use char to represent bytes in the UBJSON string.

@codecov
Copy link

codecov bot commented Oct 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.78%. Comparing base (c106644) to head (55659f3).
⚠️ Report is 1 commits behind head on release_4.5.

Additional details and impacted files
@@             Coverage Diff              @@
##           release_4.5     #629   +/-   ##
============================================
  Coverage        84.78%   84.78%           
============================================
  Files               77       77           
  Lines             6756     6756           
  Branches           531      531           
============================================
  Hits              5728     5728           
  Misses            1028     1028           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hcho3 hcho3 merged commit 9e92827 into dmlc:release_4.5 Oct 9, 2025
20 checks passed
@hcho3 hcho3 deleted the macos_patch branch October 9, 2025 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant