Bug 1668723 - pcreposix library is not linked to Perl XS modules
Summary: pcreposix library is not linked to Perl XS modules
Alias: None
Product: Fedora
Classification: Fedora
Component: cyrus-imapd
Version: rawhide
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
Assignee: Jason Tibbitts
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2019-01-23 12:42 UTC by Petr Pisar
Modified: 2019-01-25 03:49 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2019-01-25 03:49:10 UTC
Type: Bug

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1667614 0 unspecified CLOSED Issues with pcre and -Wl,--as-needed 2021-02-22 00:41:40 UTC

Description Petr Pisar 2019-01-23 12:42:30 UTC
I'm working on PCRE bug #1667614 that will make sure that POSIX regex functions are indeed used from pcreposix library at run-time.

I examined cyrus-imapd sources. I found that all cyrus-imapd source files that call the regex functions (regcomp, regexec, regfree, regerror) include <pcreposix.h> directly on indirectly. Then I checked all binary files that refer to these symbols whether they link in libpcreposix.so.0 and I found two cases where this is not true:


Build log reads:

gcc  -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -fstack-protector-strong  IMAP.o  -o blib/arch/auto/Cyrus/IMAP/IMAP.so ../../perl/.libs/libcyrus.a ../../perl/.libs/libcyrus_min.a \
   -lsasl2 -lssl -lcrypto -lssl -lcrypto -luuid -lz -lperl   \

gcc   -lpthread -shared -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -fstack-protector-strong  managesieve.o  -o blib/arch/auto/Cyrus/SIEVE/managesieve/managesieve.so ../lib/.libs/libisieve.a ../../../perl/.libs/libcyrus.a ../../../perl/.libs/libcyrus_min.a \
   -lsasl2 -lssl -lcrypto -lssl -lcrypto -luuid -lz -lsqlite3 -L/usr/lib64/ -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto -lpq -lperl   \

I checked IMAP.xs and managesieve.xs and the references to the regex symbols come from statically linked libraries perl/.libs/libcyrus_min.a and perl/.libs/libcyrus.a. Specifically from lib/.libs/util.o and lib/.libs/glob.o objects.

Those two Perl XS modules will become unusable after I will apply the change to PCRE. I run cyrus-imapd tests and indeed a test fails because of that:

There was 1 failure:
1) test_badscript_timsieved(Cassandane::Cyrus::Sieve)
 Can't load '/home/test/rpmbuild/BUILDROOT/cyrus-imapd-3.0.8-6.fc30.x86_64/usr/lib64/perl5/vendor_perl/auto/Cyrus/SIEVE/managesieve/managesieve.so' for module Cyrus::SIEVE::managesieve
: /home/test/rpmbuild/BUILDROOT/cyrus-imapd-3.0.8-6.fc30.x86_64/usr/lib64/perl5/vendor_perl/auto/Cyrus/SIEVE/managesieve/managesieve.so: undefined symbol: pcre_regexec at /usr/lib64/pe
rl5/DynaLoader.pm line 193.

I guess you will need to change the Makefile.PL.in files that hard-codes 'MYEXTLIB'  => '@top_builddir@/perl/.libs/libcyrus.a @top_builddir@/perl/.libs/libcyrus_min.a' but do not add PCRE or REGEX libraries to LIBS variable.

Comment 1 Petr Pisar 2019-01-23 14:40:23 UTC
The pcre change landed to Fedora 30 in pcre-devel-8.42-7.fc30. You should be able to reproduce the reported issue when reverting a "%undefine _ld_as_needed" hack.

Comment 2 Jason Tibbitts 2019-01-23 21:02:30 UTC
I'm afraid I don't understand why it's important to change MYEXTLIB and not LIBS.  Certainly I can tack on '-lpcreposix' to MYEXTLIB and it works, but I haven't really worked with makemaker in over two decades so I don't really get the distinction.  It results in the same command line either way if you ignore the position of the line break.

But in any case, adding it to MYEXTLIB does result in passing tests.  That's currently done in rawhide.  I reported to upstream as a continuation of https://github.com/cyrusimap/cyrus-imapd/issues/2629

Comment 3 Petr Pisar 2019-01-24 08:56:03 UTC
I wrote -lpcreposix should go to LIBS. MYEXTLIB is for libraries built by Makefile.PL. Though there is practical no difference, I think.

Comment 4 Jason Tibbitts 2019-01-24 17:55:56 UTC
Oh, sorry, what I saw was your statement "but do not add PCRE or REGEX libraries to LIBS variable" which I interpreted to mean that I should not put -lpcreposix in LIBS.  I see now that it's just a subtle grammar issue; you were trying to tell me that I should fix any Makefile.PL which has either libcyrus.a or libcyrus_min.a in MYEXTLYBS but does not have -lpcrepoxix in LIBS.

Comment 5 Jason Tibbitts 2019-01-25 03:49:10 UTC
In any case, this is all fixed in rawhide.

Note You need to log in before you can comment on or make changes to this bug.