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