From 81c82a68dc3bb09bd3b5b4101ed9737814023f1a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 10 Jul 2012 14:54:29 +0000 Subject: [PATCH] PR gold/14309 * configure.ac: Test whether std::tr1::hash works. * gold.h: Add a specialization for std::tr1::hash if needed. * output.h (class Output_fill): Add virtual destructor. * configure, config.in: Rebuild. --- gold/ChangeLog | 10 ++++++++++ gold/config.in | 3 +++ gold/configure | 33 +++++++++++++++++++++++++++++++++ gold/configure.ac | 19 +++++++++++++++++++ gold/gold.h | 16 ++++++++++++++++ gold/output.h | 4 ++++ 6 files changed, 85 insertions(+) diff --git a/gold/ChangeLog b/gold/ChangeLog index 601753025ce..33317bff893 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,13 @@ +2012-07-10 Dodji Seketeli + Ian Lance Taylor + + PR gold/14309 + * configure.ac: Test whether std::tr1::hash works. + * gold.h: Add a specialization for std::tr1::hash if + needed. + * output.h (class Output_fill): Add virtual destructor. + * configure, config.in: Rebuild. + 2012-06-22 Roland McGrath * layout.cc (finalize): Define __ehdr_start symbol if applicable. diff --git a/gold/config.in b/gold/config.in index ff4d5ee5b9e..3edc0d684f6 100644 --- a/gold/config.in +++ b/gold/config.in @@ -169,6 +169,9 @@ /* Define to 1 if you have the `times' function. */ #undef HAVE_TIMES +/* Define if std::tr1::hash is usable */ +#undef HAVE_TR1_HASH_OFF_T + /* Define to 1 if you have the header file. */ #undef HAVE_TR1_UNORDERED_MAP diff --git a/gold/configure b/gold/configure index b84234a8483..b9967ae89de 100755 --- a/gold/configure +++ b/gold/configure @@ -7266,6 +7266,39 @@ $as_echo "#define HAVE_TR1_UNORDERED_MAP_REHASH 1" >>confdefs.h 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. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether std::tr1::hash is defined" >&5 +$as_echo_n "checking whether std::tr1::hash is defined... " >&6; } +if test "${gold_cv_hash_off_t+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + CXXFLAGS_hold=$CXXFLAGS +CXXFLAGS="$CXXFLAGS $LFS_CFLAGS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +std::tr1::hash h; + +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + gold_cv_hash_off_t=yes +else + gold_cv_hash_off_t=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CXXFLAGS=$CFLAGS_hold +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gold_cv_hash_off_t" >&5 +$as_echo "$gold_cv_hash_off_t" >&6; } +if test "$gold_cv_hash_off_t" = "yes"; then + +$as_echo "#define HAVE_TR1_HASH_OFF_T 1" >>confdefs.h + +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. diff --git a/gold/configure.ac b/gold/configure.ac index fdea6291edb..5e3dc0601c0 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -515,6 +515,25 @@ if test "$gold_cv_unordered_map_rehash" = "yes"; then [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 is defined], +[gold_cv_hash_off_t], +[CXXFLAGS_hold=$CXXFLAGS +CXXFLAGS="$CXXFLAGS $LFS_CFLAGS" +AC_COMPILE_IFELSE([ +#include +#include +std::tr1::hash 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 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. diff --git a/gold/gold.h b/gold/gold.h index 4258d5543d7..9aa7cf3506c 100644 --- a/gold/gold.h +++ b/gold/gold.h @@ -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 : public std::unary_function +{ + std::size_t + operator()(off_t val) const + { return static_cast(val); } +}; +} } // Close namespaces. +#endif // !defined(HAVE_TR1_HASH_OFF_T) + #elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET) #include diff --git a/gold/output.h b/gold/output.h index 3796e9120ce..170f0ff890e 100644 --- a/gold/output.h +++ b/gold/output.h @@ -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 -- 2.30.2