Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-31 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271267: [libcxxabi] Introduce a -fno-exceptions libc++abi 
libary variant (authored by asiri).

Changed prior to commit:
  http://reviews.llvm.org/D20677?vs=59009=59044#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D20677

Files:
  libcxxabi/trunk/CMakeLists.txt
  libcxxabi/trunk/src/CMakeLists.txt
  libcxxabi/trunk/src/cxa_aux_runtime.cpp
  libcxxabi/trunk/src/cxa_handlers.cpp
  libcxxabi/trunk/src/cxa_new_delete.cpp
  libcxxabi/trunk/src/cxa_noexception.cpp
  libcxxabi/trunk/test/CMakeLists.txt
  libcxxabi/trunk/test/backtrace_test.pass.cpp
  libcxxabi/trunk/test/catch_array_01.pass.cpp
  libcxxabi/trunk/test/catch_array_02.pass.cpp
  libcxxabi/trunk/test/catch_class_01.pass.cpp
  libcxxabi/trunk/test/catch_class_02.pass.cpp
  libcxxabi/trunk/test/catch_class_03.pass.cpp
  libcxxabi/trunk/test/catch_class_04.pass.cpp
  libcxxabi/trunk/test/catch_const_pointer_nullptr.pass.cpp
  libcxxabi/trunk/test/catch_function_01.pass.cpp
  libcxxabi/trunk/test/catch_function_02.pass.cpp
  libcxxabi/trunk/test/catch_in_noexcept.pass.cpp
  libcxxabi/trunk/test/catch_member_data_pointer_01.pass.cpp
  libcxxabi/trunk/test/catch_member_function_pointer_01.pass.cpp
  libcxxabi/trunk/test/catch_member_pointer_nullptr.pass.cpp
  libcxxabi/trunk/test/catch_multi_level_pointer.pass.cpp
  libcxxabi/trunk/test/catch_pointer_nullptr.pass.cpp
  libcxxabi/trunk/test/catch_pointer_reference.pass.cpp
  libcxxabi/trunk/test/catch_ptr.pass.cpp
  libcxxabi/trunk/test/catch_ptr_02.pass.cpp
  libcxxabi/trunk/test/cxa_bad_cast.pass.cpp
  libcxxabi/trunk/test/cxa_bad_typeid.pass.cpp
  libcxxabi/trunk/test/incomplete_type.sh.cpp
  libcxxabi/trunk/test/inherited_exception.pass.cpp
  libcxxabi/trunk/test/libcxxabi/test/config.py
  libcxxabi/trunk/test/lit.site.cfg.in
  libcxxabi/trunk/test/noexception1.pass.cpp
  libcxxabi/trunk/test/noexception2.pass.cpp
  libcxxabi/trunk/test/noexception3.pass.cpp
  libcxxabi/trunk/test/noexception4.pass.cpp
  libcxxabi/trunk/test/test_aux_runtime.pass.cpp
  libcxxabi/trunk/test/test_aux_runtime_op_array_new.pass.cpp
  libcxxabi/trunk/test/test_guard.pass.cpp
  libcxxabi/trunk/test/test_vector1.pass.cpp
  libcxxabi/trunk/test/test_vector2.pass.cpp
  libcxxabi/trunk/test/test_vector3.pass.cpp
  libcxxabi/trunk/test/uncaught_exceptions.pass.cpp
  libcxxabi/trunk/test/unwind_01.pass.cpp
  libcxxabi/trunk/test/unwind_02.pass.cpp
  libcxxabi/trunk/test/unwind_03.pass.cpp
  libcxxabi/trunk/test/unwind_04.pass.cpp
  libcxxabi/trunk/test/unwind_05.pass.cpp
  libcxxabi/trunk/test/unwind_06.pass.cpp

Index: libcxxabi/trunk/test/catch_function_01.pass.cpp
===
--- libcxxabi/trunk/test/catch_function_01.pass.cpp
+++ libcxxabi/trunk/test/catch_function_01.pass.cpp
@@ -12,6 +12,7 @@
 // GCC incorrectly allows function pointer to be caught by reference.
 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372
 // XFAIL: gcc
+// UNSUPPORTED: libcxxabi-no-exceptions
 
 #include 
 
Index: libcxxabi/trunk/test/test_vector3.pass.cpp
===
--- libcxxabi/trunk/test/test_vector3.pass.cpp
+++ libcxxabi/trunk/test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: libcxxabi/trunk/test/test_vector1.pass.cpp
===
--- libcxxabi/trunk/test/test_vector1.pass.cpp
+++ libcxxabi/trunk/test/test_vector1.pass.cpp
@@ -47,8 +47,19 @@
 int gConstructorThrowTarget;
 int gDestructorCounter;
 int gDestructorThrowTarget;
-void throw_construct ( void *p ) { if ( gConstructorCounter   == gConstructorThrowTarget ) throw 1; ++gConstructorCounter; }
-void throw_destruct  ( void *p ) { if ( ++gDestructorCounter  == gDestructorThrowTarget  ) throw 2; }
+void throw_construct ( void *p ) {
+#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+if ( gConstructorCounter   == gConstructorThrowTarget )
+throw 1;
+++gConstructorCounter;
+#endif
+}
+void throw_destruct  ( void *p ) {
+#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+if ( ++gDestructorCounter  == gDestructorThrowTarget  )
+throw 2;
+#endif
+}
 
 #if __cplusplus >= 201103L
 #   define CAN_THROW noexcept(false)
@@ -146,6 +157,7 @@
 return retVal;
 }
 
+#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
 //  Make sure the constructors and destructors are matched
 int test_exception_in_constructor ( ) {
 int retVal = 0;
@@ -202,7 +214,9 @@
 
 return retVal;
 }
+#endif
 
+#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
 //  Make sure the constructors and destructors are matched
 int test_exception_in_destructor ( ) {
 int retVal = 0;
@@ -253,12 +267,15 @@
 
 return retVal;
 }
+#endif
 
 int main ( int argc, char *argv [] ) {
 int retVal = 0;
 

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-31 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D20677#443997, @rmaprath wrote:

> Thanks Eric.
>
> I think I noted a few other `assert(true)` statements elsewhere (with similar 
> application), will update those separately.
>
> Btw, do you use some systematic way to detect ABI breakages? I've only bumped 
> into http://lvc.github.io/abi-compliance-checker/ but didn't go as far as 
> setting it up.


Not really, the two primary ways I try to detect ABI breakage are using:

- the scripts under `libcxx/utils/sym_check/`. They provide a way to diff the 
symbols between two dylibs `sym_diff.py old-lib.so new-lib.so`.
- Compiling against an old library and swapping in a new library at runtime.

I also used libabigail for a while but it was a bit too noisy with false 
positives. It may be better now though.

> / Asiri





http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-31 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Thanks Eric.

I think I noted a few other `assert(true)` statements elsewhere (with similar 
application), will update those separately.

Btw, do you use some systematic way to detect ABI breakages? I've only bumped 
into http://lvc.github.io/abi-compliance-checker/ but didn't go as far as 
setting it up.

/ Asiri


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Just for reference here is a list of symbols which have been removed:

https://gist.github.com/EricWF/bf00dbc5fccc78b779f8d260727a0710

LGTM. Your free to submit it after addressing the inline comments.



Comment at: test/cxa_bad_cast.pass.cpp:40
@@ +39,3 @@
+} catch (std::bad_cast) {
+assert(true);
+} catch (...) {

return 0;


Comment at: test/cxa_bad_cast.pass.cpp:45
@@ +44,3 @@
+#endif
+return 0;
+}

return 1;


Comment at: test/cxa_bad_typeid.pass.cpp:39
@@ +38,3 @@
+} catch (std::bad_typeid) {
+assert(true);
+} catch (...) {

return 0 here instead. "assert(true)" is pretty much un-observable.


Comment at: test/cxa_bad_typeid.pass.cpp:44
@@ +43,3 @@
+#endif
+return 0;
+}

This should return non-zero.


Comment at: test/noexception1.pass.cpp:26
@@ +25,3 @@
+int main ()
+{
+std::set_terminate(my_terminate);

Before setting the terminate handling call the function once with null to make 
sure it returns.


Comment at: test/noexception2.pass.cpp:26
@@ +25,3 @@
+int main ()
+{
+std::set_terminate(my_terminate);

Before setting the terminate handling call the function once with null to make 
sure it returns.


Comment at: test/noexception3.pass.cpp:27
@@ +26,3 @@
+{
+std::set_terminate(my_terminate);
+__cxxabiv1::__cxa_rethrow_primary_exception((void*) );

Before setting the terminate handling call the function once with null to make 
sure it returns.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Nevermind. I figured out why it wasn't working. Phab didn't know the libc++ 
patch was in a different repo and so it wouldn't apply the patch.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

For some reason I'm having trouble applying your patch. Could you please upload 
it with more context? (ie git diff -U999 or similar)


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath marked 6 inline comments as done.
rmaprath added a comment.

http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 59009.
rmaprath added a comment.

Addressed review comments from @EricWF:

- Addressed the nits
- Disabled `backtrace_test.pass.cpp` for the moment, need to check if using 
`_Unwind_backtrace` with no unwinding tables (-fno-exceptions) makes sense
- Enabled a small part of `test_vector1.pass.cpp`, most of this test and other 
vector tests are to do with how exceptions are dealt with
- Added tests for the new functions introduced to `cxa_noexceptions.cpp`. These 
are mostly trivial.
- Added tests for the `__cxa_bad_cast` and `__cxa_bad_typeid` functions. Could 
not manage to invoke `__cxa_throw_bad_array_new_length`, which does not seem to 
work like documented in [1]. Need to take this offline.

[1] http://en.cppreference.com/w/cpp/memory/new/bad_array_new_length


http://reviews.llvm.org/D20677

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/cxa_aux_runtime.cpp
  src/cxa_handlers.cpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  test/CMakeLists.txt
  test/backtrace_test.pass.cpp
  test/catch_array_01.pass.cpp
  test/catch_array_02.pass.cpp
  test/catch_class_01.pass.cpp
  test/catch_class_02.pass.cpp
  test/catch_class_03.pass.cpp
  test/catch_class_04.pass.cpp
  test/catch_const_pointer_nullptr.pass.cpp
  test/catch_function_01.pass.cpp
  test/catch_function_02.pass.cpp
  test/catch_in_noexcept.pass.cpp
  test/catch_member_data_pointer_01.pass.cpp
  test/catch_member_function_pointer_01.pass.cpp
  test/catch_member_pointer_nullptr.pass.cpp
  test/catch_multi_level_pointer.pass.cpp
  test/catch_pointer_nullptr.pass.cpp
  test/catch_pointer_reference.pass.cpp
  test/catch_ptr.pass.cpp
  test/catch_ptr_02.pass.cpp
  test/cxa_bad_cast.pass.cpp
  test/cxa_bad_typeid.pass.cpp
  test/incomplete_type.sh.cpp
  test/inherited_exception.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/noexception1.pass.cpp
  test/noexception2.pass.cpp
  test/noexception3.pass.cpp
  test/noexception4.pass.cpp
  test/test_aux_runtime.pass.cpp
  test/test_aux_runtime_op_array_new.pass.cpp
  test/test_guard.pass.cpp
  test/test_vector1.pass.cpp
  test/test_vector2.pass.cpp
  test/test_vector3.pass.cpp
  test/uncaught_exceptions.pass.cpp
  test/unwind_01.pass.cpp
  test/unwind_02.pass.cpp
  test/unwind_03.pass.cpp
  test/unwind_04.pass.cpp
  test/unwind_05.pass.cpp
  test/unwind_06.pass.cpp

Index: test/unwind_06.pass.cpp
===
--- test/unwind_06.pass.cpp
+++ test/unwind_06.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_05.pass.cpp
===
--- test/unwind_05.pass.cpp
+++ test/unwind_05.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_04.pass.cpp
===
--- test/unwind_04.pass.cpp
+++ test/unwind_04.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_03.pass.cpp
===
--- test/unwind_03.pass.cpp
+++ test/unwind_03.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_02.pass.cpp
===
--- test/unwind_02.pass.cpp
+++ test/unwind_02.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/unwind_01.pass.cpp
===
--- test/unwind_01.pass.cpp
+++ test/unwind_01.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/uncaught_exceptions.pass.cpp
===
--- test/uncaught_exceptions.pass.cpp
+++ test/uncaught_exceptions.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/test_vector3.pass.cpp
===
--- test/test_vector3.pass.cpp
+++ test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

Looking good. I would like to see some tests for the methods we have specificly 
defined to have behavior in -fno-exceptions mode.



Comment at: src/cxa_noexception.cpp:27
@@ +26,3 @@
+
+_LIBCXXABI_FUNC_VIS void
+__cxa_increment_exception_refcount(void *thrown_object) throw() {

I think either all of the functions in this file should have 
`_LIBCXXABI_FUNC_VIS` or none of them should. My preference is none since the 
declarations should have them.


Comment at: src/cxa_noexception.cpp:29
@@ +28,3 @@
+__cxa_increment_exception_refcount(void *thrown_object) throw() {
+if (thrown_object != NULL)
+std::terminate();

nit: nullptr


Comment at: src/cxa_noexception.cpp:45
@@ +44,3 @@
+void
+__cxa_rethrow_primary_exception(void*) { return; }
+

I think we should terminate if `void*` is non-null.


Comment at: test/backtrace_test.pass.cpp:19
@@ -19,2 +19,2 @@
 }
 

Does this test have any value in -fno-exceptions mode?


Comment at: test/libcxxabi/test/config.py:46
@@ +45,3 @@
+if self.get_lit_bool('enable_exceptions', True):
+self.cxx.compile_flags += ['-funwind-tables', 
'-DLIBCXXABI_ENABLE_EXCEPTIONS']
+else:

Nit: I would prefer `LIBCXXABI_HAS_NO_EXCEPTIONS` since the default should be 
on. The fact that a macro is missing shouldn't disable half the tests.


Comment at: test/test_vector1.pass.cpp:8
@@ -7,3 +7,3 @@
 //
 
//===--===//
 

Don't you want these tests to run? They aren't part of the exception API AFAIK.


Comment at: test/uncaught_exceptions.pass.cpp:10
@@ -9,1 +9,3 @@
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+

We provided a different implementation so we should test it, not disable the 
test.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-30 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 59000.
rmaprath added a comment.

Addressing review comments from @EricWF:

- Rather than explicitly decoupling the no-exceptions `libc++` library from the 
`__cxa_*` routines (http://reviews.llvm.org/D20784), provide a placeholder 
implementation of those functions within the no-exceptions `libc++abi` library. 
We still have some symbols like `__cxa_throw` removed from the no-exceptions 
`libc++abi` library (those symbols are generated from the compiler, rather than 
found in the library), so the original requirement of not allowing linking 
with-exceptions code with no-exceptions `libc++abi` library is satisfied.


http://reviews.llvm.org/D20677

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/cxa_aux_runtime.cpp
  src/cxa_handlers.cpp
  src/cxa_new_delete.cpp
  src/cxa_noexception.cpp
  test/CMakeLists.txt
  test/backtrace_test.pass.cpp
  test/catch_array_01.pass.cpp
  test/catch_array_02.pass.cpp
  test/catch_class_01.pass.cpp
  test/catch_class_02.pass.cpp
  test/catch_class_03.pass.cpp
  test/catch_class_04.pass.cpp
  test/catch_const_pointer_nullptr.pass.cpp
  test/catch_function_01.pass.cpp
  test/catch_function_02.pass.cpp
  test/catch_in_noexcept.pass.cpp
  test/catch_member_data_pointer_01.pass.cpp
  test/catch_member_function_pointer_01.pass.cpp
  test/catch_member_pointer_nullptr.pass.cpp
  test/catch_multi_level_pointer.pass.cpp
  test/catch_pointer_nullptr.pass.cpp
  test/catch_pointer_reference.pass.cpp
  test/catch_ptr.pass.cpp
  test/catch_ptr_02.pass.cpp
  test/incomplete_type.sh.cpp
  test/inherited_exception.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_aux_runtime.pass.cpp
  test/test_aux_runtime_op_array_new.pass.cpp
  test/test_guard.pass.cpp
  test/test_vector1.pass.cpp
  test/test_vector2.pass.cpp
  test/test_vector3.pass.cpp
  test/uncaught_exceptions.pass.cpp
  test/unwind_01.pass.cpp
  test/unwind_02.pass.cpp
  test/unwind_03.pass.cpp
  test/unwind_04.pass.cpp
  test/unwind_05.pass.cpp
  test/unwind_06.pass.cpp

Index: test/unwind_06.pass.cpp
===
--- test/unwind_06.pass.cpp
+++ test/unwind_06.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_05.pass.cpp
===
--- test/unwind_05.pass.cpp
+++ test/unwind_05.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_04.pass.cpp
===
--- test/unwind_04.pass.cpp
+++ test/unwind_04.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_03.pass.cpp
===
--- test/unwind_03.pass.cpp
+++ test/unwind_03.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_02.pass.cpp
===
--- test/unwind_02.pass.cpp
+++ test/unwind_02.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/unwind_01.pass.cpp
===
--- test/unwind_01.pass.cpp
+++ test/unwind_01.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/uncaught_exceptions.pass.cpp
===
--- test/uncaught_exceptions.pass.cpp
+++ test/uncaught_exceptions.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/test_vector3.pass.cpp
===
--- test/test_vector3.pass.cpp
+++ test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector2.pass.cpp
===
--- test/test_vector2.pass.cpp
+++ test/test_vector2.pass.cpp
@@ -7,6 +7,8 @@
 //
 

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-29 Thread Asiri Rathnayake via cfe-commits
rmaprath marked an inline comment as done.
rmaprath added a comment.

http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 58929.
rmaprath added a comment.

Fixed a few typos.


http://reviews.llvm.org/D20677

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/cxa_aux_runtime.cpp
  src/cxa_handlers.cpp
  src/cxa_new_delete.cpp
  test/CMakeLists.txt
  test/backtrace_test.pass.cpp
  test/catch_array_01.pass.cpp
  test/catch_array_02.pass.cpp
  test/catch_class_01.pass.cpp
  test/catch_class_02.pass.cpp
  test/catch_class_03.pass.cpp
  test/catch_class_04.pass.cpp
  test/catch_const_pointer_nullptr.pass.cpp
  test/catch_function_01.pass.cpp
  test/catch_function_02.pass.cpp
  test/catch_in_noexcept.pass.cpp
  test/catch_member_data_pointer_01.pass.cpp
  test/catch_member_function_pointer_01.pass.cpp
  test/catch_member_pointer_nullptr.pass.cpp
  test/catch_multi_level_pointer.pass.cpp
  test/catch_pointer_nullptr.pass.cpp
  test/catch_pointer_reference.pass.cpp
  test/catch_ptr.pass.cpp
  test/catch_ptr_02.pass.cpp
  test/incomplete_type.sh.cpp
  test/inherited_exception.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_aux_runtime.pass.cpp
  test/test_aux_runtime_op_array_new.pass.cpp
  test/test_guard.pass.cpp
  test/test_vector1.pass.cpp
  test/test_vector2.pass.cpp
  test/test_vector3.pass.cpp
  test/uncaught_exceptions.pass.cpp
  test/unwind_01.pass.cpp
  test/unwind_02.pass.cpp
  test/unwind_03.pass.cpp
  test/unwind_04.pass.cpp
  test/unwind_05.pass.cpp
  test/unwind_06.pass.cpp

Index: test/unwind_06.pass.cpp
===
--- test/unwind_06.pass.cpp
+++ test/unwind_06.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_05.pass.cpp
===
--- test/unwind_05.pass.cpp
+++ test/unwind_05.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_04.pass.cpp
===
--- test/unwind_04.pass.cpp
+++ test/unwind_04.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_03.pass.cpp
===
--- test/unwind_03.pass.cpp
+++ test/unwind_03.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_02.pass.cpp
===
--- test/unwind_02.pass.cpp
+++ test/unwind_02.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/unwind_01.pass.cpp
===
--- test/unwind_01.pass.cpp
+++ test/unwind_01.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/uncaught_exceptions.pass.cpp
===
--- test/uncaught_exceptions.pass.cpp
+++ test/uncaught_exceptions.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/test_vector3.pass.cpp
===
--- test/test_vector3.pass.cpp
+++ test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector2.pass.cpp
===
--- test/test_vector2.pass.cpp
+++ test/test_vector2.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector1.pass.cpp
===
--- test/test_vector1.pass.cpp
+++ test/test_vector1.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_guard.pass.cpp
===
--- test/test_guard.pass.cpp
+++ test/test_guard.pass.cpp

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-29 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: CMakeLists.txt:111
@@ -110,2 +110,3 @@
 # Define options.
+option(LIBCXXABI_ENABLE_EXCEPTIONS "Use exceptions." OFF)
 option(LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build 
mode." ON)

My bad, this should be ON by default (leftover from testing).


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-29 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 58927.
rmaprath added a comment.

OK, managed to solve this problem by removing `cxa_exception.cpp` and 
`cxa_personality.cpp` from the no-exceptions libcxxabi build.

In order to do this, a small patch was needed for `exception.cpp` of libcxx: 
http://reviews.llvm.org/D20784

@EricWF, @mclow.lists: WDYT?

Thanks.

/ Asiri


http://reviews.llvm.org/D20677

Files:
  CMakeLists.txt
  src/CMakeLists.txt
  src/cxa_aux_runtime.cpp
  src/cxa_handlers.cpp
  src/cxa_new_delete.cpp
  test/CMakeLists.txt
  test/backtrace_test.pass.cpp
  test/catch_array_01.pass.cpp
  test/catch_array_02.pass.cpp
  test/catch_class_01.pass.cpp
  test/catch_class_02.pass.cpp
  test/catch_class_03.pass.cpp
  test/catch_class_04.pass.cpp
  test/catch_const_pointer_nullptr.pass.cpp
  test/catch_function_01.pass.cpp
  test/catch_function_02.pass.cpp
  test/catch_in_noexcept.pass.cpp
  test/catch_member_data_pointer_01.pass.cpp
  test/catch_member_function_pointer_01.pass.cpp
  test/catch_member_pointer_nullptr.pass.cpp
  test/catch_multi_level_pointer.pass.cpp
  test/catch_pointer_nullptr.pass.cpp
  test/catch_pointer_reference.pass.cpp
  test/catch_ptr.pass.cpp
  test/catch_ptr_02.pass.cpp
  test/incomplete_type.sh.cpp
  test/inherited_exception.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_aux_runtime.pass.cpp
  test/test_aux_runtime_op_array_new.pass.cpp
  test/test_guard.pass.cpp
  test/test_vector1.pass.cpp
  test/test_vector2.pass.cpp
  test/test_vector3.pass.cpp
  test/uncaught_exceptions.pass.cpp
  test/unwind_01.pass.cpp
  test/unwind_02.pass.cpp
  test/unwind_03.pass.cpp
  test/unwind_04.pass.cpp
  test/unwind_05.pass.cpp
  test/unwind_06.pass.cpp

Index: test/unwind_06.pass.cpp
===
--- test/unwind_06.pass.cpp
+++ test/unwind_06.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_05.pass.cpp
===
--- test/unwind_05.pass.cpp
+++ test/unwind_05.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_04.pass.cpp
===
--- test/unwind_04.pass.cpp
+++ test/unwind_04.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_03.pass.cpp
===
--- test/unwind_03.pass.cpp
+++ test/unwind_03.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_02.pass.cpp
===
--- test/unwind_02.pass.cpp
+++ test/unwind_02.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/unwind_01.pass.cpp
===
--- test/unwind_01.pass.cpp
+++ test/unwind_01.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/uncaught_exceptions.pass.cpp
===
--- test/uncaught_exceptions.pass.cpp
+++ test/uncaught_exceptions.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/test_vector3.pass.cpp
===
--- test/test_vector3.pass.cpp
+++ test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector2.pass.cpp
===
--- test/test_vector2.pass.cpp
+++ test/test_vector2.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector1.pass.cpp
===
--- test/test_vector1.pass.cpp
+++ test/test_vector1.pass.cpp
@@ -7,6 +7,8 @@
 //
 

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.



> I have a small concern about how difficult this would make things for us 
> though - our toolchain setup uses `-ffunction-sections` and `-fdata-sections` 
> along with linker's unused-section elimination to get rid of most of the 
> stuff not necessary for the final image, but I can't remember if 
> unused-section elimination happens before or after checking for missing 
> symbols. If it is the latter, then we might be in trouble with this approach. 
> I will have a look into this when I get back to work.


Come to think of it, I'm 90% sure it's the latter (I don't see how the former 
can work - the linker has to load all the objects while resolving all the 
dependencies, then only it can get rid of the stuff the final image doesn't 
really need). The linker will give up as soon as it hits a missing symbol 
referred from a section which is actually unused in the final image (but is 
within some object which contains sections that are actually needed for the 
image).

Of course I need to confirm that 10% when I get my hands on the linker, but I 
have a feeling this is going to be a blocker for us.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D20677#442713, @EricWF wrote:

> In http://reviews.llvm.org/D20677#442687, @rmaprath wrote:
>
> > In http://reviews.llvm.org/D20677#442559, @EricWF wrote:
> >
> > > I have an issue with this change since it allows a libc++abi built 
> > > without exceptions to be used in a program compiled with them. I assert 
> > > that this should not be supported in any way.
> > >
> > > My personal preference would be to remove as much of the exception API 
> > > from the library when it's built without exceptions. This should cause 
> > > link errors if a program contains any code that throws. If this is not 
> > > done it creates bugs within code like `__terminate` as mentioned in an 
> > > inline comment.
> > >
> > > I would like to see another revision of this patch that removes as much 
> > > of the exception API as possible. Looking at the symbols defined in 
> > > `cxxabi.h` I would say ever symbol in sections 2.4 and 2.5 should not 
> > > longer be defined in the library.
> >
> >
> > That sounds generally OK to me. The toolchain I'm working on (ARM Compiler 
> > 6) has an elaborate mechanism (based on build attributes) to select the 
> > correct variant of libraries. In other words, if any of your objects are 
> > compiled with exceptions, you are guaranteed to no select any of the 
> > no-exceptions library variants. This avoids the problem you mentioned 
> > altogether.
>
>
> Note that that behavior will cause different issues in some cases. If you  
> link an executable  to two libraries, `libfoo.so` and `libbar.so`, where one 
> was compiled with exceptions and the other without you'll get two copies of 
> libc++abi in the program. Now you have two copies of the global terminate 
> handler and two copies of `__terminate` for the linker to select from.
>  If it selects the nothrow `__terminate` and the terminate handler throws an 
> exception your in trouble.


In this case, I expect the linker to only select one variant of libc++abi (the 
one with exceptions). The idea behind build-attributes is to capture user 
intentions, if the user links his program with `libbar.a` and `libfoo.a` user 
libraries (with and without exceptions), the linker would assume that the user 
meant to use exceptions rather than not, and hence select the with-exceptions 
libc++abi variant. The theory behind build-attributes is bit more complicated 
that that though, I'm not the best person to go on about this.

In any case, I agree that getting the linker to produce an error (when linking 
with-exceptions objects with a no-exceptions libc++abi) is much more clearer.

I have a small concern about how difficult this would make things for us though 
- our toolchain setup uses `-ffunction-sections` and `-fdata-sections` along 
with linker's unused-section elimination to get rid of most of the stuff not 
necessary for the final image, but I can't remember if unused-section 
elimination happens before or after checking for missing symbols. If it is the 
latter, then we might be in trouble with this approach. I will have a look into 
this when I get back to work.

Cheers,

/ Asiri


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-27 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D20677#442687, @rmaprath wrote:

> In http://reviews.llvm.org/D20677#442559, @EricWF wrote:
>
> > I have an issue with this change since it allows a libc++abi built without 
> > exceptions to be used in a program compiled with them. I assert that this 
> > should not be supported in any way.
> >
> > My personal preference would be to remove as much of the exception API from 
> > the library when it's built without exceptions. This should cause link 
> > errors if a program contains any code that throws. If this is not done it 
> > creates bugs within code like `__terminate` as mentioned in an inline 
> > comment.
> >
> > I would like to see another revision of this patch that removes as much of 
> > the exception API as possible. Looking at the symbols defined in `cxxabi.h` 
> > I would say ever symbol in sections 2.4 and 2.5 should not longer be 
> > defined in the library.
>
>
> That sounds generally OK to me. The toolchain I'm working on (ARM Compiler 6) 
> has an elaborate mechanism (based on build attributes) to select the correct 
> variant of libraries. In other words, if any of your objects are compiled 
> with exceptions, you are guaranteed to no select any of the no-exceptions 
> library variants. This avoids the problem you mentioned altogether.


Note that that behavior will cause different issues in some cases. If you  link 
an executable  to two libraries, `libfoo.so` and `libbar.so`, where one was 
compiled with exceptions and the other without you'll get two copies of 
libc++abi in the program. Now you have two copies of the global terminate 
handler and two copies of `__terminate` for the linker to select from.
If it selects the nothrow `__terminate` and the terminate handler throws an 
exception your in trouble.

That's not a reason to hold up this patch, but it is a potential problem you 
should be aware of.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-27 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D20677#442559, @EricWF wrote:

> I have an issue with this change since it allows a libc++abi built without 
> exceptions to be used in a program compiled with them. I assert that this 
> should not be supported in any way.
>
> My personal preference would be to remove as much of the exception API from 
> the library when it's built without exceptions. This should cause link errors 
> if a program contains any code that throws. If this is not done it creates 
> bugs within code like `__terminate` as mentioned in an inline comment.
>
> I would like to see another revision of this patch that removes as much of 
> the exception API as possible. Looking at the symbols defined in `cxxabi.h` I 
> would say ever symbol in sections 2.4 and 2.5 should not longer be defined in 
> the library.


That sounds generally OK to me. The toolchain I'm working on (ARM Compiler 6) 
has an elaborate mechanism (based on build attributes) to select the correct 
variant of libraries. In other words, if any of your objects are compiled with 
exceptions, you are guaranteed to no select any of the no-exceptions library 
variants. This avoids the problem you mentioned altogether.

But I can see that this can be a problem for any other toolchain that does not 
have such a functionality, and a link-time error would be more suitable.

I'll re-spin a patch soon.

Thanks.

/ Asiri


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-27 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I have an issue with this change since it allows a libc++abi built without 
exceptions to be used in a program compiled with them. I assert that this 
should not be supported in any way.

My personal preference would be to remove as much of the exception API from the 
library when it's built without exceptions. This should cause link errors if a 
program contains any code that throws. If this is not done it creates bugs 
within code like `__terminate` as mentioned in an inline comment.

I would like to see another revision of this patch that removes as much of the 
exception API as possible. Looking at the symbols defined in `cxxabi.h` I would 
say ever symbol in sections 2.4 and 2.5 should not longer be defined in the 
library.



Comment at: src/cxa_handlers.cpp:62
@@ -61,3 +61,3 @@
 void
 __terminate(terminate_handler func) _NOEXCEPT
 {

If any part of your executable was compiled with exceptions on, and it sets a 
terminate handler that throws an exception this does the wrong thing.  I don't 
really like that although I admit that would certainly be an exceptional 
situation.

At minimum this requirement needs to be documented explicitly somewhere. Within 
the CMake option description seems fine for now.


Comment at: src/cxa_personality.cpp:1204
@@ -1203,2 +1203,3 @@
 }
+#ifndef _LIBCXXABI_NO_EXCEPTIONS
 try

This is yucky. We are in exception handling code and we are saying it has been 
built without exceptions. I understand this "gets libc++abi to compile" without 
exceptions but it doesn't really make sense.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-27 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

If you're really going to do this, you should probably empty out most of the 
routines in src/cxa_exception.cpp as well.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D20677#441598, @EricWF wrote:

> I want to take a look at this as well. I'll review it tomorrow.


Thanks! will wait until we have ironed out all the details, no hurry.

/ Asiri


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D20677#441407, @bcraig wrote:

> https://mentorembedded.github.io/cxx-abi/abi-eh.html mentions the functions, 
> but it doesn't really say what they are for.  The C++ standard mentions when 
> an exception of std::bad_cast and std::bad_typeid are thrown.  Put those two 
> documents together, and you get my earlier statements.  Granted, it's just a 
> well informed guess, but a guess I'm pretty confident in.
>
> Leaving those functions in should be harmless, other than the size of the 
> dead code.  There are also all the private type_info classes that are dead 
> weight if RTTI is turned off.
>
> While it may make sense to remove those functions, that's probably best left 
> for a different code review.


Thanks, added that to my arsenal of references :)


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Eric Fiselier via cfe-commits
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: mclow.lists.
EricWF added a comment.

Adding @mclow.lists to this as well.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

I want to take a look at this as well. I'll review it tomorrow.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM.  Probably want a "LGTM" from at least one other person though.

In http://reviews.llvm.org/D20677#441085, @rmaprath wrote:

> In http://reviews.llvm.org/D20677#441061, @jroelofs wrote:
>
> > This is the canonical reference for the Itanium ABI: 
> > https://mentorembedded.github.io/cxx-abi/abi.html
>
>
> I was indeed looking at this, but couldn't find those exact function 
> signatures (or something that looks like it). Perhaps it's covered there as a 
> more general concept. I'll have a read.


https://mentorembedded.github.io/cxx-abi/abi-eh.html mentions the functions, 
but it doesn't really say what they are for.  The C++ standard mentions when an 
exception of std::bad_cast and std::bad_typeid are thrown.  Put those two 
documents together, and you get my earlier statements.  Granted, it's just a 
well informed guess, but a guess I'm pretty confident in.

Leaving those functions in should be harmless, other than the size of the dead 
code.  There are also all the private type_info classes that are dead weight if 
RTTI is turned off.

While it may make sense to remove those functions, that's probably best left 
for a different code review.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

In http://reviews.llvm.org/D20677#441061, @jroelofs wrote:

> This is the canonical reference for the Itanium ABI: 
> https://mentorembedded.github.io/cxx-abi/abi.html


I was indeed looking at this, but couldn't find those exact function signatures 
(or something that looks like it). Perhaps it's covered there as a more general 
concept. I'll have a read.

Thanks!

/ Asiri


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Jonathan Roelofs via cfe-commits
jroelofs added a comment.

This is the canonical reference for the Itanium ABI: 
https://mentorembedded.github.io/cxx-abi/abi.html


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Asiri Rathnayake via cfe-commits
rmaprath marked an inline comment as done.


Comment at: src/cxa_aux_runtime.cpp:19-25
@@ -18,5 +18,9 @@
 extern "C" {
 _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
+#ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_cast();
+#else
+  std::terminate();
+#endif
 }
 

rmaprath wrote:
> I'm not very familiar with how RTTI works, I was simply getting rid of the 
> `throw` statements which get in the way of compiling with `-fno-exceptions`.
> 
> So, I presume these `__cxa_bad_xxx` calls are inserted by the compiler?
> 
> The tests `dynamic_cast_xxx` all seem to pass, which I found a bit weird 
> because I would've expected some of those to fail because of the 
> `std::terminate()`. Or are they not related to RTTI?
Thanks. I will try to get clang to generate these (btw, do you have a reference 
for those RTTI functions? I couldn't find much on the interwebs.

I suppose leaving these functions (which call `std::terminate()`) in the 
-fno-exceptions variant is not a problem?


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Ben Craig via cfe-commits
bcraig added inline comments.


Comment at: src/cxa_aux_runtime.cpp:19-24
@@ -18,4 +18,8 @@
 extern "C" {
 _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
+#ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_cast();
+#else
+  std::terminate();
+#endif
 }

bcraig wrote:
> So you're turning off exceptions, but leaving RTTI?  You might want to keep 
> some of the RTTI tests around too if that's the case.
_cxa_bad_cast should be inserted by the compiler.  It is called when a 
dynamic_cast to a reference type fails.
_cxa_bad_typeid should be inserted by the compiler.  It is called when typeid 
is used on a null pointer.

_cxa_throw_bad_array_new_length should probably stay put.  The most common 
reason for that to get hit is if sizeof(obj) * number_of_elts > SIZE_T_MAX.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Asiri Rathnayake via cfe-commits
rmaprath marked 2 inline comments as done.


Comment at: src/cxa_aux_runtime.cpp:19-20
@@ -18,3 +18,4 @@
 extern "C" {
 _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
+#ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_cast();

I'm not very familiar with how RTTI works, I was simply getting rid of the 
`throw` statements which get in the way of compiling with `-fno-exceptions`.

So, I presume these `__cxa_bad_xxx` calls are inserted by the compiler?

The tests `dynamic_cast_xxx` all seem to pass, which I found a bit weird 
because I would've expected some of those to fail because of the 
`std::terminate()`. Or are they not related to RTTI?


Comment at: src/cxa_new_delete.cpp:85-86
@@ -79,2 +84,4 @@
+#endif
 p = ::operator new(size);
+#ifndef _LIBCXXABI_NO_EXCEPTIONS
 }

I agree. I've update it to be inline with `new.cpp` from libcxx.

At least the users will have some method of recovery if we return null, calling 
`std::terminate()` would be a bit rude.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 58620.

http://reviews.llvm.org/D20677

Files:
  CMakeLists.txt
  src/cxa_aux_runtime.cpp
  src/cxa_handlers.cpp
  src/cxa_new_delete.cpp
  src/cxa_personality.cpp
  test/CMakeLists.txt
  test/backtrace_test.pass.cpp
  test/catch_array_01.pass.cpp
  test/catch_array_02.pass.cpp
  test/catch_class_01.pass.cpp
  test/catch_class_02.pass.cpp
  test/catch_class_03.pass.cpp
  test/catch_class_04.pass.cpp
  test/catch_const_pointer_nullptr.pass.cpp
  test/catch_function_01.pass.cpp
  test/catch_function_02.pass.cpp
  test/catch_in_noexcept.pass.cpp
  test/catch_member_data_pointer_01.pass.cpp
  test/catch_member_function_pointer_01.pass.cpp
  test/catch_member_pointer_nullptr.pass.cpp
  test/catch_multi_level_pointer.pass.cpp
  test/catch_pointer_nullptr.pass.cpp
  test/catch_pointer_reference.pass.cpp
  test/catch_ptr.pass.cpp
  test/catch_ptr_02.pass.cpp
  test/incomplete_type.sh.cpp
  test/inherited_exception.pass.cpp
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_aux_runtime.pass.cpp
  test/test_aux_runtime_op_array_new.pass.cpp
  test/test_guard.pass.cpp
  test/test_vector1.pass.cpp
  test/test_vector2.pass.cpp
  test/test_vector3.pass.cpp
  test/uncaught_exceptions.pass.cpp
  test/unwind_01.pass.cpp
  test/unwind_02.pass.cpp
  test/unwind_03.pass.cpp
  test/unwind_04.pass.cpp
  test/unwind_05.pass.cpp
  test/unwind_06.pass.cpp

Index: test/unwind_06.pass.cpp
===
--- test/unwind_06.pass.cpp
+++ test/unwind_06.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_05.pass.cpp
===
--- test/unwind_05.pass.cpp
+++ test/unwind_05.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_04.pass.cpp
===
--- test/unwind_04.pass.cpp
+++ test/unwind_04.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_03.pass.cpp
===
--- test/unwind_03.pass.cpp
+++ test/unwind_03.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/unwind_02.pass.cpp
===
--- test/unwind_02.pass.cpp
+++ test/unwind_02.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/unwind_01.pass.cpp
===
--- test/unwind_01.pass.cpp
+++ test/unwind_01.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 
 struct A
Index: test/uncaught_exceptions.pass.cpp
===
--- test/uncaught_exceptions.pass.cpp
+++ test/uncaught_exceptions.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include 
 #include 
 #include 
Index: test/test_vector3.pass.cpp
===
--- test/test_vector3.pass.cpp
+++ test/test_vector3.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector2.pass.cpp
===
--- test/test_vector2.pass.cpp
+++ test/test_vector2.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_vector1.pass.cpp
===
--- test/test_vector1.pass.cpp
+++ test/test_vector1.pass.cpp
@@ -7,6 +7,8 @@
 //
 //===--===//
 
+// UNSUPPORTED: libcxxabi-no-exceptions
+
 #include "cxxabi.h"
 
 #include 
Index: test/test_guard.pass.cpp
===
--- test/test_guard.pass.cpp
+++ test/test_guard.pass.cpp
@@ -41,6 +41,7 @@
 // When initialization 

Re: [PATCH] D20677: Make it possible to build a -fno-exceptions libc++abi variant.

2016-05-26 Thread Ben Craig via cfe-commits
bcraig added inline comments.


Comment at: CMakeLists.txt:359
@@ -350,2 +358,3 @@
 else()
-  add_subdirectory(test)
+  # libc++abi tests are mostly exceptions related. The only reason we want to
+  # build libc++abi without exceptions is to support the -fno-exceptions libc++

There's one area / test that I would still like to see when exceptions are off. 
 "magic" / thread safe static initialization has a test (test_guard.pass.cpp).  
I think it would be pretty easy to #if out the one sub-test that uses 
exceptions there.

There's also some demangling and backtracing tests, but I'm much less concerned 
with those.  If you go through the trouble to get any tests working with 
exceptions turned off, you might as well get those too.


Comment at: src/cxa_aux_runtime.cpp:19
@@ -18,2 +18,3 @@
 extern "C" {
 _LIBCXXABI_FUNC_VIS LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
+#ifndef _LIBCXXABI_NO_EXCEPTIONS

So you're turning off exceptions, but leaving RTTI?  You might want to keep 
some of the RTTI tests around too if that's the case.


Comment at: src/cxa_new_delete.cpp:85
@@ -79,1 +84,3 @@
+#endif
 p = ::operator new(size);
+#ifndef _LIBCXXABI_NO_EXCEPTIONS

Question:  Should "throwing" new call terminate on allocation failure, or is 
returning null from "throwing" new fine?

I'm leaning towards returning null, as I would rapidly grow tired of 
std::nothrow everywhere, but it does seem a bit dangerous.


http://reviews.llvm.org/D20677



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits