<div dir="ltr">On Wed, Feb 11, 2015 at 12:21 PM, Sergey Dmitrouk <span dir="ltr"><<a href="mailto:sdmitrouk@accesssoftek.com" target="_blank">sdmitrouk@accesssoftek.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Although code compiles and works in most cases, part of this change (namely<br>
addition of `-fno-exceptions` flag) seems to break exception handling on ARM.<br>
E.g. `catch` doesn't work in this example and `std::terminate()` is invoked:<br>
<br>
    int main(void)<br>
    {<br>
        try<br>
        {<br>
            throw 1;<br>
        }<br>
        catch (int)<br>
        {<br>
        }<br>
        return 0;<br>
    }<br>
<br>
Is it possible that `-fno-exceptions` makes Clang skip generation of<br>
some auxiliary data, which results in such strange behaviour?<br>
<br>
It's not just about `int` type, class types were not caught as well even<br>
with `catch (...)` statement.  In fact almost all tests under<br>
test-suite/SingleSource/Regression/C++/EH failed.<br>
<br>
Anyone else seeing this?  libcxxabi is used with LLVM, Clang, compiler-rt<br>
and libcxx here.<br></blockquote><div><br></div><div>Can you provide more information about how you are building things?  Perhaps an exact set of steps to reproduce this.  The change should only effects unwind.  As such, the following is sufficient for checking the result:</div><div><br></div><div>$ cat reduced.cc</div><div>extern "C" int printf(const char *, ...);</div><div>int main(int argc, char **argv) {</div><div>  try { throw 1; } catch (const int &i) { printf("caught %u\n", i); }</div><div>  return 0;</div><div>}</div><div>$ armv7a-hardfloat-linux-gnueabi-g++-4.8.3 -fno-stack-protector -c reduced.cc -o reduced.o</div><div>$ armv7a-hardfloat-linux-gnueabi-g++-4.8.3 -nodefaultlibs reduced.o -o reduced -Llib -lunwind -lc -lc++abi</div><div>$ LD_LIBRARY_PATH=lib ./reduced</div><div>caught 1</div><div><br></div><div>That was with current ToT of libc++abi and libunwind (LLVM).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Regards,<br>
Sergey<br>
<div class="HOEnZb"><div class="h5"><br>
On Fri, Feb 06, 2015 at 09:47:57AM -0800, Saleem Abdulrasool wrote:<br>
> Author: compnerd<br>
> Date: Fri Feb  6 11:47:57 2015<br>
> New Revision: 228408<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=228408&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=228408&view=rev</a><br>
> Log:<br>
> unwind: use -fno-rtti -fno-exceptions -funwind-tables<br>
><br>
> RTTI and exceptions are not needed for the unwinder, the use of C++ there is for<br>
> very specific cases, and does not require dynamic_cast nor does it use<br>
> exceptions.  This avoids unnecessary references to type information being<br>
> emitted.<br>
><br>
> Modified:<br>
>     libcxxabi/trunk/cmake/config-ix.cmake<br>
>     libcxxabi/trunk/src/Unwind/CMakeLists.txt<br>
><br>
> Modified: libcxxabi/trunk/cmake/config-ix.cmake<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=228408&r1=228407&r2=228408&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/cmake/config-ix.cmake?rev=228408&r1=228407&r2=228408&view=diff</a><br>
> ==============================================================================<br>
> --- libcxxabi/trunk/cmake/config-ix.cmake (original)<br>
> +++ libcxxabi/trunk/cmake/config-ix.cmake Fri Feb  6 11:47:57 2015<br>
> @@ -5,6 +5,8 @@ include(CheckCXXCompilerFlag)<br>
>  # Check compiler flags<br>
>  check_c_compiler_flag(-funwind-tables         LIBCXXABI_HAS_FUNWIND_TABLES)<br>
>  check_cxx_compiler_flag(-fPIC                 LIBCXXABI_HAS_FPIC_FLAG)<br>
> +check_cxx_compiler_flag(-fno-exceptions       LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG)<br>
> +check_cxx_compiler_flag(-fno-rtti             LIBCXXABI_HAS_NO_RTTI_FLAG)<br>
>  check_cxx_compiler_flag(-fstrict-aliasing     LIBCXXABI_HAS_FSTRICT_ALIASING_FLAG)<br>
>  check_cxx_compiler_flag(-nodefaultlibs        LIBCXXABI_HAS_NODEFAULTLIBS_FLAG)<br>
>  check_cxx_compiler_flag(-nostdinc++           LIBCXXABI_HAS_NOSTDINCXX_FLAG)<br>
><br>
> Modified: libcxxabi/trunk/src/Unwind/CMakeLists.txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/Unwind/CMakeLists.txt?rev=228408&r1=228407&r2=228408&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/Unwind/CMakeLists.txt?rev=228408&r1=228407&r2=228408&view=diff</a><br>
> ==============================================================================<br>
> --- libcxxabi/trunk/src/Unwind/CMakeLists.txt (original)<br>
> +++ libcxxabi/trunk/src/Unwind/CMakeLists.txt Fri Feb  6 11:47:57 2015<br>
> @@ -68,6 +68,11 @@ target_link_libraries(unwind ${libraries<br>
>  append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FPIC_FLAG -fPIC)<br>
>  append_if(LIBCXXABI_LINK_FLAGS LIBCXXABI_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)<br>
><br>
> +set(LIBUNWIND_COMPILE_FLAGS)<br>
> +append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG -fno-exceptions)<br>
> +append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_NO_RTTI_FLAG -fno-rtti)<br>
> +append_if(LIBUNWIND_COMPILE_FLAGS LIBCXXABI_HAS_FUNWIND_TABLES -funwind-tables)<br>
> +<br>
>  set(LIBCXXABI_UNWINDER_NAME "unwind")<br>
><br>
>  if ( APPLE )<br>
> @@ -86,11 +91,12 @@ if ( APPLE )<br>
>  endif()<br>
><br>
>  string(REPLACE ";" " " LIBCXXABI_COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}")<br>
> +string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")<br>
>  string(REPLACE ";" " " LIBCXXABI_LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}")<br>
><br>
>  set_target_properties(unwind<br>
>    PROPERTIES<br>
> -    COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"<br>
> +    COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS} ${LIBUNWIND_COMPILE_FLAGS}"<br>
>      LINK_FLAGS    "${LIBCXXABI_LINK_FLAGS}"<br>
>      OUTPUT_NAME   "${LIBCXXABI_UNWINDER_NAME}"<br>
>      VERSION       "1.0"<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Saleem Abdulrasool<br>compnerd (at) compnerd (dot) org</div>
</div></div>