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]

[Patch Ping^2, C++] Move assemble_external call in cp/decl2.c.


This is a second ping for my C++ compiler patch to fix two libstdc++
test failures on IA64 HP-UX.  The original patch is at:

http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00174.html

I have attached the patch and comments from that email here and I am
cc'ing the libstdc++ list since this patch fixes two failures in that
testsuite, but the actual fix is to the compiler in cp/decl2.c.

Steve Ellcey
sje@cup.hp.com

--------

The C++ library tests 29_atomics/atomic/cons/default.cc and
29_atomics/atomic/cons/explicit_value.cc are failing on IA64 HP-UX with
undefined externals.  The problem is that declarations for a function
are put out and then we find out that we don't need that function and
never output a definition for it.  This causes a problem with the HP
linker because it doesn't like declarations without definiltioins, even
if there are no uses for that declaration.

This patch fixes the problem by moving the call to declare_external out
of mark_used and into cp_write_global_declarations.  Even if we call
mark_used with a function, we could later optimize away (or inline) the
use and not actually write out the function.  Once we are in
cp_write_global_declarations we are certain that we will write out the
function so that is where we should call assemble_external.

Tested on IA64 HP-UX with no regressions.

OK for checkin?


2008-10-06  Steve Ellcey  <sje@cup.hp.com>

	* decl2.c (mark_used): Move assemble_external from here
	(cp_write_global_declarations): to here.


Index: decl2.c
===================================================================
--- decl2.c	(revision 140899)
+++ decl2.c	(working copy)
@@ -3528,6 +3528,7 @@ cp_write_global_declarations (void)
 	      DECL_DEFER_OUTPUT (decl) = 0;
 	      /* Generate RTL for this function now that we know we
 		 need it.  */
+	      assemble_external (decl);
 	      expand_or_defer_fn (decl);
 	      /* If we're compiling -fsyntax-only pretend that this
 		 function has been written out so that we don't try to
@@ -3833,8 +3834,8 @@ mark_used (tree decl)
 
       note_vague_linkage_fn (decl);
     }
-
-  assemble_external (decl);
+  else
+    assemble_external (decl);
 
   /* Is it a synthesized method that needs to be synthesized?  */
   if (TREE_CODE (decl) == FUNCTION_DECL


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