Index: ChangeLog
authorGeoffrey Keating <geoffk@apple.com>
Tue, 9 Jan 2007 07:48:38 +0000 (07:48 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Tue, 9 Jan 2007 07:48:38 +0000 (07:48 +0000)
2007-01-08  Geoffrey Keating  <geoffk@apple.com>

* target.h (struct gcc_target): New field library_rtti_comdat.
* target-def.h (TARGET_CXX_LIBRARY_RTTI_COMDAT): New.
(TARGET_CXX): Add TARGET_CXX_LIBRARY_RTTI_COMDAT.
* doc/tm.texi (C++ ABI): Document TARGET_CXX_LIBRARY_RTTI_COMDAT.
* config/darwin.h (TARGET_CXX_LIBRARY_RTTI_COMDAT): Define.

Index: testsuite/ChangeLog
2007-01-08  Geoffrey Keating  <geoffk@apple.com>

* g++.dg/rtti/darwin-builtin-linkage.C: New.

Index: cp/ChangeLog
2007-01-08  Geoffrey Keating  <geoffk@apple.com>

* rtti.c: Include target.h.
(emit_support_tinfos): If ! targetm.cxx.library_rtti_comdat (),
don't emit typeinfo for fundamental types as weak.
* Make-lang.in (cp/rtti.o): Update and correct dependencies.

From-SVN: r120611

gcc/ChangeLog
gcc/config/darwin.h
gcc/cp/ChangeLog
gcc/cp/Make-lang.in
gcc/cp/rtti.c
gcc/doc/tm.texi
gcc/target-def.h
gcc/target.h
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/rtti/darwin-builtin-linkage.C [new file with mode: 0644]

index 7e8fc99..caeff6b 100644 (file)
@@ -1,5 +1,13 @@
 2007-01-08  Geoffrey Keating  <geoffk@apple.com>
 
+       * target.h (struct gcc_target): New field library_rtti_comdat.
+       * target-def.h (TARGET_CXX_LIBRARY_RTTI_COMDAT): New.
+       (TARGET_CXX): Add TARGET_CXX_LIBRARY_RTTI_COMDAT.
+       * doc/tm.texi (C++ ABI): Document TARGET_CXX_LIBRARY_RTTI_COMDAT.
+       * config/darwin.h (TARGET_CXX_LIBRARY_RTTI_COMDAT): Define.
+
+2007-01-08  Geoffrey Keating  <geoffk@apple.com>
+
        * doc/invoke.texi (Optimize Options): Correct description of -O0.
 
 2007-01-08  Richard Guenther  <rguenther@suse.de>
index fb885ad..926197c 100644 (file)
@@ -482,6 +482,10 @@ extern GTY(()) int darwin_ms_struct;
    with names, so it's safe to make the class data not comdat.  */
 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_false
 
+/* For efficiency, on Darwin the RTTI information that is always
+   emitted in the standard C++ library should not be COMDAT.  */
+#define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_false
+
 /* We make exception information linkonce. */
 #undef TARGET_USES_WEAK_UNWIND_INFO
 #define TARGET_USES_WEAK_UNWIND_INFO 1
index d41988f..f97f7d9 100644 (file)
@@ -1,3 +1,10 @@
+2007-01-08  Geoffrey Keating  <geoffk@apple.com>
+
+       * rtti.c: Include target.h.
+       (emit_support_tinfos): If ! targetm.cxx.library_rtti_comdat (),
+       don't emit typeinfo for fundamental types as weak.
+       * Make-lang.in (cp/rtti.o): Update and correct dependencies.
+
 2007-01-08  Richard Guenther  <rguenther@suse.de>
 
        * cvt.c (cp_convert_to_pointer): Use build_int_cst_type.
index db095ce..b16bcc1 100644 (file)
@@ -265,7 +265,7 @@ cp/tree.o: cp/tree.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H) \
   $(TARGET_H) debug.h
 cp/ptree.o: cp/ptree.c $(CXX_TREE_H) $(TM_H)
 cp/rtti.o: cp/rtti.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h convert.h \
-  gt-cp-rtti.h
+  $(TARGET_H) gt-cp-rtti.h
 cp/except.o: cp/except.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) $(RTL_H) except.h \
   toplev.h cp/cfns.h $(EXPR_H) libfuncs.h $(TREE_INLINE_H) $(TARGET_H)
 cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_H) $(RTL_H) $(FLAGS_H) $(EXPR_H) \
index f185cc5..8549ec0 100644 (file)
@@ -32,6 +32,7 @@ Boston, MA 02110-1301, USA.  */
 #include "assert.h"
 #include "toplev.h"
 #include "convert.h"
+#include "target.h"
 
 /* C++ returns type information to the user in struct type_info
    objects. We also use type information to implement dynamic_cast and
@@ -1429,8 +1430,11 @@ emit_support_tinfos (void)
             comdat_linkage for details.)  Since we want these objects
             to have external linkage so that copies do not have to be
             emitted in code outside the runtime library, we make them
-            non-COMDAT here.  */
-         if (!flag_weak)
+            non-COMDAT here.  
+
+            It might also not be necessary to follow this detail of the
+            ABI.  */
+         if (!flag_weak || ! targetm.cxx.library_rtti_comdat ())
            {
              gcc_assert (TREE_PUBLIC (tinfo) && !DECL_COMDAT (tinfo));
              DECL_INTERFACE_KNOWN (tinfo) = 1;
index 0896ab8..9e8ad0e 100644 (file)
@@ -9080,6 +9080,12 @@ classes whose virtual table will be emitted in only one translation
 unit will not be COMDAT.
 @end deftypefn
 
+@deftypefn {Target Hook} bool TARGET_CXX_LIBRARY_RTTI_COMDAT (void)
+This hook returns true (the default) if the RTTI information for
+the basic types which is defined in the C++ runtime should always
+be COMDAT, false if it should not be COMDAT.
+@end deftypefn
+
 @deftypefn {Target Hook} bool TARGET_CXX_USE_AEABI_ATEXIT (void)
 This hook returns true if @code{__aeabi_atexit} (as defined by the ARM EABI)
 should be used to register static destructors when @option{-fuse-cxa-atexit}
index 8cb5d26..8f7abd8 100644 (file)
@@ -596,6 +596,10 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 #define TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT hook_bool_void_true
 #endif
 
+#ifndef TARGET_CXX_LIBRARY_RTTI_COMDAT
+#define TARGET_CXX_LIBRARY_RTTI_COMDAT hook_bool_void_true
+#endif
+
 #ifndef TARGET_CXX_USE_AEABI_ATEXIT
 #define TARGET_CXX_USE_AEABI_ATEXIT hook_bool_void_false
 #endif
@@ -619,6 +623,7 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
     TARGET_CXX_KEY_METHOD_MAY_BE_INLINE,       \
     TARGET_CXX_DETERMINE_CLASS_DATA_VISIBILITY,        \
     TARGET_CXX_CLASS_DATA_ALWAYS_COMDAT,        \
+    TARGET_CXX_LIBRARY_RTTI_COMDAT,            \
     TARGET_CXX_USE_AEABI_ATEXIT,               \
     TARGET_CXX_USE_ATEXIT_FOR_CXA_ATEXIT,      \
     TARGET_CXX_ADJUST_CLASS_AT_DEFINITION      \
index b59f561..e86ba21 100644 (file)
@@ -808,6 +808,10 @@ struct gcc_target
        class data for classes whose virtual table will be emitted in
        only one translation unit will not be COMDAT.  */
     bool (*class_data_always_comdat) (void);
+    /* Returns true (the default) if the RTTI for the basic types,
+       which is always defined in the C++ runtime, should be COMDAT;
+       false if it should not be COMDAT.  */
+    bool (*library_rtti_comdat) (void);
     /* Returns true if __aeabi_atexit should be used to register static
        destructors.  */
     bool (*use_aeabi_atexit) (void);
index 538c84d..4d097ea 100644 (file)
@@ -1,3 +1,7 @@
+2007-01-08  Geoffrey Keating  <geoffk@apple.com>
+
+       * g++.dg/rtti/darwin-builtin-linkage.C: New.
+
 2007-01-08  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        * gcc.target/spu/intrinsics-1.c: Remove xfail.
diff --git a/gcc/testsuite/g++.dg/rtti/darwin-builtin-linkage.C b/gcc/testsuite/g++.dg/rtti/darwin-builtin-linkage.C
new file mode 100644 (file)
index 0000000..6db1611
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-final { scan-assembler-not "\\.weak_definition __ZTI" } } */
+
+/* Verify that none of the type_info structures for the fundamental
+   types are emitted as weak on Darwin.  */
+
+#include <cxxabi.h>
+
+namespace __cxxabiv1 {
+
+using namespace std;
+
+// This has special meaning to the compiler, and will cause it
+// to emit the type_info structures for the fundamental types which are
+// mandated to exist in the runtime.
+__fundamental_type_info::
+~__fundamental_type_info ()
+{}
+}