[libcxxabi] r228408 - unwind: use -fno-rtti -fno-exceptions -funwind-tables

Sergey Dmitrouk sdmitrouk at accesssoftek.com
Thu Feb 12 13:13:16 PST 2015


How about the attached patch?  Seems to work for me (it's trivial, but
syntax is weird, so I wasn't sure).

-- 
Sergey

On Thu, Feb 12, 2015 at 07:36:14AM -0800, Sergey Dmitrouk wrote:
> On Thu, Feb 12, 2015 at 07:13:09AM -0800, Saleem Abdulrasool wrote:
> >    I've been successful with clang as well.
> >    Reproduction steps would help in identifying what is happening.
>
> Looks like I found the culprit, it's CMake.  I'm cross compiling
> libcxxabi for ARM on x86_64 host, compiler targets ARM only (so ARM is
> also the default target).  cmake/config-ix.cmake contains (also note "_c_"
> instead of "_cxx_", but it doesn't affect results):
>
>     check_c_compiler_flag(-funwind-tables LIBCXXABI_HAS_FUNWIND_TABLES)
>
> This test fails on linking stage:
>
>     CMakeFiles/cmTryCompileExec3829915952.dir/src.cxx.o:(.ARM.exidx+0x0):
>     undefined reference to `__aeabi_unwind_cpp_pr0'
>
> because successful linking requires symbol defined in libunwind (and that's
> what is being built).  Now here:
>
>     append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG -fno-exceptions)
>     append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_RTTI_FLAG -fno-rtti)
>     append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)
>
> `-fno-exceptions` is added, but not `-funwind-tables`.  As a result
> libunwind sees "can't unwind" marker in exidx records and gives up.
>
> I found this bug report, which seems to be related:
>     http://www.cmake.org/Bug/view.php?id=15264
>
> Not adding `-fno-exceptions` flag if `-funwind-tables` isn't available seems
> to be reasonable by itself, but will also work around this issue with CMake.
>
> --
> Sergey
-------------- next part --------------
 src/Unwind/CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/Unwind/CMakeLists.txt b/src/Unwind/CMakeLists.txt
index 56c217d..1e623b5 100644
--- a/src/Unwind/CMakeLists.txt
+++ b/src/Unwind/CMakeLists.txt
@@ -69,9 +69,11 @@ append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FPIC_FLAG -fPIC)
 append_if(LIBCXXABI_LINK_FLAGS LIBCXXABI_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
 
 set(LIBUNWIND_COMPILE_FLAGS)
-append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG -fno-exceptions)
 append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_RTTI_FLAG -fno-rtti)
-append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)
+if ( LIBCXXABI_HAS_FUNWIND_TABLES )
+    append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG -fno-exceptions)
+    append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)
+endif()
 
 set(LIBCXXABI_UNWINDER_NAME "unwind")
 


More information about the cfe-commits mailing list