Skip to contentSkip to conversation

libunwind: backport patch to link against libgcc_s intead of libgcc

PATCH In review Jonathan Liu 2 participants 5 messages Mar 11, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libunwind: backport patch to link against libgcc_s intead of libgcc

---
 ...-libunwind-to-libgcc_s-rather-than-libgcc.patch | 42 ++++++++++++++++++++++
 meta/recipes-support/libunwind/libunwind_1.1.bb    |  1 +
 2 files changed, 43 insertions(+)
 create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch
meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +42 -0
new file mode 100644
index 0000000..0e55c91
@@ -0,0 +1,42 @@
+From 508ca17a7be01d1cc960d9a07d0af4513948fb8d Mon Sep 17 00:00:00 2001
+From: Thierry Reding <[email protected]>
+Date: Fri, 27 Jun 2014 08:40:33 +0200
+Subject: [PATCH] Link libunwind to libgcc_s rather than libgcc
+
+For some architectures, -lgcc and -lgcc_s are not equivalent. On ARM for
+example, libgcc_s.so.1 contains some symbols needed by libunwind which
+are not present in libgcc.
+
+This causes the following link error when building the X.Org X server
+with libunwind support:
+
+	  CCLD     Xorg
+	/usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr0'
+	/usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr1'
+
+Linking against libgcc_s explicitly solves this problem.
+
+Upstream-Status: Backport
+
+Signed-off-by: Thierry Reding <[email protected]>
+Signed-off-by: Jonathan Liu <[email protected]>
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index cffe19b..3beb5f2 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -258,7 +258,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#ifndef __INTEL_COMPILER
+ 
+ if test x$GCC = xyes -a x$intel_compiler != xyes; then
+   CFLAGS="${CFLAGS} -fexceptions -Wall -Wsign-compare"
+-  LIBCRTS="-lgcc"
++  LIBCRTS="-lgcc_s"
+ fi
+ AC_MSG_RESULT([$intel_compiler])
+ 
+-- 
+2.3.2
+
meta/recipes-support/libunwind/libunwind_1.1.bb +1 -0
index 20db132..05dba3b 100644
@@ -2,6 +2,7 @@ require libunwind.inc
 
 SRC_URI += "\
     file://Fix-test-case-link-failure-on-PowerPC-systems-with-Altivec.patch \
+    file://Link-libunwind-to-libgcc_s-rather-than-libgcc.patch \
 "
 
 SRC_URI[md5sum] = "fb4ea2f6fbbe45bf032cd36e586883ce"
Signature · 1 line
2.3.1
#1 lore raw
Quoted 24 lines · Jonathan Liu

---
...-libunwind-to-libgcc_s-rather-than-libgcc.patch | 42 ++++++++++++++++++++++
meta/recipes-support/libunwind/libunwind_1.1.bb | 1 +

2 files changed, 43 insertions(+)

create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +8 -0
new file mode 100644
index 0000000..0e55c91
@@ -0,0 +1,42 @@
+From 508ca17a7be01d1cc960d9a07d0af4513948fb8d Mon Sep 17 00:00:00 2001
+From: Thierry Reding <[email protected]>
+Date: Fri, 27 Jun 2014 08:40:33 +0200
+Subject: [PATCH] Link libunwind to libgcc_s rather than libgcc
+
+For some architectures, -lgcc and -lgcc_s are not equivalent. On ARM for
+example, libgcc_s.so.1 contains some symbols needed by libunwind which
+are not present in libgcc.

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch line 18

Quoted 10 lines
meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +10 -0
+
+This causes the following link error when building the X.Org X server
+with libunwind support:
+
+	  CCLD     Xorg
+	/usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr0'
+	/usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr1'
+
+Linking against libgcc_s explicitly solves this problem.
+

have you tried it at runtime too ?

#2 lore raw
Quoted 28 lines · Khem Raj
Quoted 28 lines · Jonathan Liu

---
...-libunwind-to-libgcc_s-rather-than-libgcc.patch | 42 ++++++++++++++++++++++
meta/recipes-support/libunwind/libunwind_1.1.bb | 1 +

2 files changed, 43 insertions(+)

create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +12 -0
new file mode 100644
index 0000000..0e55c91
@@ -0,0 +1,42 @@
+From 508ca17a7be01d1cc960d9a07d0af4513948fb8d Mon Sep 17 00:00:00 2001
+From: Thierry Reding <[email protected]>
+Date: Fri, 27 Jun 2014 08:40:33 +0200
+Subject: [PATCH] Link libunwind to libgcc_s rather than libgcc
+
+For some architectures, -lgcc and -lgcc_s are not equivalent. On ARM for
+example, libgcc_s.so.1 contains some symbols needed by libunwind which
+are not present in libgcc.
+
+This causes the following link error when building the X.Org X server
+with libunwind support:
+
Quoted 9 lines

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch line 18

Quoted 6 lines
meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +6 -0
+       CCLD     Xorg
+     /usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr0'
+     /usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr1'
+
+Linking against libgcc_s explicitly solves this problem.
+

have you tried it at runtime too ?

strace 4.9 with libunwind PACKAGECONFIG wouldn't build on master without the patch.
If I add strace 4.9 recipe to dizzy branch, using the libunwind PACKAGECONFIG also fails to build without the patch. It gives the same errors during linking.

I tested at runtime on master branch which has libunwind 1.1 running strace 4.9 on the target and didn't notice any issues. I haven't tested on dizzy branch at runtime though.

Regards,
Jonathan

#3 lore raw
Quoted 47 lines · Jonathan Liu
Quoted 28 lines · Khem Raj
Quoted 28 lines · Jonathan Liu

---
...-libunwind-to-libgcc_s-rather-than-libgcc.patch | 42 ++++++++++++++++++++++
meta/recipes-support/libunwind/libunwind_1.1.bb | 1 +

2 files changed, 43 insertions(+)

create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +12 -0
new file mode 100644
index 0000000..0e55c91
@@ -0,0 +1,42 @@
+From 508ca17a7be01d1cc960d9a07d0af4513948fb8d Mon Sep 17 00:00:00 2001
+From: Thierry Reding <[email protected]>
+Date: Fri, 27 Jun 2014 08:40:33 +0200
+Subject: [PATCH] Link libunwind to libgcc_s rather than libgcc
+
+For some architectures, -lgcc and -lgcc_s are not equivalent. On ARM for
+example, libgcc_s.so.1 contains some symbols needed by libunwind which
+are not present in libgcc.
+
+This causes the following link error when building the X.Org X server
+with libunwind support:
+
Quoted 9 lines

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch line 18

Quoted 6 lines
meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +6 -0
+       CCLD     Xorg
+     /usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr0'
+     /usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr1'
+
+Linking against libgcc_s explicitly solves this problem.
+

have you tried it at runtime too ?

strace 4.9 with libunwind PACKAGECONFIG wouldn't build on master without the patch.
If I add strace 4.9 recipe to dizzy branch, using the libunwind PACKAGECONFIG also fails to build without the patch. It gives the same errors during linking.

Quoted 3 lines

I tested at runtime on master branch which has libunwind 1.1 running strace 4.9 on the target and didn't notice any issues. I haven't tested on dizzy branch at runtime though.

OK thanks, it would be interesting to see if exception handling in some binaries and shared objects is able to unwind through to make sure this all works

#4 lore raw
Quoted 47 lines · Khem Raj
Quoted 47 lines · Jonathan Liu
Quoted 28 lines · Khem Raj
Quoted 28 lines · Jonathan Liu

---
...-libunwind-to-libgcc_s-rather-than-libgcc.patch | 42 ++++++++++++++++++++++
meta/recipes-support/libunwind/libunwind_1.1.bb | 1 +

2 files changed, 43 insertions(+)

create mode 100644 meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +12 -0
new file mode 100644
index 0000000..0e55c91
@@ -0,0 +1,42 @@
+From 508ca17a7be01d1cc960d9a07d0af4513948fb8d Mon Sep 17 00:00:00 2001
+From: Thierry Reding <[email protected]>
+Date: Fri, 27 Jun 2014 08:40:33 +0200
+Subject: [PATCH] Link libunwind to libgcc_s rather than libgcc
+
+For some architectures, -lgcc and -lgcc_s are not equivalent. On ARM for
+example, libgcc_s.so.1 contains some symbols needed by libunwind which
+are not present in libgcc.
+
+This causes the following link error when building the X.Org X server
+with libunwind support:
+
Quoted 9 lines

meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch line 18

Quoted 6 lines
meta/recipes-support/libunwind/libunwind-1.1/Link-libunwind-to-libgcc_s-rather-than-libgcc.patch new file +6 -0
+       CCLD     Xorg
+     /usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr0'
+     /usr/lib/libunwind.so: undefined reference to `__aeabi_unwind_cpp_pr1'
+
+Linking against libgcc_s explicitly solves this problem.
+

have you tried it at runtime too ?

strace 4.9 with libunwind PACKAGECONFIG wouldn't build on master without the patch.
If I add strace 4.9 recipe to dizzy branch, using the libunwind PACKAGECONFIG also fails to build without the patch. It gives the same errors during linking.

Quoted 7 lines
Quoted 3 lines

I tested at runtime on master branch which has libunwind 1.1 running strace 4.9 on the target and didn't notice any issues. I haven't tested on dizzy branch at runtime though.

OK thanks, it would be interesting to see if exception handling in some binaries and shared objects is able to unwind through to make sure this all works

Seems to work on dizzy branch too with strace 4.9 + libunwind 1.1 + libunwind patch:

# strace -k uname 2>&1 | sed -n '/^write(1/,$p'
write(1, "Linux\n", 6Linux
)                  = 6
Quoted 7 lines

/lib/libc-2.20.so(__write+0x1c) [0xbf8cc]
/lib/libc-2.20.so(_IO_file_write+0x20) [0x69c10]
/lib/libc-2.20.so(_IO_file_setbuf+0xd0) [0x690b8]
/lib/libc-2.20.so(_IO_do_write+0x1c) [0x6ab20]
/lib/libc-2.20.so(_IO_file_sync+0xc0) [0x68fb0]
/lib/libc-2.20.so(fflush+0x8c) [0x5e1f4]
/bin/busybox.nosuid(+0x0) [0x67178]

exit_group(0) = ?
+++ exited with 0 +++

Quoted 3 lines

/lib/libc-2.20.so(_exit+0x10) [0x9a930] /lib/libc-2.20.so(__libc_secure_getenv+0xf8) [0x30dc8] /bin/busybox.nosuid(+0x0) [0x67194]

Regards,
Jonathan