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