This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH] Fix gnu.ver, fix std::tr1::hash<long double> on {ppc,s390,sparc,alpha}*-linux
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Benjamin Kosnik <bkoz at redhat dot com>, Paolo Carlini <pcarlini at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Fri, 29 Feb 2008 06:48:50 -0500
- Subject: [PATCH] Fix gnu.ver, fix std::tr1::hash<long double> on {ppc,s390,sparc,alpha}*-linux
- References: <20080228145915.72def41a@wabash.artheist.org> <20080229100826.GH24887@devserv.devel.redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Feb 29, 2008 at 05:08:26AM -0500, Jakub Jelinek wrote:
> Unfortunately, while looking at this, I've found another ABI issue:
> _ZNKSt3tr14hashI[eg]EclE[eg];
> On ppc*-linux/sparc*-linux/alpha*-linux/s390*-linux we still allow
> configuring gcc without --with-long-double-128, in fact with older glibc's
> that's even the default, and we still support -mlong-double-64 complication
> even on systems which default to 128-bit long double.
> As std::tr1::hash<long double>::operator()(long double) const
> is newly exported from libstdc++, it really should be exported as:
> _ZNKSt3tr14hashIgEclEg@@GLIBCXX_LDBL_3.4.10
> and
> _ZNKSt3tr14hashIeEclEe@@GLIBCXX_3.4.10
> Will work on a patch.
> BTW, _ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIgEERS2_T_ should
> have been exported at @@GLIBCXX_LDBL_3.4.9 rather than at
> @@GLIBCXX_LDBL_3.4.7, unfortunately 4.2 released with that, so it is too
> late to cure. But it is not as big deal as this _ZNKSt3tr14hashIgEclEg.
The following updated patch seems to cure it.
Regtested on ppc-linux, additionally tested with
#include <tr1/functional>
#include <iostream>
int
main (void)
{
std::tr1::hash <long double> h;
size_t a = size_t (h (3.141592653L));
size_t b = size_t (h (3.141592653E31L));
std::cout << a << " " << b << std::endl;
}
compiled both using default options and with -mlong-double-64, executed
against 4.3 libstdc++ with this patch as well as vanilla 4.3 libstdc++
from gcc build configured --without-long-double-128 (obviously the
-mlong-double-64 compiled program only).
Ok for 4.3?
For the trunk, different changes are needed:
1) move _ZNKSt4hash* exports to GLIBCXX_3.4.11, similarly system_error etc.
2) _ZNKSt4hashI[eg]EclE[eg] needs to be handled similarly as
_ZNKSt3tr14hashI[eg]EclE[eg] in this patch, though perhaps to avoid
introducing compatibility-ldbl-0x.cc we could just use an alias
as _ZNKSt3tr14hashIeEclEe and _ZNKSt4hashIeEclEe are identical
In any case, _ZNKSt4hashIgEclEg should be exported as
GLIBCXX_LDBL_3.4.11.
BTW, do the changes from yesterday mean that -std=gnu++0x compiled
#include <functional>
#include <iostream>
int
main (void)
{
std::hash <long double> h;
size_t a = size_t (h (3.141592653L));
size_t b = size_t (h (3.141592653E31L));
std::cout << a << " " << b << std::endl;
}
will not link?
2008-02-29 Jakub Jelinek <jakub@redhat.com>
* config/abi/pre/gnu.ver: Remove std::hash exports. Remove
_ZNKSt3tr14hashIgEclEg@@GLIBCXX_3.4.10 export.
* config/os/gnu-linux/ldbl-extra.ver: Export
_ZNKSt3tr14hashIgEclEg@@GLIBCXX_LDBL_3.4.10.
* src/hash.cc: Only define long double hash specialization if
_GLIBCXX_LONG_DOUBLE_COMPAT_IMPL is defined.
* src/compatibility-ldbl.cc: Include "hash.cc".
(_GLIBCXX_LONG_DOUBLE_COMPAT_IMPL): Define.
* testsuite/util/testsuite_abi.cc (check_version): Support
GLIBCXX_LDBL_3.4.10.
--- libstdc++-v3/config/abi/pre/gnu.ver.jj 2008-02-29 10:33:11.000000000 +0100
+++ libstdc++-v3/config/abi/pre/gnu.ver 2008-02-29 11:11:58.000000000 +0100
@@ -757,14 +757,7 @@ GLIBCXX_3.4.10 {
_ZNKSt3tr14hashIRKSsEclES2_;
_ZNKSt3tr14hashISbIwSt11char_traitsIwESaIwEEEclES4_;
_ZNKSt3tr14hashISsEclESs;
- _ZNKSt3tr14hashI[eg]EclE[eg];
-
- _ZNKSt4hashIRKSbIwSt11char_traitsIwESaIwEEEclES5_;
- _ZNKSt4hashIRKSsEclES1_;
- _ZNKSt4hashISbIwSt11char_traitsIwESaIwEEEclES3_;
- _ZNKSt4hashISsEclESs;
- _ZNKSt4hashISt10error_codeEclES0_;
- _ZNKSt4hashI[eg]EclE[eg];
+ _ZNKSt3tr14hashIeEclEe;
_ZSt17__verify_grouping*;
--- libstdc++-v3/config/os/gnu-linux/ldbl-extra.ver.jj 2008-02-29 10:33:09.000000000 +0100
+++ libstdc++-v3/config/os/gnu-linux/ldbl-extra.ver 2008-02-29 11:13:48.000000000 +0100
@@ -19,6 +19,10 @@ GLIBCXX_LDBL_3.4.7 {
_ZNSt13basic_ostreamIwSt11char_traitsIwEE9_M_insertIgEERS2_T_;
} GLIBCXX_LDBL_3.4;
+GLIBCXX_LDBL_3.4.10 {
+ _ZNKSt3tr14hashIgEclEg;
+} GLIBCXX_LDBL_3.4.7;
+
CXXABI_LDBL_1.3 {
_ZT[IS]g;
_ZT[IS]Pg;
--- libstdc++-v3/src/hash.cc.jj 2008-02-29 10:31:51.000000000 +0100
+++ libstdc++-v3/src/hash.cc 2008-02-29 11:29:48.000000000 +0100
@@ -1,6 +1,6 @@
// std::hash and std::tr1::hash definitions -*- C++ -*-
-// Copyright (C) 2007 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2008 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
@@ -74,6 +74,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
return __result;
};
+#ifndef _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
template<>
size_t
hash<string>::operator()(string __s) const
@@ -101,6 +102,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
return _Fnv_hash<>::hash(__p, __s.length() * sizeof(wchar_t));
}
#endif
+#endif
_GLIBCXX_END_NAMESPACE_TR1
}
--- libstdc++-v3/src/compatibility-ldbl.cc.jj 2008-02-29 10:31:51.000000000 +0100
+++ libstdc++-v3/src/compatibility-ldbl.cc 2008-02-29 11:40:04.000000000 +0100
@@ -1,6 +1,6 @@
// Compatibility symbols for -mlong-double-64 compatibility -*- C++ -*-
-// Copyright (C) 2006
+// Copyright (C) 2006, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -36,6 +36,8 @@
#error "compatibility-ldbl.cc must be compiled with -mlong-double-64"
#endif
+#define _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL
+
namespace std
{
#define C char
@@ -70,4 +72,7 @@ namespace std
#endif
}
+// For std::tr1::hash<long double>
+#include "hash.cc"
+
#endif
--- libstdc++-v3/testsuite/util/testsuite_abi.cc.jj 2008-02-29 10:33:00.000000000 +0100
+++ libstdc++-v3/testsuite/util/testsuite_abi.cc 2008-02-29 11:38:40.000000000 +0100
@@ -1,6 +1,6 @@
// -*- C++ -*-
-// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+// Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -194,6 +194,7 @@ check_version(symbol& test, bool added)
known_versions.push_back("GLIBCXX_3.4.10");
known_versions.push_back("GLIBCXX_LDBL_3.4");
known_versions.push_back("GLIBCXX_LDBL_3.4.7");
+ known_versions.push_back("GLIBCXX_LDBL_3.4.10");
known_versions.push_back("CXXABI_1.3");
known_versions.push_back("CXXABI_1.3.1");
known_versions.push_back("CXXABI_1.3.2");
Jakub