b2938d
From f6bc8fb3d26892ba1a84ba2df76beedd51998dd2 Mon Sep 17 00:00:00 2001
b2938d
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
b2938d
Date: Mon, 29 Jan 2018 16:34:17 +0100
b2938d
Subject: [PATCH] hints/linux: Add -lphtread to lddlflags
b2938d
MIME-Version: 1.0
b2938d
Content-Type: text/plain; charset=UTF-8
b2938d
Content-Transfer-Encoding: 8bit
b2938d
b2938d
Passing -z defs to linker flags causes perl to fail to build if threads are
b2938d
enabled:
b2938d
b2938d
gcc  -shared -Wl,-z,relro -Wl,-z,defs -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -fstack-protector-strong Bzip2.o  -o ../../lib/auto/Compress/Raw/Bzip2/Bzip2.so  \
b2938d
   -L/usr/lib64 -lbz2 "-L../.." -lperl   \
b2938d
b2938d
Bzip2.o: In function `deRef':
b2938d
/builddir/build/BUILD/perl-5.26.1/cpan/Compress-Raw-Bzip2/Bzip2.xs:256: undefined reference to `pthread_getspecific'
b2938d
b2938d
The reason is Bzip2.xs calls dTHX macro included from thread.h via perl.h that
b2938d
expands to pthread_getspecific() function call that is defined in pthread
b2938d
library. But the pthread library is not explicitly linked to Bzip.so (see the
b2938d
gcc command). This is exactly what -z defs linker flag enforces.
b2938d
b2938d
Underlinking ELFs can be dangerous because in case of versioned
b2938d
symbols it can cause run-time binding to an improper version symbol or
b2938d
even to an symbold from different library.
b2938d
b2938d
This patch fixes hints for Linux by adding -lpthreads to lddlflags. It
b2938d
also adds -shared there because Configure.sh adds it only hints return
b2938d
lddlflags empty.
b2938d
b2938d
<https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/3RHZEHLRUHJFF2XGHI5RB6YPDNLDR4HG/>
b2938d
b2938d
Signed-off-by: Petr Písař <ppisar@redhat.com>
b2938d
---
b2938d
 hints/linux.sh | 4 ++++
b2938d
 1 file changed, 4 insertions(+)
b2938d
b2938d
diff --git a/hints/linux.sh b/hints/linux.sh
b2938d
index 3f38ea07f1..9ec3bc02ef 100644
b2938d
--- a/hints/linux.sh
b2938d
+++ b/hints/linux.sh
b2938d
@@ -353,12 +353,16 @@ if [ -f /etc/synoinfo.conf -a -d /usr/syno ]; then
b2938d
     echo "$libswanted" >&4
b2938d
 fi
b2938d
 
b2938d
+# Flags needed to produce shared libraries.
b2938d
+lddlflags='-shared'
b2938d
+
b2938d
 # This script UU/usethreads.cbu will get 'called-back' by Configure
b2938d
 # after it has prompted the user for whether to use threads.
b2938d
 cat > UU/usethreads.cbu <<'EOCBU'
b2938d
 case "$usethreads" in
b2938d
 $define|true|[yY]*)
b2938d
         ccflags="-D_REENTRANT -D_GNU_SOURCE $ccflags"
b2938d
+        lddlflags="-lpthread $lddlflags"
b2938d
         if echo $libswanted | grep -v pthread >/dev/null
b2938d
         then
b2938d
             set `echo X "$libswanted "| sed -e 's/ c / pthread c /'`
b2938d
-- 
b2938d
2.13.6
b2938d