[build] Fix Solaris gty handling (PR target/84379)

Message ID yddin7vpr8m.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show
Series
  • [build] Fix Solaris gty handling (PR target/84379)
Related show

Commit Message

Rainer Orth May 10, 2018, 1:36 p.m.
As described in the PR, there are a couple of jit testsuite failures on
Solaris when using /bin/as.  The errors point to GC issues and indeed,
gcc/config/sol2.c lacked GTY markup.  This patch fixes that, following
what darwin.c does for machopic_indirections.  I confess I have no idea
why I had to change the code the way I did except for the fact that it
works.  While formally I don't need approval, it would be nice if
someone in the know could have a look.

Bootstrappedn without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11 with as and gas, with and without jit.

	Rainer

Comments

Eric Botcazou May 10, 2018, 5:34 p.m. | #1
> As described in the PR, there are a couple of jit testsuite failures on
> Solaris when using /bin/as.  The errors point to GC issues and indeed,
> gcc/config/sol2.c lacked GTY markup.  This patch fixes that, following
> what darwin.c does for machopic_indirections.  I confess I have no idea
> why I had to change the code the way I did except for the fact that it
> works.  While formally I don't need approval, it would be nice if
> someone in the know could have a look.

The net effect of the patch is to block GC for the DECLs registered by calls 
to solaris_elf_asm_comdat_section, that is to say, the mere fact of passing 
these DECLs to the function ensures that they will be kept.

This obviously fixes the GC failures described in PR jit/84288.  However, this 
also means that, even if the DECLs could otherwise be collected, they won't be 
anymore once they are passed to solaris_elf_asm_comdat_section.

This may be the expected behavior or may be deemed good enough.  However, you 
may want to implement a cache-like behavior instead, where the DECLs passed to 
solaris_elf_asm_comdat_section are not automatically kept, but instead only 
the slots of the hash table are kept if their associated DECL is.  See the 
documentation of ggc_cache_remove in hash-table.h for further details.

Patch

# HG changeset patch
# Parent  2c72579b3945b50373c09b9c93a37f00d94eee79
Fix Solaris gty handling  (PR target/84379)

diff --git a/gcc/config.gcc b/gcc/config.gcc
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -880,6 +880,7 @@  case ${target} in
   fi
   tm_p_file="${tm_p_file} sol2-protos.h"
   tmake_file="${tmake_file} t-sol2 t-slibgcc"
+  target_gtfiles="$target_gtfiles \$(srcdir)/config/sol2.c"
   c_target_objs="${c_target_objs} sol2-c.o"
   cxx_target_objs="${cxx_target_objs} sol2-c.o sol2-cxx.o"
   extra_objs="${extra_objs} sol2.o sol2-stubs.o"
diff --git a/gcc/config/sol2.c b/gcc/config/sol2.c
--- a/gcc/config/sol2.c
+++ b/gcc/config/sol2.c
@@ -163,7 +163,7 @@  solaris_assemble_visibility (tree decl, 
 
 /* Group section information entry stored in solaris_comdat_htab.  */
 
-typedef struct comdat_entry
+typedef struct GTY((for_user)) comdat_entry
 {
   const char *name;
   unsigned int flags;
@@ -173,11 +173,10 @@  typedef struct comdat_entry
 
 /* Helpers for maintaining solaris_comdat_htab.  */
 
-struct comdat_entry_hasher : nofree_ptr_hash <comdat_entry>
+struct comdat_entry_hasher : ggc_ptr_hash <comdat_entry>
 {
   static inline hashval_t hash (const comdat_entry *);
   static inline bool equal (const comdat_entry *, const comdat_entry *);
-  static inline void remove (comdat_entry *);
 };
 
 inline hashval_t
@@ -195,7 +194,7 @@  comdat_entry_hasher::equal (const comdat
 
 /* Hash table of group signature symbols.  */
 
-static hash_table<comdat_entry_hasher> *solaris_comdat_htab;
+static GTY (()) hash_table<comdat_entry_hasher> *solaris_comdat_htab;
 
 /* Output assembly to switch to COMDAT group section NAME with attributes
    FLAGS and group signature symbol DECL, using Sun as syntax.  */
@@ -237,14 +236,14 @@  solaris_elf_asm_comdat_section (const ch
      remember the signature symbols and emit those not marked
      TREE_SYMBOL_REFERENCED in solaris_file_end.  */
   if (!solaris_comdat_htab)
-    solaris_comdat_htab = new hash_table<comdat_entry_hasher> (37);
+    solaris_comdat_htab = hash_table<comdat_entry_hasher>::create_ggc (37);
 
   entry.sig = signature;
   slot = solaris_comdat_htab->find_slot (&entry, INSERT);
 
   if (*slot == NULL)
     {
-      *slot = XCNEW (comdat_entry);
+      *slot = ggc_alloc<comdat_entry> ();
       /* Remember fragmented section name.  */
       (*slot)->name = section;
       /* Emit as regular section, .group declaration has already been done.  */
@@ -299,3 +298,5 @@  solaris_override_options (void)
   if (!HAVE_LD_EH_FRAME_CIEV3 && !global_options_set.x_dwarf_version)
     dwarf_version = 2;
 }
+
+#include "gt-sol2.h"