Do not add -fno-exceptions without -funwind-tables

Adding just -fno-exceptions breaks libunwind in quite mysterious way
when it's there, but exception handling doesn't work because of dummy
unwind tables.

Also as using exceptions implies references to symbols defined in
libcxx, abort build of libcxxabi as shared library if we have to keep
exceptions (when compiler supports -fno-exceptions, but not
-funwind-tables; one example would be a cross-compiler, in which case
testing for -funwind-tables flag by CMake actually requires libunwind to
be available before it's built).

llvm-svn: 229427
This commit is contained in:
Sergey Dmitrouk 2015-02-16 19:51:06 +00:00
parent 4d0397382c
commit 0aa66cf8f8
1 changed files with 9 additions and 2 deletions

View File

@ -70,9 +70,16 @@ 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_NO_EXCEPTIONS_FLAG AND LIBCXXABI_HAS_FUNWIND_TABLES )
list(APPEND LIBUNWIND_COMPILE_FLAGS -fno-exceptions)
list(APPEND LIBUNWIND_COMPILE_FLAGS -funwind-tables)
elseif( LIBUNWIND_ENABLE_SHARED )
message(FATAL_ERROR "Compiler doesn't support generation of unwind tables "
"if exception support is disabled. Building libunwind "
"DSO with runtime dependency on libcxxabi is not "
"supported.")
endif()
set(LIBCXXABI_UNWINDER_NAME "unwind")