aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>2011-08-18 14:47:46 +0000
committerRainer Orth <ro@gcc.gnu.org>2011-08-18 14:47:46 +0000
commit5b880ea61c107da98ea87a5ffad4520445d60007 (patch)
tree15183626c4d31ca839660bc4750300b8ed0ef58d /gcc/config
parent901ebcdf97fefd24e464f98593bfa6dc741d4525 (diff)
downloadgcc-5b880ea61c107da98ea87a5ffad4520445d60007.zip
gcc-5b880ea61c107da98ea87a5ffad4520445d60007.tar.gz
gcc-5b880ea61c107da98ea87a5ffad4520445d60007.tar.bz2
Keep tm, div_t, ldiv_t, lconv mangling on Solaris (PR libstdc++-v3/1773)
Co-Authored-By: Marc Glisse <marc.glisse@normalesup.org> From-SVN: r177863
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/sol2-cxx.c64
-rw-r--r--gcc/config/sol2-protos.h12
-rw-r--r--gcc/config/sol2-stubs.c33
-rw-r--r--gcc/config/sol2.h2
-rw-r--r--gcc/config/t-sol216
5 files changed, 120 insertions, 7 deletions
diff --git a/gcc/config/sol2-cxx.c b/gcc/config/sol2-cxx.c
new file mode 100644
index 0000000..4c89d0d
--- /dev/null
+++ b/gcc/config/sol2-cxx.c
@@ -0,0 +1,64 @@
+/* C++ specific Solaris system support.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "cp/cp-tree.h"
+#include "tm.h"
+#include "tm_p.h"
+
+/* Before GCC 4.7, g++ defined __cplusplus 1 to avoid coping with the C++98
+ overloads in Solaris system headers. Since this was fixed, 4 structure
+ types would move to namespace std, breaking the Solaris libstdc++ ABI.
+ To avoid this, we forcefully keep those types in the global namespace.
+ This can be removed once the next major version of libstdc++ is
+ released. */
+
+/* Cache the identifiers of the affected types to speed up lookup. */
+#define NUM_FGID 4
+static GTY(()) tree force_global_identifiers[NUM_FGID];
+
+/* Check if DECL is one of the affected types and move it to the global
+ namespace if so. */
+tree
+solaris_cxx_decl_mangling_context (const_tree decl)
+{
+ static bool init = false;
+ int i = 0;
+
+ if (!init)
+ {
+ force_global_identifiers[i++] = get_identifier ("div_t");
+ force_global_identifiers[i++] = get_identifier ("ldiv_t");
+ force_global_identifiers[i++] = get_identifier ("lconv");
+ force_global_identifiers[i++] = get_identifier ("tm");
+ init = true;
+ }
+
+ if (!(DECL_P (decl) && DECL_NAMESPACE_STD_P (CP_DECL_CONTEXT (decl))))
+ return NULL_TREE;
+
+ for (i = 0; i < NUM_FGID; i++)
+ if (DECL_NAME (decl) == force_global_identifiers[i])
+ return global_namespace;
+
+ return NULL_TREE;
+}
diff --git a/gcc/config/sol2-protos.h b/gcc/config/sol2-protos.h
index dae3e13..9f31ce3 100644
--- a/gcc/config/sol2-protos.h
+++ b/gcc/config/sol2-protos.h
@@ -18,9 +18,15 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-extern void solaris_insert_attributes (tree, tree *);
-extern void solaris_register_pragmas (void);
-extern void solaris_output_init_fini (FILE *, tree);
+/* In sol2.c. */
extern void solaris_assemble_visibility (tree, int);
extern void solaris_elf_asm_comdat_section (const char *, unsigned int, tree);
extern void solaris_file_end (void);
+extern void solaris_insert_attributes (tree, tree *);
+extern void solaris_output_init_fini (FILE *, tree);
+
+/* In sol2-c.c. */
+extern void solaris_register_pragmas (void);
+
+/* In sol2-cxx.c. */
+extern tree solaris_cxx_decl_mangling_context (const_tree);
diff --git a/gcc/config/sol2-stubs.c b/gcc/config/sol2-stubs.c
new file mode 100644
index 0000000..94cab49
--- /dev/null
+++ b/gcc/config/sol2-stubs.c
@@ -0,0 +1,33 @@
+/* Stubs for C++ specific Solaris system support.
+ Copyright (C) 2011 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "tm.h"
+#include "tm_p.h"
+
+/* Stub implemenation of TARGET_CXX_DECL_MANGLING_CONTEXT for non-C++
+ frontends. */
+tree
+solaris_cxx_decl_mangling_context (const_tree decl ATTRIBUTE_UNUSED)
+{
+ return NULL_TREE;
+}
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
index 99f0382..b265f15 100644
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -217,6 +217,8 @@ along with GCC; see the file COPYING3. If not see
/* Allow macro expansion in #pragma pack. */
#define HANDLE_PRAGMA_PACK_WITH_EXPANSION
+#define TARGET_CXX_DECL_MANGLING_CONTEXT solaris_cxx_decl_mangling_context
+
/* Solaris/x86 as and gas support unquoted section names. */
#define SECTION_NAME_FORMAT "%s"
diff --git a/gcc/config/t-sol2 b/gcc/config/t-sol2
index f53da4d..f915622 100644
--- a/gcc/config/t-sol2
+++ b/gcc/config/t-sol2
@@ -20,14 +20,22 @@
sol2-c.o: $(srcdir)/config/sol2-c.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
tree.h c-family/c-format.h $(C_PRAGMA_H) $(C_COMMON_H) $(CPPLIB_H) \
intl.h $(TM_H) $(TM_P_H)
- $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
- $(srcdir)/config/sol2-c.c
+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+
+# Solaris-specific C++ mangling.
+sol2-cxx.o: $(srcdir)/config/sol2-cxx.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
+ tree.h cp/cp-tree.h $(TM_H) $(TM_P_H)
+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+
+# Corresponding stub routines.
+sol2-stubs.o: $(srcdir)/config/sol2-stubs.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
+ tree.h $(TM_H) $(TM_P_H)
+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
# Solaris-specific attributes
sol2.o: $(srcdir)/config/sol2.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
tree.h output.h $(TM_H) $(TARGET_H) $(TM_P_H) $(GGC_H)
- $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
- $(srcdir)/config/sol2.c
+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
# This is required by gcc/ada/gcc-interface/Makefile.in.
TARGET_LIBGCC2_CFLAGS = -fPIC