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