public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Patch committed: Let gold build with GCC 4.1.3
@ 2012-07-10 14:54 iant
  0 siblings, 0 replies; only message in thread
From: iant @ 2012-07-10 14:54 UTC (permalink / raw)
  To: binutils

This patch to gold lets it build with GCC 4.1.3 on 32-bit systems that
use a 64-bit off_t type.  This is based on a patch attached to PR
14309 by Dodji Seketeli.  Committed to mainline.

Ian


2012-07-10  Dodji Seketeli  <dodji@redhat.com>
	    Ian Lance Taylor  <iant@google.com>

	PR gold/14309
	* configure.ac: Test whether std::tr1::hash<off_t> works.
	* gold.h: Add a specialization for std::tr1::hash<off_t> if
	needed.
	* output.h (class Output_fill): Add virtual destructor.
	* configure, config.in: Rebuild.


Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gold/configure.ac,v
retrieving revision 1.74
diff -u -p -r1.74 configure.ac
--- configure.ac	6 Jun 2012 22:12:47 -0000	1.74
+++ configure.ac	10 Jul 2012 14:46:17 -0000
@@ -515,6 +515,25 @@ if test "$gold_cv_unordered_map_rehash" 
 	    [Define if ::std::tr1::unordered_map::rehash is usable])
 fi
 
+# Use of tr1/unordered_map with off_t as a key is not supported on GCC
+# 4.1.xx when compiling in 32-bit mode with a 64-bit off_t type.
+AC_CACHE_CHECK([whether std::tr1::hash<off_t> is defined],
+[gold_cv_hash_off_t],
+[CXXFLAGS_hold=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $LFS_CFLAGS"
+AC_COMPILE_IFELSE([
+#include <sys/types.h>
+#include <tr1/unordered_map>
+std::tr1::hash<off_t> h;
+],
+[gold_cv_hash_off_t=yes],
+[gold_cv_hash_off_t=no])
+CXXFLAGS=$CFLAGS_hold])
+if test "$gold_cv_hash_off_t" = "yes"; then
+   AC_DEFINE(HAVE_TR1_HASH_OFF_T, 1,
+	     [Define if std::tr1::hash<off_t> is usable])
+fi
+
 # gcc 4.3.0 doesn't recognize the printf attribute on a template
 # function.  Check for that.  This is gcc bug 35546.  This test can
 # probably be removed after the bug has been fixed for a while.
Index: gold.h
===================================================================
RCS file: /cvs/src/src/gold/gold.h,v
retrieving revision 1.48
diff -u -p -r1.48 gold.h
--- gold.h	6 Jun 2012 07:49:26 -0000	1.48
+++ gold.h	10 Jul 2012 14:46:17 -0000
@@ -80,6 +80,22 @@
 
 #define reserve_unordered_map(map, n) ((map)->rehash(n))
 
+#ifndef HAVE_TR1_HASH_OFF_T
+// The library does not support hashes of off_t values.  Add support
+// here.  This is likely to be specific to libstdc++.  This issue
+// arises with GCC 4.1.x when compiling in 32-bit mode with a 64-bit
+// off_t type.
+namespace std { namespace tr1 {
+template<>
+struct hash<off_t> : public std::unary_function<off_t, std::size_t>
+{
+  std::size_t
+  operator()(off_t val) const
+  { return static_cast<std::size_t>(val); }
+};
+} } // Close namespaces.
+#endif // !defined(HAVE_TR1_HASH_OFF_T)
+
 #elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
 
 #include <ext/hash_map>
Index: output.h
===================================================================
RCS file: /cvs/src/src/gold/output.h,v
retrieving revision 1.134
diff -u -p -r1.134 output.h
--- output.h	17 Apr 2012 01:50:39 -0000	1.134
+++ output.h	10 Jul 2012 14:46:17 -0000
@@ -2819,6 +2819,10 @@ class Output_fill
     : is_big_endian_(parameters->target().is_big_endian())
   { }
 
+  virtual
+  ~Output_fill()
+  { }
+
   // Return the smallest size chunk of free space that can be
   // filled with a dummy compilation unit.
   size_t

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-10 14:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-10 14:54 Patch committed: Let gold build with GCC 4.1.3 iant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).