[cfe-dev] ARM Linux libc++ / libunwind — Exceptions not being caught
Peter Smith via cfe-dev
cfe-dev at lists.llvm.org
Thu Aug 30 09:37:51 PDT 2018
Hello Andrew,
I've not built libc++ precisely with the v7 release candidate as I
don't have that to hand but I've managed to get your example to print
"caught!" when building natively on an Arm Ubuntu 16.04 machine and
using --stdlib=libc++. I built shared libraries and didn't use
compiler-rt this time to keep it simple. I followed a similar recipe
to the buildbot
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-armv7-linux
which is using clang 5.0
My steps were:
1.) Build trunk clang to use for building libc++ etc.
2.) Using cmake
cmake -GNinja\
/path/to/monorepo/llvm \
-DLLVM_ENABLE_PROJECTS="libcxxabi;libcxx;libunwind" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=true\
-DCMAKE_C_FLAGS='-mcpu=cortex-a57'\
-DCMAKE_CXX_FLAGS='-mcpu=cortex-a57'\
-DLLVM_TARGETS_TO_BUILD='ARM'\
-DLIBCXXABI_USE_LLVM_UNWINDER=On
3.) build
ninja libunwind
ninja cxxabi
ninja cxx
I was then able to run the example with:
clang++ --stdlib=libc++ -I ./include/c++/v1 t.cpp -o t.axf -L ./lib -v
--std=c++17
LD_LIBRARY_PATH=lib ./t.axf./t.axf
caught!
Some things you might want to try:
- Use trunk clang rather than the 7.0 release. You may have found a
release blocking bug if it is only a problem on the 7.0 branch.
- What happens to your example when you use libstd++ and the gcc
unwinding implementation? I'm trying to rule out whether clang has not
produced correct exception handling information for the program.
- If you are able to build libunwind with debug then I've had some
success with the logging functions that are enabled when certain
environment variables are set, such as LIBUNWIND_PRINT_UNWINDING. This
might help determine if the abort is because the callsite of the throw
isn't found in the .ARM.exidx exception table.
- It may also be worth simplifying your example so that it is your
executable that throws the exception and not a function in the libc++
library itself, which in this case I believe would be in the libc++
shared object itself.
I'm making the assumption you are building natively here. I have
cross-compiled from x86_64 to AArch64 before but I haven't done it for
Arm. The solution I found needed standalone builds of the libraries.
If you can share a bit more about how you are trying to build we may
be able to spot something wrong?
Peter
On 30 August 2018 at 16:43, Andrew Brownsword via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> It would be most helpful if the was a known good combination of libraries and settings that would net a working toolchain for ARM7hf Ubuntu 16.04, with CLang 7 and libc++. I’ve been trying libc++abi and libunwind mostly (and compiler-rt in the last day or two) as I had build problems with the various gcc-based paths. What is the recommended path to follow though? A lot of options are provided but clearly it’s a minefield of broken paths.
>
>> On Aug 30, 2018, at 7:04 AM, Louis Dionne <ldionne at apple.com> wrote:
>>
>> Are you building your test program with -fno-rtti? I’ve seen a problem where if libc++ is built with RTTI and exceptions enabled, and a program is built with exceptions enabled BUT -fno-rtti, exceptions thrown from the program will not be caught.
>>
>> Louis
>>
>>> On Aug 25, 2018, at 15:20, Andrew Brownsword via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>>>
>>> I have built the llvm/clang 7.0.0 rc2, including libc++/libc++abi/libunwind for my Ubuntu 16.04 Linux 32-bit ARM7 hf target. A trivial c++17 test program with just this try/catch block:
>>>
>>> try { auto result = stoul(“foo”); } catch (...) { std::cerr << “caught!” << std::endl; }
>>>
>>> fails to print “caught!” Instead it just aborts. If no exceptions are thrown, programs built with this toolchain behave as expected.
>>>
>>> I have tried numerous variations of the toolchain, compile and link steps (including alternatives to the cxxabi), however they all run into various errors or ultimately give the same runtime abort.
>>>
>>> Any suggestions for how to get a functioning Linux armhf clang/libc++ 7.0.0 toolchain?
>>>
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list