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:
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.
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.
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
I wrote -lpcreposix should go to LIBS. MYEXTLIB is for libraries built by Makefile.PL. Though there is practical no difference, I think.
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.
In any case, this is all fixed in rawhide.