FreeBSD Bugzilla – Attachment 253608 Details for
Bug 281540
devel/sfml: fix build with libc++ 19
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
devel/sfml: fix build with libc++ 19
devel__sfml-fix-libcxx19-build-1.diff (text/plain), 5.12 KB, created by
Dimitry Andric
on 2024-09-16 18:01:34 UTC
(
hide
)
Description:
devel/sfml: fix build with libc++ 19
Filename:
MIME Type:
Creator:
Dimitry Andric
Created:
2024-09-16 18:01:34 UTC
Size:
5.12 KB
patch
obsolete
>commit 7ac22560c029dbf6e7cc5c21d3bba27ff2a1eb3f >Author: Dimitry Andric <dim@FreeBSD.org> >Date: 2024-09-16T20:00:40+02:00 > > devel/sfml: fix build with libc++ 19 > > As noted in the libc++ 19 release notes [1], std::char_traits<> is now > only provided for char, char8_t, char16_t, char32_t and wchar_t, and any > instantiation for other types will fail. > > This causes devel/sfml to fail to compile with clang 19 and libc++ 19, > resulting in errors similar to: > > /usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned int>' > 820 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, > | ^ > /wrkdirs/usr/ports/devel/sfml/work/SFML-2.6.1/include/SFML/System/String.hpp:52:18: note: in instantiation of template class 'std::basic_string<unsigned int>' requested here > 52 | typedef std::basic_string<Uint32>::iterator Iterator; //!< Iterator type > | ^ > /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here > 23 | struct _LIBCPP_TEMPLATE_VIS char_traits; > | ^ > > SFML makes heavy use of the no-longer-existing basic_string variants, so > I had to add a rudimentary set of char_traits classes, for unsigned > char, unsigned short and unsigned int, otherwise this would not compile. > > [1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals > > PR: 281540 > MFH: 2024Q3 > >diff --git a/devel/sfml/files/patch-include_SFML_System_String.hpp b/devel/sfml/files/patch-include_SFML_System_String.hpp >new file mode 100644 >index 000000000000..7764d885314a >--- /dev/null >+++ b/devel/sfml/files/patch-include_SFML_System_String.hpp >@@ -0,0 +1,132 @@ >+--- include/SFML/System/String.hpp.orig 2023-10-30 00:03:26 UTC >++++ include/SFML/System/String.hpp >+@@ -34,6 +34,129 @@ >+ #include <locale> >+ #include <string> >+ >++namespace std >++{ >++ >++namespace // anonymous >++{ >++ >++template<class CharType, class IntType, IntType EOFVal> >++struct char_traits_base >++{ >++ using char_type = CharType; >++ using int_type = IntType; >++ using off_type = streamoff; >++ using pos_type = fpos<mbstate_t>; >++ using state_type = mbstate_t; >++ >++ static inline constexpr void assign(char_type& c1, const char_type& c2) noexcept >++ { >++ c1 = c2; >++ } >++ >++ static inline constexpr bool eq(char_type c1, char_type c2) noexcept >++ { >++ return c1 == c2; >++ } >++ >++ static inline constexpr bool lt(char_type c1, char_type c2) noexcept >++ { >++ return c1 < c2; >++ } >++ >++ static constexpr int compare(const char_type* lhs, const char_type* rhs, size_t count) noexcept >++ { >++ for (; count; --count, ++lhs, ++rhs) >++ { >++ if (lt(*lhs, *rhs)) >++ return -1; >++ if (lt(*rhs, *lhs)) >++ return 1; >++ } >++ return 0; >++ } >++ >++ static inline size_t constexpr length(const char_type* s) noexcept >++ { >++ size_t i = 0; >++ for (; s[i] != '\0'; ++i) >++ { >++ } >++ return i; >++ } >++ >++ static constexpr const char_type* find(const char_type* s, size_t n, const char_type& a) noexcept >++ { >++ for (; n; --n) >++ { >++ if (*s == a) >++ return s; >++ ++s; >++ } >++ return nullptr; >++ } >++ >++ static inline char_type* move(char_type* s1, const char_type* s2, size_t n) noexcept >++ { >++ return reinterpret_cast<char_type*>(__builtin_memmove(s1, s2, n * sizeof(char_type))); >++ } >++ >++ static inline char_type* copy(char_type* s1, const char_type* s2, size_t n) noexcept >++ { >++ __builtin_memmove(s1, s2, n * sizeof(char_type)); >++ return s1; >++ } >++ >++ static inline char_type* assign(char_type* s, size_t n, char_type a) noexcept >++ { >++ std::fill_n(s, n, a); >++ return s; >++ } >++ >++ static inline constexpr int_type not_eof(int_type c) noexcept >++ { >++ return eq_int_type(c, eof()) ? ~eof() : c; >++ } >++ >++ static inline constexpr char_type to_char_type(int_type c) noexcept >++ { >++ return char_type(c); >++ } >++ >++ static inline constexpr int_type to_int_type(char_type c) noexcept >++ { >++ return int_type(c); >++ } >++ >++ static inline constexpr bool eq_int_type(int_type c1, int_type c2) noexcept >++ { >++ return c1 == c2; >++ } >++ >++ static inline constexpr int_type eof() noexcept >++ { >++ return int_type(EOF); >++ } >++}; >++ >++} // namespace anonymous >++ >++template<> >++struct char_traits<unsigned char> : char_traits_base<unsigned char, unsigned int, static_cast<unsigned int>(EOF)> >++{ >++}; >++ >++template<> >++struct char_traits<unsigned short> : char_traits_base<unsigned short, unsigned int, static_cast<unsigned int>(0xFFFF)> >++{ >++}; >++ >++template<> >++struct char_traits<unsigned int> : char_traits_base<unsigned int, unsigned int, static_cast<unsigned int>(0xFFFFFFFF)> >++{ >++}; >++ >++} // namespace std >+ >+ namespace sf >+ {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 281540
: 253608