This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix visibility of constructors/destructors with -fwhole-program


> This patch fixes PR middle-end/41674.  With -fwhole-program, the
> constructor _GLOBAL__I_65535_0_main has its public flag turned off
> by function_and_variable_visibility and thereby made local.  However,
> these symbols need to be global for collect2 to arrange to call them.
> 
> Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

Here is take 2.  The first version was deemed overkill and Richard suggested
using DECL_PRESERVE_P.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11 with no regressions.

Ok for trunk?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2010-01-02  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR middle-end/41674
	* cgraphunit.c (cgraph_build_static_cdtor): If target doesn't have
	cdtors, set DECL_PRESERVE_P.
	* ipa.c (cgraph_externally_visible_p): Return true if declaration
	should be preseved.

Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 157617)
+++ cgraphunit.c	(working copy)
@@ -1946,7 +1946,11 @@
   DECL_ARTIFICIAL (decl) = 1;
   DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
   DECL_SAVED_TREE (decl) = body;
-  TREE_PUBLIC (decl) = ! targetm.have_ctors_dtors;
+  if (!targetm.have_ctors_dtors)
+    {
+      TREE_PUBLIC (decl) = 1;
+      DECL_PRESERVE_P (decl) = 1;
+    }
   DECL_UNINLINABLE (decl) = 1;
 
   DECL_INITIAL (decl) = make_node (BLOCK);
Index: ipa.c
===================================================================
--- ipa.c	(revision 157617)
+++ ipa.c	(working copy)
@@ -317,6 +317,8 @@
     return false;
   if (!whole_program)
     return true;
+  if (DECL_PRESERVE_P (node->decl))
+    return true;
   /* COMDAT functions must be shared only if they have address taken,
      otherwise we can produce our own private implementation with
      -fwhole-program.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]