Bug 281516 - graphics/libemf: fix build with libc++ 19
Summary: graphics/libemf: fix build with libc++ 19
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: FreeBSD Office Team
URL:
Keywords:
Depends on:
Blocks: 280562
  Show dependency treegraph
 
Reported: 2024-09-15 11:54 UTC by Dimitry Andric
Modified: 2024-09-28 10:04 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (office)


Attachments
graphics/libemf: fix build with libc++ 19 (2.57 KB, patch)
2024-09-15 11:55 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer freebsd_triage 2024-09-15 11:54:30 UTC
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 graphics/libemf 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 short>'
    820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
        |                                          ^
  libemf.cpp:982:30: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
    982 |     std::basic_string<WCHAR> filename_w( filename, filename + filename_count );
        |                              ^
  /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
     23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
        |                             ^

libemf should really use char16_t for its 16-bit character type, but the
code is full of Windows assumptions that WCHAR is unsigned short. Since
std::basic_string<unsigned short> is no longer available, use
std::basic_string<char16_t> instead, and cast the result to the
appropriate type for GetEnhMetaFileW().

[1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2024-09-15 11:55:54 UTC
Created attachment 253581 [details]
graphics/libemf: fix build with libc++ 19
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-09-28 09:56:23 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2b65317363f625eceb125cad5864fd873a66562f

commit 2b65317363f625eceb125cad5864fd873a66562f
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-09-15 11:55:03 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-09-28 09:53:51 +0000

    graphics/libemf: 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 graphics/libemf 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 short>'
        820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
            |                                          ^
      libemf.cpp:982:30: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
        982 |     std::basic_string<WCHAR> filename_w( filename, filename + filename_count );
            |                              ^
      /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
         23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
            |                             ^

    libemf should really use char16_t for its 16-bit character type, but the
    code is full of Windows assumptions that WCHAR is unsigned short. Since
    std::basic_string<unsigned short> is no longer available, use
    std::basic_string<char16_t> instead, and cast the result to the
    appropriate type for GetEnhMetaFileW().

    [1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals

    PR:             281516
    Approved by:    maintainer timeout (~2 weeks)
    MFH:            2024Q3

 graphics/libemf/files/patch-libemf_libemf.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-09-28 10:02:24 UTC
A commit in branch 2024Q3 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5b9dda30c763cfaf81e0abcdeee4f6b2ac02ff45

commit 5b9dda30c763cfaf81e0abcdeee4f6b2ac02ff45
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-09-15 11:55:03 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-09-28 10:01:20 +0000

    graphics/libemf: 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 graphics/libemf 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 short>'
        820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
            |                                          ^
      libemf.cpp:982:30: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
        982 |     std::basic_string<WCHAR> filename_w( filename, filename + filename_count );
            |                              ^
      /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
         23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
            |                             ^

    libemf should really use char16_t for its 16-bit character type, but the
    code is full of Windows assumptions that WCHAR is unsigned short. Since
    std::basic_string<unsigned short> is no longer available, use
    std::basic_string<char16_t> instead, and cast the result to the
    appropriate type for GetEnhMetaFileW().

    [1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals

    PR:             281516
    Approved by:    maintainer timeout (~2 weeks)
    MFH:            2024Q3

    (cherry picked from commit 2b65317363f625eceb125cad5864fd873a66562f)

 graphics/libemf/files/patch-libemf_libemf.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)