[llvm-dev] libunwind, -static and -lpthread on ARM

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 30 19:23:30 PDT 2021


On 2021-05-01, pawel k. via llvm-dev wrote:
>Hello,
>I may be wrong here but i was getting something like this in old vers of
>clang.
>
>Id assume, pthread.a namely unwind.c is using api for unwinding thats
>incompatible with one provided by clang libs. Prolly assumed gcc model or
>windows api. Id check source of unwind.c and lookup+use or if absent
>implement exception api version thats compatible with clang. We will need
>to ask somebody else which clang lib provides this api. Documentation to
>clang might have some hints too.
>
>Best regards,
>Pawel
>
>sob., 1.05.2021, 03:47 użytkownik Andrei Datcu via llvm-dev <
>llvm-dev at lists.llvm.org> napisał:
>
>> Hello,
>>
>> I'm trying to cross compile an executable that's using pthread. Target is
>> armv7-linux-gnueabihf. I'm using the latest raspberry pi os as sysroot.
>> I've managed to successfully build llvm, clang + all the runtimes and I'm
>> trying to build a statically linked executable that's using as less GNU
>> stuff as possible.
>>
>> clang++ -sysroot=...  -stdlib=libc++ --rtlib=compiler-rt -static
>> -resource-dir ... -fuse-ld=lld -lc++abi -lunwind test.cpp

You can use --unwindlib=libunwind.

-lc++abi -lunwind are technically not in the right place.
It is ok for ld.lld, though.

>> The linker error I'm getting is:
>>
>> ld.lld: error: undefined symbol: _Unwind_ForcedUnwind
>> >>> referenced by unwind.c:121
>> >>>               unwind.o:(__pthread_unwind) in archive
>> path-to-sysroot/usr/lib/arm-linux-gnueabihf/libpthread.a
>>
>> Peeking at libunwind's internals, it seems clear there's no
>> _Unwind_ForcedUnwind built for ARM (at least not with default options).
>> What options do I have?

Pending patch adding _Unwind_ForcedUnwind for ARM EHABI
https://reviews.llvm.org/D89570

>> 1) Should I add some options when building libunwind so I get
>> _Unwind_ForcedUnwind? I'm not sure this is even possible
>> 2) Use libgcc?
>>
>> Thanks,
>> Andrei
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>

>_______________________________________________
>LLVM Developers mailing list
>llvm-dev at lists.llvm.org
>https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list