Do not add -fno-exceptions without -funwind-tables
authorSergey Dmitrouk <sdmitrouk@accesssoftek.com>
Mon, 16 Feb 2015 19:51:06 +0000 (19:51 +0000)
committerSergey Dmitrouk <sdmitrouk@accesssoftek.com>
Mon, 16 Feb 2015 19:51:06 +0000 (19:51 +0000)
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

libcxxabi/src/Unwind/CMakeLists.txt

index 77bb019..2aa45dc 100644 (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")