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