Page MenuHomePhabricator

[CMake] Fix libc++abi arm build w/o libunwind.

Authored by logan on Aug 31 2016, 8:39 AM.



This commit fixes libc++abi build when LLVM unwinder (libunwind_llvm) is
not enabled.

This commit fixes the problem by removing "LLVM_NATIVE_ARCH MATCHES ARM"
from CMakeLists.txt so that LIBCXXABI_USE_LLVM_UNWINDER will only be
defined when LLVM unwinder is enabled.

We need LIBCXXABI_USE_LLVM_UNWINDER becase there is a subtle difference
between the unwinder from libgcc and the one from libunwind_llvm. For
the unwinder from libgcc, we have to initialize register r12 with the
address of _Unwind_Control_Block; otherwise,
_Unwind_GetLanguageSpecificData() and _Unwind_GetRegionStart() won't
work properly. Consequently, there is an extra _Unwind_SetGR() when
LLVM unwinder is disabled. Check cxa_personality.cpp for details.

Diff Detail

Event Timeline

logan updated this revision to Diff 69862.Aug 31 2016, 8:39 AM
logan retitled this revision from to [CMake] Fix libc++abi arm build w/o libunwind..
logan updated this object.
logan added reviewers: mclow.lists, rengolin, EricWF.
logan added a subscriber: cfe-commits.
rengolin edited edge metadata.Aug 31 2016, 8:45 AM

That match would only make sense if LLVM's unwinder was forced on ARM targets, and they're most certainly not. Expecting both unwindwers to behave identically makes no sense.

This fix looks good to me, but I'll let Marshall or Eric have a look first.

logan added a comment.Oct 3 2016, 9:14 AM

Ping? Any other comments?

LGTM too.

@EricWF or @mclow.lists need to approve.

logan added a comment.Oct 31 2016, 6:59 AM

Hi @EricWF and @mclow.lists:

Do you have any comments?

EricWF edited edge metadata.Oct 31 2016, 7:06 AM

Is ON the right default for ARM? If so please apply the inline comment to fix the default settings.. Otherwise this LGTM.

cmake_dependent_option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder" OFF
                                           "LLVM_NATIVE_ARCH MATCHES ARM" ON)

And don't forget to add the include for cmake_dependent_option somewhere above!

EricWF added inline comments.Oct 31 2016, 7:08 AM

The above code isn't correct as-is. You'll have to escape the strings for MATCHES.

logan added a comment.Nov 1 2016, 8:56 AM

Hi @EricWF:

Thanks for your comment.

However, I think OFF is a better default for ARM (just like other platforms.) I usually use libc++abi without libunwind since libgcc is quite stable and usually linked by default. Besides, it is much more tricky to get the libc++/libc++abi/libunwind/compiler-rt combo work. The situation goes even worse when you are linking libgcc together.


logan added a comment.Nov 11 2016, 8:22 PM

Hi @EricWF:

Would you mind if I commit this patch as-is? I believe OFF will is the better default value for ARM as well. Thanks.


EricWF accepted this revision.Nov 12 2016, 12:05 AM
EricWF edited edge metadata.

Nope LGTM.

This revision is now accepted and ready to land.Nov 12 2016, 12:05 AM
logan closed this revision.Nov 13 2016, 6:52 AM

Thanks. Committed as rL286759.