Skip to content

PS-10070, PS-10083 [8.4]: fixes for Apple clang#5942

Open
jankowsk wants to merge 2 commits into
percona:8.4from
jankowsk:PS10070-8.4-fix_apple_build
Open

PS-10070, PS-10083 [8.4]: fixes for Apple clang#5942
jankowsk wants to merge 2 commits into
percona:8.4from
jankowsk:PS10070-8.4-fix_apple_build

Conversation

@jankowsk
Copy link
Copy Markdown
Contributor

https://perconadev.atlassian.net/browse/PS-10070

rapidjson's TypeHelper has specializations for the fixed-width integer typedefs (uint64_t etc.) but not for size_t. On macOS / Apple clang + libc++, size_t is 'unsigned long' which has no TypeHelper specialization, so get_element<size_t>() fails to compile. Read into a uint64_t and assign back on success; uint64_t is recognized on all platforms.

@jankowsk jankowsk requested a review from lukin-oleksiy May 12, 2026 07:15
@jankowsk jankowsk changed the title PS-10070 [8.4]: fix for Apple clang PS-10070, PS-10083 [8.4]: fixes for Apple clang May 12, 2026
@jankowsk
Copy link
Copy Markdown
Contributor Author

Added another commit fixing problems with https://perconadev.atlassian.net/browse/PS-10083

The static_assert(sizeof(thread_group_t) == 512, ...) in sql/threadpool_unix.cc has existed since PS 8.0.12 and was hand-tuned against the Linux/glibc layout of the embedded mysql_mutex_t and PSI structures. PS-10083 ("Add more statistics for threadpool", merged 2026-03-11 between 9.6.0 and 9.7.0) inserted two LiveStats members into thread_group_t and adjusted the trailing 'char padding[]' from 328 to 248 to keep the Linux total at exactly 512.

LiveStats itself is platform-neutral (5 PODs, 40 bytes), but mysql_mutex_t expands by ~128 bytes on macOS / Apple clang + libc++, so on that platform the struct lands at 640 bytes and breaks the build:

sql/threadpool_unix.cc:155:1: error: static assertion failed due
to requirement 'sizeof(thread_group_t) == 512'
The false-sharing guarantee comes from alignas(128); what matters is that the struct occupies a whole number of 128-byte cache lines, not that it is exactly 512 bytes (640 is also a multiple of 128). Replace the equality check with 'sizeof % 128 == 0' so Linux/glibc, libc++ on macOS, and any future libstdc++ layout drift all pass while the no-false-sharing invariant remains enforced.

jankowsk and others added 2 commits May 12, 2026 12:23
https://perconadev.atlassian.net/browse/PS-10070

rapidjson's TypeHelper has specializations for the fixed-width integer
typedefs (uint64_t etc.) but not for size_t. On macOS / Apple clang +
libc++, size_t is 'unsigned long' which has no TypeHelper specialization,
so get_element<size_t>() fails to compile. Read into a uint64_t and
assign back on success; uint64_t is recognized on all platforms.
The static_assert(sizeof(thread_group_t) == 512, ...) in
sql/threadpool_unix.cc has existed since PS 8.0.12 and was hand-tuned
against the Linux/glibc layout of the embedded mysql_mutex_t and PSI
structures. PS-10083 ("Add more statistics for threadpool", merged
2026-03-11 between 9.6.0 and 9.7.0) inserted two LiveStats members into
thread_group_t and adjusted the trailing 'char padding[]' from 328 to
248 to keep the Linux total at exactly 512.

LiveStats itself is platform-neutral (5 PODs, 40 bytes), but
mysql_mutex_t expands by ~128 bytes on macOS / Apple clang + libc++,
so on that platform the struct lands at 640 bytes and breaks the
build:

    sql/threadpool_unix.cc:155:1: error: static assertion failed due
        to requirement 'sizeof(thread_group_t) == 512'

The false-sharing guarantee comes from alignas(128); what matters is
that the struct occupies a whole number of 128-byte cache lines, not
that it is exactly 512 bytes (640 is also a multiple of 128). Replace
the equality check with 'sizeof % 128 == 0' so Linux/glibc, libc++
on macOS, and any future libstdc++ layout drift all pass while the
no-false-sharing invariant remains enforced.
@jankowsk jankowsk force-pushed the PS10070-8.4-fix_apple_build branch from 7d0dd1b to 7fce944 Compare May 12, 2026 10:26
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.

2 participants