[PATCH] Determine libgcc_s version

View: New views
9 Messages — Rating Filter:   Alert me  

[PATCH] Determine libgcc_s version

by Andreas Schwab-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Add configure test to determine the version of the libgcc_s library and
use that instead of hardcoding libgcc_s.so.1.

Andreas.

2009-09-20  Andreas Schwab  <schwab@...>

        [BZ #4457]
        * configure.in: Determine version of libgcc_s libraray.
        * configure: Regenerated.
        * config.make.in (libgcc_s-version): Define.
        * Makeconfig ($(common-objpfx)libgcc_s-version): New target.
        ($(common-objpfx)shlib-versions.v.i): Depend on it.
        (postclean-generated): Add libgcc_s-version.
        * sysdeps/generic/framestate.c (__frame_state_for): Use
        LIBGCC_S_SO.

nptl/:
        [BZ #4457]
        * sysdeps/pthread/unwind-forcedunwind.c (pthread_cancel_init): Use
        LIBGCC_S_SO.
        * sysdeps/pthread/unwind-resume.c (init): Likewise.

diff --git a/Makeconfig b/Makeconfig
index 9f134cc..7b75c29 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -829,7 +829,9 @@ ifndef avoid-generated
 $(common-objpfx)shlib-versions.v.i: \
  $(wildcard $(+sysdep_dirs:=/shlib-versions) \
    $(subdir-srcdirs:=/shlib-versions)) \
- $(..)shlib-versions
+ $(..)shlib-versions $(common-objpfx)libgcc_s-version
+$(common-objpfx)libgcc_s-version: $(common-objpfx)config.make
+ echo '.*-.*-.* libgcc_s=$(libgcc_s-version)' > $@
 
 soversions-default-setname = $(patsubst %, %,\
  $(filter-out %_default,\
@@ -867,7 +869,8 @@ endif
 endif
 
 postclean-generated += soversions.mk soversions.i \
-       shlib-versions.v shlib-versions.v.i
+       shlib-versions.v shlib-versions.v.i \
+       libgcc_s-version
 
 # Generate the header containing the names of all shared libraries.
 # We use a stamp file to avoid unnecessary recompilations.
diff --git a/config.make.in b/config.make.in
index d65706c..f140211 100644
--- a/config.make.in
+++ b/config.make.in
@@ -69,6 +69,7 @@ bind-now = @bindnow@
 have-hash-style = @libc_cv_hashstyle@
 
 static-libgcc = @libc_cv_gcc_static_libgcc@
+libgcc_s-version = @libc_cv_libgcc_s_version@
 
 versioning = @VERSIONING@
 oldest-abi = @oldest_abi@
diff --git a/configure.in b/configure.in
index 4a81fb0..0d71dd4 100644
--- a/configure.in
+++ b/configure.in
@@ -2170,6 +2170,22 @@ AC_CHECK_SIZEOF(long double, 0)
 sizeof_long_double=$ac_cv_sizeof_long_double
 AC_SUBST(sizeof_long_double)
 
+AC_CACHE_CHECK([for version of libgcc_s library], libc_cv_libgcc_s_version, [dnl
+  cat > conftest.c <<EOF
+int main (void) { return 0; }
+EOF
+  if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
+      -fPIC -shared -o conftest.so conftest.c
+      -lgcc_s$libc_cv_libgcc_s_suffix
+      -nostdlib >&AS_MESSAGE_LOG_FD])
+  then
+    libc_cv_libgcc_s_version=`$OBJDUMP -p conftest.so |
+      $AWK '$[]1 == "NEEDED" && $[]2 ~ /libgcc_s/ {
+      sub(/.*\.so\./, "", $[]2)
+      print $[]2 }'`
+  fi
+  rm -f conftest*])
+
 ### End of automated tests.
 ### Now run sysdeps configure fragments.
 
@@ -2291,6 +2307,7 @@ AC_SUBST(libc_cv_localedir)
 AC_SUBST(libc_cv_sysconfdir)
 AC_SUBST(libc_cv_rootsbindir)
 AC_SUBST(libc_cv_forced_unwind)
+AC_SUBST(libc_cv_libgcc_s_version)
 
 dnl sysdeps/CPU/configure.in checks set this via arch-specific asm tests
 AC_SUBST(libc_cv_cpp_asm_debuginfo)
diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c
index 402591f..142ca74 100644
--- a/nptl/sysdeps/pthread/unwind-forcedunwind.c
+++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c
@@ -22,6 +22,7 @@
 #include <unwind.h>
 #include <pthreadP.h>
 #include <sysdep.h>
+#include <gnu/lib-names.h>
 
 static void *libgcc_s_handle;
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
@@ -49,7 +50,7 @@ pthread_cancel_init (void)
       return;
     }
 
-  handle = __libc_dlopen ("libgcc_s.so.1");
+  handle = __libc_dlopen (LIBGCC_S_SO);
 
   if (handle == NULL
       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
@@ -61,7 +62,7 @@ pthread_cancel_init (void)
       || ARCH_CANCEL_INIT (handle)
 #endif
       )
-    __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+    __libc_fatal (LIBGCC_S_SO " must be installed for pthread_cancel to work\n");
 
   PTR_MANGLE (resume);
   libgcc_s_resume = resume;
diff --git a/nptl/sysdeps/pthread/unwind-resume.c b/nptl/sysdeps/pthread/unwind-resume.c
index 088f4c6..f06a479 100644
--- a/nptl/sysdeps/pthread/unwind-resume.c
+++ b/nptl/sysdeps/pthread/unwind-resume.c
@@ -20,6 +20,7 @@
 #include <dlfcn.h>
 #include <stdio.h>
 #include <unwind.h>
+#include <gnu/lib-names.h>
 
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static _Unwind_Reason_Code (*libgcc_s_personality)
@@ -32,12 +33,12 @@ init (void)
   void *resume, *personality;
   void *handle;
 
-  handle = __libc_dlopen ("libgcc_s.so.1");
+  handle = __libc_dlopen (LIBGCC_S_SO);
 
   if (handle == NULL
       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
       || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
-    __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+    __libc_fatal (LIBGCC_S_SO " must be installed for pthread_cancel to work\n");
 
   libgcc_s_resume = resume;
   libgcc_s_personality = personality;
diff --git a/sysdeps/generic/framestate.c b/sysdeps/generic/framestate.c
index a912a8c..15f31a1 100644
--- a/sysdeps/generic/framestate.c
+++ b/sysdeps/generic/framestate.c
@@ -20,6 +20,7 @@
 
 #include <dlfcn.h>
 #include <stdlib.h>
+#include <gnu/lib-names.h>
 #define STATIC static
 #define __frame_state_for fallback_frame_state_for
 #include <unwind-dw2.c>
@@ -36,7 +37,7 @@ __frame_state_for (void *pc, struct frame_state *frame_state)
 
   if (frame_state_for == NULL)
     {
-      void *handle = __libc_dlopen ("libgcc_s.so.1");
+      void *handle = __libc_dlopen (LIBGCC_S_SO);
 
       if (handle == NULL
   || (frame_state_for

--
Andreas Schwab, schwab@...
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Re: [PATCH] Determine libgcc_s version

by Roland McGrath :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not at all sure we really want to do this via configure.  This is the
ambient ABI requirement we are building into the libc we build, a bit like
the --enable-kernel setting.  It seems to me we might only want that to
change by conscious choice, not by implicit magic.  I guess that would just
mean maintaining it manually in shlib-versions.  That seems wiser to me off
hand.  But I don't know what Jakub or Uli think about it, and I'm happy to
defer to the consensus.


Thanks,
Roland

Re: [PATCH] Determine libgcc_s version

by Andreas Schwab-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Roland McGrath <roland@...> writes:

> I'm not at all sure we really want to do this via configure.  This is the
> ambient ABI requirement we are building into the libc we build, a bit like
> the --enable-kernel setting.  It seems to me we might only want that to
> change by conscious choice, not by implicit magic.  I guess that would just
> mean maintaining it manually in shlib-versions.  That seems wiser to me off
> hand.  But I don't know what Jakub or Uli think about it, and I'm happy to
> defer to the consensus.

See <http://sourceware.org/bugzilla/show_bug.cgi?id=4457#c3> for Uli's
position.

Andreas.

--
Andreas Schwab, schwab@...
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Re: [PATCH] Determine libgcc_s version

by Ulrich Drepper :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 09/20/2009 04:45 AM, Andreas Schwab wrote:
> Add configure test to determine the version of the libgcc_s library and
> use that instead of hardcoding libgcc_s.so.1.

I think we need a second header file or just an internal wrapper around
gnu/lib-names.h.

There are two problems:

- on bi-arch systems, you'd have to check the version of both
architectures (e.g., on x86-64 the x86 is currently assumed to be the same)

- we export in glibc headers info about the gcc DSO although we don't
control it.


As I said, either a separate header or somehow get <gnu/lib-names.h>
intercepted similar to how the include/ subdir works.

--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖

Re: [PATCH] Determine libgcc_s version

by Roland McGrath :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> See <http://sourceware.org/bugzilla/show_bug.cgi?id=4457#c3> for Uli's
> position.

That comment is unambiguous that getting LIBGCC_S defined is right.
It's not clear about automagic selection vs maintaining shlib-versions.


Thanks,
Roland

Re: [PATCH] Determine libgcc_s version

by Roland McGrath :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> - on bi-arch systems, you'd have to check the version of both
> architectures (e.g., on x86-64 the x86 is currently assumed to be the same)

Existing biarch magic already takes care of this issue if we maintain it
with shlib-versions lines.

> - we export in glibc headers info about the gcc DSO although we don't
> control it.

Hmm.  I hadn't thought about it before, but this is a pretty good reason
not to have LIBGCC_S_SO defined in the installed <gnu/lib-names.h> IMHO.

Let's just add a trivial sysdeps/.../libgcc_s.h that defines LIBGCC_S_SO by
hand, and maintain that by hand.


Thanks,
Roland


Re: [PATCH] Determine libgcc_s version

by Andreas Schwab-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Roland McGrath <roland@...> writes:

> Let's just add a trivial sysdeps/.../libgcc_s.h that defines LIBGCC_S_SO by
> hand, and maintain that by hand.

Here is a patch, sanity checked on powerpc.

Andreas.

From ae5f95a2aca5914cacbb406741257a519ba02002 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@...>
Date: Mon, 21 Sep 2009 21:13:21 +0200
Subject: [PATCH] Make name of libgcc_s library configurable

---
 ChangeLog                                  |    6 ++++++
 nptl/ChangeLog                             |    7 +++++++
 nptl/sysdeps/pthread/unwind-forcedunwind.c |    5 +++--
 nptl/sysdeps/pthread/unwind-resume.c       |    5 +++--
 sysdeps/generic/framestate.c               |    3 ++-
 sysdeps/generic/libgcc_s.h                 |    2 ++
 6 files changed, 23 insertions(+), 5 deletions(-)
 create mode 100644 sysdeps/generic/libgcc_s.h

diff --git a/ChangeLog b/ChangeLog
index bdc4b4d..21a0dbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-09-21  Andreas Schwab  <schwab@...>
+
+ [BZ #4457]
+ * sysdeps/generic/libgcc_s.h: New file.
+ * sysdeps/generic/framestate.c: Include it and use LIBGCC_S_SO.
+
 2009-09-20  Andreas Schwab  <schwab@...>
 
  * iconvdata/iso646.c (gconv_init): Correctly initialize the
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index d211635..2621bc4 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-21  Andreas Schwab  <schwab@...>
+
+ [BZ #4457]
+ * sysdeps/pthread/unwind-resume.c: Include <libgcc_s.h> and use
+ LIBGCC_S_SO.
+ * sysdeps/pthread/unwind-forcedunwind.c: Likewise.
+
 2009-09-07  Andreas Schwab  <schwab@...>
 
  * sysdeps/pthread/bits/libc-lock.h (BP_SYM): Remove space before paren.
diff --git a/nptl/sysdeps/pthread/unwind-forcedunwind.c b/nptl/sysdeps/pthread/unwind-forcedunwind.c
index 402591f..ae43f33 100644
--- a/nptl/sysdeps/pthread/unwind-forcedunwind.c
+++ b/nptl/sysdeps/pthread/unwind-forcedunwind.c
@@ -22,6 +22,7 @@
 #include <unwind.h>
 #include <pthreadP.h>
 #include <sysdep.h>
+#include <libgcc_s.h>
 
 static void *libgcc_s_handle;
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
@@ -49,7 +50,7 @@ pthread_cancel_init (void)
       return;
     }
 
-  handle = __libc_dlopen ("libgcc_s.so.1");
+  handle = __libc_dlopen (LIBGCC_S_SO);
 
   if (handle == NULL
       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
@@ -61,7 +62,7 @@ pthread_cancel_init (void)
       || ARCH_CANCEL_INIT (handle)
 #endif
       )
-    __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+    __libc_fatal (LIBGCC_S_SO " must be installed for pthread_cancel to work\n");
 
   PTR_MANGLE (resume);
   libgcc_s_resume = resume;
diff --git a/nptl/sysdeps/pthread/unwind-resume.c b/nptl/sysdeps/pthread/unwind-resume.c
index 088f4c6..69f3e04 100644
--- a/nptl/sysdeps/pthread/unwind-resume.c
+++ b/nptl/sysdeps/pthread/unwind-resume.c
@@ -20,6 +20,7 @@
 #include <dlfcn.h>
 #include <stdio.h>
 #include <unwind.h>
+#include <libgcc_s.h>
 
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static _Unwind_Reason_Code (*libgcc_s_personality)
@@ -32,12 +33,12 @@ init (void)
   void *resume, *personality;
   void *handle;
 
-  handle = __libc_dlopen ("libgcc_s.so.1");
+  handle = __libc_dlopen (LIBGCC_S_SO);
 
   if (handle == NULL
       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL
       || (personality = __libc_dlsym (handle, "__gcc_personality_v0")) == NULL)
-    __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+    __libc_fatal (LIBGCC_S_SO " must be installed for pthread_cancel to work\n");
 
   libgcc_s_resume = resume;
   libgcc_s_personality = personality;
diff --git a/sysdeps/generic/framestate.c b/sysdeps/generic/framestate.c
index a912a8c..80375bb 100644
--- a/sysdeps/generic/framestate.c
+++ b/sysdeps/generic/framestate.c
@@ -24,6 +24,7 @@
 #define __frame_state_for fallback_frame_state_for
 #include <unwind-dw2.c>
 #undef __frame_state_for
+#include <libgcc_s.h>
 
 typedef struct frame_state * (*framesf)(void *pc, struct frame_state *);
 struct frame_state *__frame_state_for (void *pc,
@@ -36,7 +37,7 @@ __frame_state_for (void *pc, struct frame_state *frame_state)
 
   if (frame_state_for == NULL)
     {
-      void *handle = __libc_dlopen ("libgcc_s.so.1");
+      void *handle = __libc_dlopen (LIBGCC_S_SO);
 
       if (handle == NULL
   || (frame_state_for
diff --git a/sysdeps/generic/libgcc_s.h b/sysdeps/generic/libgcc_s.h
new file mode 100644
index 0000000..e74a103
--- /dev/null
+++ b/sysdeps/generic/libgcc_s.h
@@ -0,0 +1,2 @@
+/* Name of libgcc_s library provided by gcc.  */
+#define LIBGCC_S_SO "libgcc_s.so.1"
--
1.6.4.4


--
Andreas Schwab, schwab@...
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

Re: [PATCH] Determine libgcc_s version

by Roland McGrath :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That looks fine to me, but we'll need Uli to verify it's what he wants.

Thanks,
Roland

Re: [PATCH] Determine libgcc_s version

by Andreas Schwab-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've pushed that now, since there were no objections.

Andreas.

--
Andreas Schwab, schwab@...
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."