tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [RFC] Improving compatibility of NetBSD's unwind.h (or replacing it?)



On 08.12.2018 00:22, Christos Zoulas wrote:
> In article <1544216124.17308.17.camel%gentoo.org@localhost>,
> MichaŠ Górny  <mgorny%gentoo.org@localhost> wrote:
>> -=-=-=-=-=-
>>
>> Hi,
>>
>> While working on building more LLVM projects on NetBSD, I've noticed
>> that libcxxabi fails to build due to incompatible unwind.h.  The example
>> of problematic code is [1]:
>>
>>  _Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
>>                reinterpret_cast<uintptr_t>(unwind_exception));
>>  _Unwind_SetGR(context, __builtin_eh_return_data_regno(1),
>>                static_cast<uintptr_t>(results.ttypeIndex));
>>  _Unwind_SetIP(context, results.landingPad);
>>
>> This fails to build because NetBSD's unwind.h expects the last argument
>> to _Unwind_Set{GR,IP} to be a pointer.  However, it seems that other
>> implementations expect an unsigned integer type instead.  The types used
>> for the last argument of appropriate functions (and return type of their
>> respective _Unwind_Get* counterparts) are:
>>
>>                        SetGR/GetGR   SetIP/GetIP
>>  gcc 7.3.0 on Linux    _Unwind_Word  _Unwind_Ptr   (-> unsigned [a])
>>  clang                 _Unwind_Word  _Unwind_Word  (-> uintptr_t)
>>  llvm-libunwind        uintptr_t     uintptr_t
>>  libunwind 1.2.1       uns. long     uns. long
>>
>>  [a] gcc is doing some __attribute__ magic on top of it
>>
>> I think changing our header to use unsigned integer type alike other
>> implementations is the way to go.  Does this sound like the right thing
>> to do?
>>
>> [1]:https://github.com/llvm-mirror/libcxxabi/blob/master/src/cxa_personality.cpp#L528
>>
> First we have to figure out why we have so many:
> 
> ./external/bsd/llvm/dist/clang/lib/Headers/unwind.h

This one is used by Clang as far as I can tell.

> ./external/bsd/libc++/dist/libcxxrt/src/unwind.h
> 

This is libcxxabi from PathScale.

Michal is the right person here as he used to be upstream for this
repository and probably can shed a light on this unwind.h copy.

> Ok, these 4 can be excluded I guess:
> ./external/gpl3/binutils/dist/include/mach-o/unwind.h
> ./external/gpl3/binutils.old/dist/include/mach-o/unwind.h
> ./external/gpl3/gdb/dist/include/mach-o/unwind.h
> ./external/gpl3/gdb.old/dist/include/mach-o/unwind.h
> 

Darwin-only related.

> This I wrote IIRC, and it could/should be normalized:
> ./lib/libexecinfo/unwind.h 
> 

This one is used by GCC.

It does not make much difference whether a type is 'unsigned long' or
'uintptr_t'. The incompatibility with this unwind.h variation comes from
a pointer type (void*) vs [unsigned] integer type. We shall normalize or
replace it with something compatible with the world.

> ./sys/lib/libunwind/unwind.h
> 

This one (as informed by Joerg) is a fork of a version from Apple.

Its rationale shall be explained.

> Are the others the same?
> 

The state of [lib]unwind.h used to be cryptic for me and I wish we were
able to document all the used variations, their source, purpose and
rationale.

> christos
> 


Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index