This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix libstdc++ build with GNU ld, but non-GNU as (PR libstdc++/38092)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Paolo Carlini <paolo dot carlini at oracle dot com>, Benjamin Kosnik <bkoz at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 7 Jan 2009 22:28:27 +0100
- Subject: [PATCH] Fix libstdc++ build with GNU ld, but non-GNU as (PR libstdc++/38092)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
When using non-GNU as together with GNU ld, GNU symbol versioning
is used, but .symver directive can't be used.
The following patch fixes it.
Bootstrapped/regtested on x86_64-linux and Rainer Orth tested
it on Solaris. Ok for trunk?
2009-01-07 Jakub Jelinek <jakub@redhat.com>
PR libstdc++/38092
* acinclude.m4 (HAVE_AS_SYMVER_DIRECTIVE): New test.
* src/compatibility.cc: Don't use .symver directives if
_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE is not defined.
* config.h.in: Regenerated.
* configure: Likewise.
--- libstdc++-v3/acinclude.m4.jj 2008-12-19 10:19:38.000000000 +0100
+++ libstdc++-v3/acinclude.m4 2009-01-07 12:47:40.000000000 +0100
@@ -2819,6 +2819,16 @@ if test x$enable_symvers != xno ; then
[Define to use symbol versioning in the shared library.])
fi
+AC_CACHE_CHECK([whether the target supports .symver directive],
+ glibcxx_cv_have_as_symver_directive, [
+ AC_TRY_COMPILE([void foo (void); __asm (".symver foo, bar@SYMVER");],
+ [], glibcxx_cv_have_as_symver_directive=yes,
+ glibcxx_cv_have_as_symver_directive=no)])
+if test $glibcxx_cv_have_as_symver_directive = yes; then
+ AC_DEFINE(HAVE_AS_SYMVER_DIRECTIVE, 1,
+ [Define to 1 if the target assembler supports .symver directive.])
+fi
+
AC_SUBST(SYMVER_FILE)
AC_SUBST(port_specific_symbol_files)
GLIBCXX_CONDITIONAL(ENABLE_SYMVERS, test $enable_symvers != no)
--- libstdc++-v3/src/compatibility.cc.jj 2008-09-05 12:56:34.000000000 +0200
+++ libstdc++-v3/src/compatibility.cc 2009-01-07 12:30:41.000000000 +0100
@@ -1,6 +1,6 @@
// Compatibility symbols for previous versions -*- C++ -*-
-// Copyright (C) 2005, 2006
+// Copyright (C) 2005, 2006, 2009
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -30,7 +30,8 @@
#include <bits/c++config.h>
-#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC)
+#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
+ && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
#define istreambuf_iterator istreambuf_iteratorXX
#define basic_fstream basic_fstreamXX
#define basic_ifstream basic_ifstreamXX
@@ -204,7 +204,8 @@ _GLIBCXX_END_NAMESPACE
// NB: These symbols renames should go into the shared library only,
// and only those shared libraries that support versioning.
-#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC)
+#if defined(_GLIBCXX_SYMVER_GNU) && defined(PIC) \
+ && defined(_GLIBCXX_HAVE_AS_SYMVER_DIRECTIVE)
/* gcc-3.4.4
_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
--- libstdc++-v3/config.h.in.jj 2008-12-16 09:48:43.000000000 +0100
+++ libstdc++-v3/config.h.in 2009-01-07 12:48:06.000000000 +0100
@@ -12,6 +12,9 @@
/* Define to 1 if you have the `asinl' function. */
#undef HAVE_ASINL
+/* Define to 1 if the target assembler supports .symver directive. */
+#undef HAVE_AS_SYMVER_DIRECTIVE
+
/* Define to 1 if you have the `atan2f' function. */
#undef HAVE_ATAN2F
--- libstdc++-v3/configure.jj 2009-01-05 12:30:59.000000000 +0100
+++ libstdc++-v3/configure 2009-01-07 12:48:01.000000000 +0100
@@ -107735,6 +107735,68 @@ _ACEOF
fi
+echo "$as_me:$LINENO: checking whether the target supports .symver directive" >&5
+echo $ECHO_N "checking whether the target supports .symver directive... $ECHO_C" >&6
+if test "${glibcxx_cv_have_as_symver_directive+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+void foo (void); __asm (".symver foo, bar@SYMVER");
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ glibcxx_cv_have_as_symver_directive=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+glibcxx_cv_have_as_symver_directive=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $glibcxx_cv_have_as_symver_directive" >&5
+echo "${ECHO_T}$glibcxx_cv_have_as_symver_directive" >&6
+if test $glibcxx_cv_have_as_symver_directive = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_AS_SYMVER_DIRECTIVE 1
+_ACEOF
+
+fi
+
Jakub