diff --git a/perl-5.27.8-hints-linux-Add-lphtread-to-lddlflags.patch b/perl-5.27.8-hints-linux-Add-lphtread-to-lddlflags.patch new file mode 100644 index 0000000..f68569f --- /dev/null +++ b/perl-5.27.8-hints-linux-Add-lphtread-to-lddlflags.patch @@ -0,0 +1,61 @@ +From f6bc8fb3d26892ba1a84ba2df76beedd51998dd2 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 29 Jan 2018 16:34:17 +0100 +Subject: [PATCH] hints/linux: Add -lphtread to lddlflags +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Passing -z defs to linker flags causes perl to fail to build if threads are +enabled: + +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 \ + -L/usr/lib64 -lbz2 "-L../.." -lperl \ + +Bzip2.o: In function `deRef': +/builddir/build/BUILD/perl-5.26.1/cpan/Compress-Raw-Bzip2/Bzip2.xs:256: undefined reference to `pthread_getspecific' + +The reason is Bzip2.xs calls dTHX macro included from thread.h via perl.h that +expands to pthread_getspecific() function call that is defined in pthread +library. But the pthread library is not explicitly linked to Bzip.so (see the +gcc command). This is exactly what -z defs linker flag enforces. + +Underlinking ELFs can be dangerous because in case of versioned +symbols it can cause run-time binding to an improper version symbol or +even to an symbold from different library. + +This patch fixes hints for Linux by adding -lpthreads to lddlflags. It +also adds -shared there because Configure.sh adds it only hints return +lddlflags empty. + + + +Signed-off-by: Petr Písař +--- + hints/linux.sh | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/hints/linux.sh b/hints/linux.sh +index 3f38ea07f1..9ec3bc02ef 100644 +--- a/hints/linux.sh ++++ b/hints/linux.sh +@@ -353,12 +353,16 @@ if [ -f /etc/synoinfo.conf -a -d /usr/syno ]; then + echo "$libswanted" >&4 + fi + ++# Flags needed to produce shared libraries. ++lddlflags='-shared' ++ + # This script UU/usethreads.cbu will get 'called-back' by Configure + # after it has prompted the user for whether to use threads. + cat > UU/usethreads.cbu <<'EOCBU' + case "$usethreads" in + $define|true|[yY]*) + ccflags="-D_REENTRANT -D_GNU_SOURCE $ccflags" ++ lddlflags="-lpthread $lddlflags" + if echo $libswanted | grep -v pthread >/dev/null + then + set `echo X "$libswanted "| sed -e 's/ c / pthread c /'` +-- +2.13.6 + diff --git a/perl.spec b/perl.spec index 0e445ec..d504e58 100644 --- a/perl.spec +++ b/perl.spec @@ -79,7 +79,7 @@ License: GPL+ or Artistic Epoch: %{perl_epoch} Version: %{perl_version} # release number must be even higher, because dual-lived modules will be broken otherwise -Release: 404%{?dist} +Release: 405%{?dist} Summary: Practical Extraction and Report Language Url: http://www.perl.org/ Source0: http://www.cpan.org/src/5.0/perl-%{perl_version}.tar.bz2 @@ -261,6 +261,10 @@ Patch77: perl-5.27.3-avoid-the-address-of-.-will-always-evaluate-as-.-war # in libcrypt / glibc, rhbz#1536752 Patch78: perl-5.26.1-guard_old_libcrypt_fix.patch +# Link XS modules to pthread library to fix linking with -z defs, +# +Patch79: perl-5.27.8-hints-linux-Add-lphtread-to-lddlflags.patch + # Link XS modules to libperl.so with EU::CBuilder on Linux, bug #960048 Patch200: perl-5.16.3-Link-XS-modules-to-libperl.so-with-EU-CBuilder-on-Li.patch @@ -2854,6 +2858,7 @@ Perl extension for Version Objects %patch76 -p1 %patch77 -p1 %patch78 -p1 +%patch79 -p1 %patch200 -p1 %patch201 -p1 @@ -2903,6 +2908,7 @@ perl -x patchlevel.h \ 'Fedora Patch73: Expand system() arguments before a fork (RT#121105)' \ 'Fedora Patch76: Avoid undefined behavior when copying memory in Glob and pp_caller (RT#131746)' \ 'Fedora Patch78: Fix compatibility with libxcrypt (bug #1536752)' \ + 'Fedora Patch79: Link XS modules to pthread library to fix linking with -z defs' \ 'Fedora Patch200: Link XS modules to libperl.so with EU::CBuilder on Linux' \ 'Fedora Patch201: Link XS modules to libperl.so with EU::MM on Linux' \ %{nil} @@ -5186,6 +5192,9 @@ popd # Old changelog entries are preserved in CVS. %changelog +* Mon Jan 29 2018 Petr Pisar - 4:5.26.1-405 +- Link XS modules to pthread library to fix linking with -z defs + * Sat Jan 20 2018 Björn Esser - 4:5.26.1-404 - Add patch to conditionalize a fix for an old and long fixed bug in libcrypt / glibc (rhbz#1536752)