Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [RFC] requires libgcc_s.so.1 when libpthread.so.0 is required
@ 2022-03-20  9:48 sgn
  2022-03-20 12:08 ` leahneukirchen
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: sgn @ 2022-03-20  9:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1247 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages glibc-libpthread
https://github.com/void-linux/void-packages/pull/36239

[RFC] requires libgcc_s.so.1 when libpthread.so.0 is required
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

<!--
#### New package
- This new package conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please [skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration)
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!-- 
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/36239.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-glibc-libpthread-36239.patch --]
[-- Type: text/x-diff, Size: 4018 bytes --]

From 2ca8434c0dbbc698823ff74e96739c7164112c6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sun, 20 Mar 2022 16:29:53 +0700
Subject: [PATCH 1/2] hooks/gen-runtime-deps: convert element check to
 case...esac

This change was made in the hope of finding a needle in a haystack
could be faster than tokenizing and loop with for.

However, the ultimate goal is easier to integrate a later change to
add implicit sh-requires on libgcc_s.so.1 when libpthread.so.0 is
required since libpthread.so.0 always dlopen(2) libgcc_s.so.1,
and libpthread.so.0 will go ahead to crash the program, should it fail
to do so.
---
 common/hooks/pre-pkg/04-generate-runtime-deps.sh | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh
index c8f8c04d4884..da0ac7754902 100644
--- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh
+++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh
@@ -75,12 +75,13 @@ hook() {
         read -n4 elfmagic < "$f"
         if [ "$elfmagic" = $'\177ELF' ]; then
             for nlib in $($OBJDUMP -p "$f"|awk '/NEEDED/{print $2}'); do
-                [ -z "$verify_deps" ] && verify_deps="$nlib" && continue
-                found=0
-                for j in ${verify_deps}; do
-                    [[ $j == $nlib ]] && found=1 && break
-                done
-                [[ $found -eq 0 ]] && verify_deps="$verify_deps $nlib"
+                case " $verify_deps " in
+                    *" $nlib "*)
+                        ;;
+                    *)
+                        verify_deps="$verify_deps $nlib"
+                        ;;
+                esac
             done
         fi
     done

From 71478956740ba94d02a7ea4b98417f0d7ce81376 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Sun, 20 Mar 2022 16:38:00 +0700
Subject: [PATCH 2/2] hooks/gen-runtime-deps: require libgcc_s.so.1 for
 libpthread.so.0

libpthread.so.0 dlopen(2) libgcc_s.so.1 on startup.
Should the former fails to dlopen(2) the latter, it will proceed to
crash the program.

Let's add libgcc_s.so.1 to sh-requires list whenever libpthread.so.0 is
required.

While doing so, don't add it to sh-requires list when $sourcepkg is
glibc, in order to prevent circular dependencies between glibc and
libgcc.

Fix: #36004
---
 common/hooks/pre-pkg/04-generate-runtime-deps.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/common/hooks/pre-pkg/04-generate-runtime-deps.sh b/common/hooks/pre-pkg/04-generate-runtime-deps.sh
index da0ac7754902..2fb9dc34b9e3 100644
--- a/common/hooks/pre-pkg/04-generate-runtime-deps.sh
+++ b/common/hooks/pre-pkg/04-generate-runtime-deps.sh
@@ -48,6 +48,7 @@ store_pkgdestdir_rundeps() {
 
 hook() {
     local depsftmp f lf j mapshlibs sorequires _curdep elfmagic
+    local needpthread=
 
     # Disable trap on ERR, xbps-uhelper cmd might return error... but not something
     # to be worried about because if there are broken shlibs this hook returns
@@ -80,6 +81,9 @@ hook() {
                         ;;
                     *)
                         verify_deps="$verify_deps $nlib"
+                        if [ "$nlib" = libpthread.so.0 ]; then
+                            needpthread=y
+                        fi
                         ;;
                 esac
             done
@@ -88,6 +92,12 @@ hook() {
     exec 0<&3 # restore stdin
     rm -f $depsftmp
 
+    # libpthread.so.0 dlopen(2) libgcc_s.so.1 and will abort if fail to do so
+    # Don't make glibc depends on libgcc to prevent circular dependencies.
+    if [ "$needpthread" ] && [ "$sourcepkg" != glibc ] ; then
+        verify_deps="$verify_deps libgcc_s.so.1"
+    fi
+
     #
     # Add required run time packages by using required shlibs resolved
     # above, the mapping is done thru the common/shlibs file.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-10-31  2:14 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-20  9:48 [PR PATCH] [RFC] requires libgcc_s.so.1 when libpthread.so.0 is required sgn
2022-03-20 12:08 ` leahneukirchen
2022-03-21  2:51 ` sgn
2022-03-21  5:51 ` q66
2022-03-21 20:23 ` leahneukirchen
2022-03-21 20:56 ` q66
2022-03-24 14:44 ` sgn
2022-04-03 11:14 ` sgn
2022-04-03 14:02 ` q66
2022-04-13 19:43 ` Chocimier
2022-04-14  0:32 ` q66
2022-07-13  2:15 ` github-actions
2022-07-17 20:13 ` ericonr
2022-07-17 20:13 ` ericonr
2022-10-16  2:14 ` github-actions
2022-10-31  2:14 ` [PR PATCH] [Closed]: " github-actions

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).