[committed] hppa: Drop 16-byte pthread lock alignment

Florian Weimer fw@deneb.enyo.de
Fri Mar 31 07:14:29 GMT 2023


* John David Anglin:

> On 2023-03-27 8:42 a.m., Florian Weimer wrote:
>>> Here is comment in map.h:
>>>     // MapAllocator does not support alignments beyond 8. Technically we should
>>>     // support up to std::max_align_t, but this fails with ubsan and tcmalloc
>>>     // debug allocation logic which assume 8 as default alignment.
>>>     static_assert(alignof(value_type) <= 8, "");
>>>
>>> It was the above comment that convinced me that we needed to change
>>> the pthread lock alignment.
>> It seems that current tcmalloc honors GCC's
>> __STDCPP_DEFAULT_NEW_ALIGNMENT__:
>>
>>    <https://github.com/google/tcmalloc/blob/master/tcmalloc/size_classes.cc>
> Agreed.
>
> The current tcmalloc is compiled with c++17.  For earlier versions of c++, we have the
> following issue:
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html
>
> There are many packages in Debian and gentoo that are built with
> earlier versions of c++ and I don't see that changing.  This
> includes protobuf. 

Well, GCC nowadays defaults to C++17:

$ echo __cplusplus | gcc -x c++ -E -
# 0 "<stdin>"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "<stdin>"
201703L

This is GCC 12 from Debian bookworm.

>> On panama.debian.net, it seems correct:
>>
>> $ gcc -x c++ -E - < /dev/null -dM | grep __STDCPP_DEFAULT_NEW_ALIGNMENT__
>> #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16

> That should change to 8 to minimize wasted bytes.  The current
> pthread types do not need 16-byte alignment.

There might be other reasons why 16-byte alignment is needed.  But
perhaps not on HPPA.


More information about the Libc-alpha mailing list