From 60d9461b2b6bfbaffffa0415e58f1c685edad57d Mon Sep 17 00:00:00 2001 From: geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Tue, 9 Jan 2007 07:48:38 +0000 Subject: [PATCH] Index: ChangeLog 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120611 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++++ gcc/config/darwin.h | 4 ++++ gcc/cp/ChangeLog | 7 +++++++ gcc/cp/Make-lang.in | 2 +- gcc/cp/rtti.c | 8 ++++++-- gcc/doc/tm.texi | 6 ++++++ gcc/target-def.h | 5 +++++ gcc/target.h | 4 ++++ gcc/testsuite/ChangeLog | 4 ++++ .../g++.dg/rtti/darwin-builtin-linkage.C | 20 +++++++++++++++++++ 10 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/rtti/darwin-builtin-linkage.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7e8fc995d40c..caeff6bf0766 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +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. diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index fb885ad5ac0d..926197c027f3 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -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 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d41988f0709c..f97f7d981e69 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in index db095cea2cf2..b16bcc1849ce 100644 --- a/gcc/cp/Make-lang.in +++ b/gcc/cp/Make-lang.in @@ -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) \ diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index f185cc5c6a9d..8549ec07f117 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -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; diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 0896ab8db173..9e8ad0e99dfd 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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} diff --git a/gcc/target-def.h b/gcc/target-def.h index 8cb5d269278c..8f7abd8a2963 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -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 \ diff --git a/gcc/target.h b/gcc/target.h index b59f561657f9..e86ba2167e2e 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 538c84da7255..4d097ea1e017 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 000000000000..6db161169d8f --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/darwin-builtin-linkage.C @@ -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 () +{} + +} -- GitLab