Bug 280693 - databases/mysql80-server: fix build with libc++ 19
Summary: databases/mysql80-server: 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: Jochen Neumeister
URL:
Keywords:
Depends on:
Blocks: 280562
  Show dependency treegraph
 
Reported: 2024-08-08 18:24 UTC by Dimitry Andric
Modified: 2024-08-31 15:49 UTC (History)
2 users (show)

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


Attachments
databases/mysql80-client: fix build with libc++ 19 (5.04 KB, patch)
2024-08-08 18:25 UTC, Dimitry Andric
no flags Details | Diff
databases/mysql80-server: fix build with libc++ 19 (v2) (15.10 KB, patch)
2024-08-18 19:32 UTC, Dimitry Andric
no flags Details | Diff
databases/mysql80-server: fix build with libc++ 19 (v3) (16.94 KB, patch)
2024-08-22 09:32 UTC, Dimitry Andric
no flags Details | Diff
databases/mysql80-server: fix build with libc++ 19 (v4) (16.94 KB, patch)
2024-08-25 20:00 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-08-08 18:24:47 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 databases/mysql80-client 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 char>'
      820 |   static_assert(is_same<_CharT, typename traits_type::char_type>::value,
          |                                          ^
    /wrkdirs/usr/ports/databases/mysql80-client/work/mysql-8.0.39/sql/rpl_log_encryption.h:821:14: note: in instantiation of template class 'std::basic_string<unsigned char>' requested here
      821 |   Key_string m_encrypted_password;
          |              ^
    /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here
       23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
          |                             ^

`Key_string` is defined as `std::basic_string<unsigned char>`, which is
no longer possible. So redefine it as a `std::vector<unsigned char>`
instead.

This requires only a few small adjustments in other places: replacing
the `length()` method with the equivalent `size()` method, and adjusting
the arguments for the `assign()` method, which for `std::vector` takes a
begin and end iterator, instead of a begin iterator and a size.

[1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2024-08-08 18:25:26 UTC
Created attachment 252615 [details]
databases/mysql80-client: fix build with libc++ 19
Comment 2 Dimitry Andric freebsd_committer freebsd_triage 2024-08-18 19:32:34 UTC
Created attachment 252897 [details]
databases/mysql80-server: fix build with libc++ 19 (v2)

(In reply to Jochen Neumeister from comment #2)
Sorry, this was a screw-up from my side. I missed that the client port is really a slave of the server port, and that the server port compiles quite bit _more_ code, some of which also needs fixing!

I updated the patch to fix the rest of the errors that occur.
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2024-08-22 09:32:19 UTC
Created attachment 253005 [details]
databases/mysql80-server: fix build with libc++ 19 (v3)

Added two additional files to the patch to also ensure the "make test" target succeeds.
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2024-08-25 11:43:38 UTC
If it's possible I would like to get these mysql fixes in relatively soon, so I can request another exp-run for bug 280562.
Comment 5 Dimitry Andric freebsd_committer freebsd_triage 2024-08-25 20:00:43 UTC
Created attachment 253094 [details]
databases/mysql80-server: fix build with libc++ 19 (v4)

(In reply to Jochen Neumeister from comment #8)
Okay, this was due to the diff line that deleted "#include <string>" from sql/stream_cipher.h. Apparently some other files do rely on this, but it depends on the underlying C++ headers whether it leads to an error or not.

I have put back the <string> include, it should compile now. I also updated the patches for the other mysql ports.
Comment 7 Dimitry Andric freebsd_committer freebsd_triage 2024-08-28 18:42:29 UTC
(In reply to Jochen Neumeister from comment #6)
Hm, all the same problem, something with an allocator alignment:

/wrkdirs/usr/ports/databases/mysql80-server/work/mysql-8.0.39/storage/innobase/include/detail/ut/aligned_alloc.h:289:17: error: static assertion failed due to requirement 'allocator_metadata_size <= max_metadata_size': Aligned_alloc_impl provides a strong guarantee of only up to Aligned_alloc_impl::metadata_size bytes.
  289 |   static_assert(allocator_metadata_size <= max_metadata_size,
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/wrkdirs/usr/ports/databases/mysql80-server/work/mysql-8.0.39/storage/innobase/include/detail/ut/aligned_alloc.h:451:17: note: in instantiation of template class 'ut::detail::Aligned_alloc_metadata<unsigned int, unsigned int>' requested here
  451 |   static inline allocator_metadata::meta_2_t datalen(
      |                 ^
/wrkdirs/usr/ports/databases/mysql80-server/work/mysql-8.0.39/storage/innobase/include/detail/ut/aligned_alloc.h:289:41: note: expression evaluates to '8 <= 4'
  289 |   static_assert(allocator_metadata_size <= max_metadata_size,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~

I'm currently doing a poudriere run on a i386 jail, when it is finished I can do a mysql80 build there. I will probably look how mysql84 does this, since I understand that mysql84 has no issues building on i386 with these clang 19 specific patches?
Comment 8 Dimitry Andric freebsd_committer freebsd_triage 2024-08-29 10:42:49 UTC
(In reply to Dimitry Andric from comment #7)
Looks like this was already reported in bug 280541, I will see if the patch proposed there works.
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-08-31 15:45:57 UTC
A commit in branch main references this bug:

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

commit 4e862d56da47f4a6fed220dbf53e1099d7d64277
Author:     Jochen Neumeister <joneum@FreeBSD.org>
AuthorDate: 2024-08-31 15:44:28 +0000
Commit:     Jochen Neumeister <joneum@FreeBSD.org>
CommitDate: 2024-08-31 15:45:19 +0000

    databases/mysql80-server: 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 databases/mysql80-client 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 char>'
          820 |   static_assert(is_same<_CharT, typename
    traits_type::char_type>::value,
              |                                          ^
        /wrkdirs/usr/ports/databases/mysql80-client/work/mysql-8.0.39/sql/rpl_log_encryption.h:821:14:
    note: in instantiation of template class 'std::basic_string<unsigned
    char>' requested here
          821 |   Key_string m_encrypted_password;
              |              ^
        /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared
    here
           23 | struct _LIBCPP_TEMPLATE_VIS char_traits;
              |                             ^

    `Key_string` is defined as `std::basic_string<unsigned char>`, which is
    no longer possible. So redefine it as a `std::vector<unsigned char>`
    instead.

    This requires only a few small adjustments in other places: replacing
    the `length()` method with the equivalent `size()` method, and adjusting
    the arguments for the `assign()` method, which for `std::vector` takes a
    begin and end iterator, instead of a begin iterator and a size.

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

    PR:     280693
    Sponsored by:   Netzkommune GmbH

 .../files/patch-sql_binlog__ostream.cc (new)       |  11 ++
 .../files/patch-sql_mdl__context__backup.cc (new)  |  36 ++++++
 .../files/patch-sql_mdl__context__backup.h (new)   |  11 ++
 ...ge__optimizer_index__range__scan__plan.cc (new) |  39 ++++++
 .../files/patch-sql_rpl__log__encryption.cc (new)  | 134 +++++++++++++++++++++
 .../files/patch-sql_stream__cipher.cc (new)        |  11 ++
 .../files/patch-sql_stream__cipher.h (new)         |  19 +++
 ...inlogevents_transaction__compression-t.cc (new) |  11 ++
 .../patch-unittest_gunit_stream__cipher-t.cc (new) |  15 +++
 9 files changed, 287 insertions(+)