Bug 281886 - cad/kicad: fix build with libc++ 19
Summary: cad/kicad: 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: Christoph Moench-Tegeder
URL:
Keywords:
Depends on:
Blocks: 280562
  Show dependency treegraph
 
Reported: 2024-10-06 08:58 UTC by Dimitry Andric
Modified: 2024-10-07 20:58 UTC (History)
0 users

See Also:
cmt: maintainer-feedback+


Attachments
cad/kicad: fix build with libc++ 19 (6.65 KB, patch)
2024-10-06 08:59 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-10-06 08:58:10 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 cad/kicad to fail to compile with clang 19 and libc++ 19,
resulting in errors similar to:

  /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:261:25: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
    261 |     auto const n = std::char_traits<NANODBC_SQLCHAR>::length(array);
        |                         ^
  /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
     45 | struct char_traits;
        |        ^
  /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3576:52: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
   3576 |             dsn.name = string(&name[0], &name[std::char_traits<NANODBC_SQLCHAR>::length(name)]);
        |                                                    ^
  /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
     45 | struct char_traits;
        |        ^
  /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3578:49: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
   3578 |                 string(&driver[0], &driver[std::char_traits<NANODBC_SQLCHAR>::length(driver)]);
        |                                                 ^
  /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
     45 | struct char_traits;
        |        ^
  /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3629:54: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
   3629 |             drv.name = string(&descr[0], &descr[std::char_traits<NANODBC_SQLCHAR>::length(descr)]);
        |                                                      ^
  /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
     45 | struct char_traits;
        |        ^

and:

  /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,
        |                                          ^
  /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/compoundfilereader/compoundfilereader.h:226:21: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
    226 |         utf16string dir;
        |                     ^
  /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
     23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
        |                             ^

The first batch of errors can be fixed by providing a simple `length()`
function for the `NANODBC_SQLCHAR const*` type. The second batch can be
fixed by using `std::basic_string<char16_t>` for `utf16string`, and
adjusting the call to `std::basic_string<char16_t>::append`.

[1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2024-10-06 08:59:10 UTC
Created attachment 254038 [details]
cad/kicad: fix build with libc++ 19
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-10-07 20:52:11 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0cb9394fcd48f9247a6b9faa072701b25df6471a

commit 0cb9394fcd48f9247a6b9faa072701b25df6471a
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-10-07 20:50:06 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2024-10-07 20:50:06 +0000

    cad/kicad: 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 cad/kicad to fail to compile with clang 19 and libc++ 19,
    resulting in errors similar to:

      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:261:25: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
        261 |     auto const n = std::char_traits<NANODBC_SQLCHAR>::length(array);
            |                         ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3576:52: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
       3576 |             dsn.name = string(&name[0], &name[std::char_traits<NANODBC_SQLCHAR>::length(name)]);
            |                                                    ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3578:49: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
       3578 |                 string(&driver[0], &driver[std::char_traits<NANODBC_SQLCHAR>::length(driver)]);
            |                                                 ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3629:54: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
       3629 |             drv.name = string(&descr[0], &descr[std::char_traits<NANODBC_SQLCHAR>::length(descr)]);
            |                                                      ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^

    and:

      /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,
            |                                          ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/compoundfilereader/compoundfilereader.h:226:21: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
        226 |         utf16string dir;
            |                     ^
      /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
         23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
            |                             ^

    The first batch of errors can be fixed by providing a simple `length()`
    function for the `NANODBC_SQLCHAR const*` type. The second batch can be
    fixed by using `std::basic_string<char16_t>` for `utf16string`, and
    adjusting the call to `std::basic_string<char16_t>::append`.

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

    PR:             281886
    MFH:            2024Q3

 ...y_compoundfilereader_compoundfilereader.h (new) | 20 ++++++++++
 ...ch-thirdparty_nanodbc_nanodbc_nanodbc.cpp (new) | 44 ++++++++++++++++++++++
 2 files changed, 64 insertions(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-10-07 20:56:12 UTC
A commit in branch 2024Q4 references this bug:

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

commit c5b74ac54ae1c5510a2fda3d3d7211e73c7745ae
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-10-07 20:50:06 +0000
Commit:     Christoph Moench-Tegeder <cmt@FreeBSD.org>
CommitDate: 2024-10-07 20:54:46 +0000

    cad/kicad: 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 cad/kicad to fail to compile with clang 19 and libc++ 19,
    resulting in errors similar to:

      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:261:25: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
        261 |     auto const n = std::char_traits<NANODBC_SQLCHAR>::length(array);
            |                         ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3576:52: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
       3576 |             dsn.name = string(&name[0], &name[std::char_traits<NANODBC_SQLCHAR>::length(name)]);
            |                                                    ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3578:49: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
       3578 |                 string(&driver[0], &driver[std::char_traits<NANODBC_SQLCHAR>::length(driver)]);
            |                                                 ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/nanodbc/nanodbc/nanodbc.cpp:3629:54: error: implicit instantiation of undefined template 'std::char_traits<unsigned short>'
       3629 |             drv.name = string(&descr[0], &descr[std::char_traits<NANODBC_SQLCHAR>::length(descr)]);
            |                                                      ^
      /usr/include/c++/v1/__string/char_traits.h:45:8: note: template is declared here
         45 | struct char_traits;
            |        ^

    and:

      /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,
            |                                          ^
      /wrkdirs/usr/ports/cad/kicad/work/kicad-7.0.2/thirdparty/compoundfilereader/compoundfilereader.h:226:21: note: in instantiation of template class 'std::basic_string<unsigned short>' requested here
        226 |         utf16string dir;
            |                     ^
      /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
         23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
            |                             ^

    The first batch of errors can be fixed by providing a simple `length()`
    function for the `NANODBC_SQLCHAR const*` type. The second batch can be
    fixed by using `std::basic_string<char16_t>` for `utf16string`, and
    adjusting the call to `std::basic_string<char16_t>::append`.

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

    PR:             281886
    MFH:            2024Q3
    (cherry picked from commit 0cb9394fcd48f9247a6b9faa072701b25df6471a)

 ...y_compoundfilereader_compoundfilereader.h (new) | 20 ++++++++++
 ...ch-thirdparty_nanodbc_nanodbc_nanodbc.cpp (new) | 44 ++++++++++++++++++++++
 2 files changed, 64 insertions(+)
Comment 4 Christoph Moench-Tegeder freebsd_committer freebsd_triage 2024-10-07 20:58:11 UTC
committed, thanks