|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80402 configure filtering out -lpthread
Submitted: 2020-11-23 00:20 UTC Modified: 2020-11-26 10:57 UTC
From: bjornar dot ness at gmail dot com Assigned: nikic (profile)
Status: Closed Package: *Configuration Issues
PHP Version: Irrelevant OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bjornar dot ness at gmail dot com
New email:
PHP Version: OS:


 [2020-11-23 00:20 UTC] bjornar dot ness at gmail dot com
php's configure script has multiple places where it filters out -lpthread from $LIBS
before ac_fn_c_try_link

This is likely ok for shared, but causes problems with static libs.
One example of this is when building openssl static.

# pkg-config openssl --libs

-L/usr/src/php-build/install/OpenSSL_1_1_1h/lib -lssl -lz -lcrypto -lpthread -ldl

Problem is, when configure tries to check this rule, it filters out some libs from
what it was told by pkg-config:

(looping through $XXXX_LIBS)
case $ac_ii in
c|c_r|pthread*) ;;
 LIBS="$LIBS -l$ac_ii"
(end loop)


ac_fn_c_try_link basically does:

$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5

and in my case then, results in the following libs:

-lssl -lz -lcrypto -ldl

note -lpthread missing, and the test failing.

I have not managed to find a way around this without modifying the configure file, adding -lpthread where it needs to be.

The rest of the actual build is just fine after manually adding -lpthread to just the relevant tests.


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-11-23 01:19 UTC] bjornar dot ness at gmail dot com
The only, but ugly, way I have managed to find around this atm is:

LIBS="-lpthread" LDFLAGS="-Wl,--start-group" /path/to/configure
 [2020-11-24 11:06 UTC]
Which PHP version are you using? (In particular wondering if you have, which is in 7.4.)
 [2020-11-24 11:12 UTC]
Ah no, that one was about -pthread, not -lpthread. I presume lpthread is getting stripped out by _PHP_ADD_LIBRARY_SKELETON. That logic was originally added 20 years ago with:

I have no idea why it is there.
 [2020-11-24 11:27 UTC]
The following pull request has been associated:

Patch Name: Don't strip -lpthread
On GitHub:
 [2020-11-26 10:56 UTC]
Automatic comment on behalf of
Log: Fix bug #80402: Don't strip -lpthread
 [2020-11-26 10:56 UTC]
-Status: Open +Status: Closed
 [2020-11-26 10:57 UTC]
-Assigned To: +Assigned To: nikic
 [2020-11-26 10:57 UTC]
I've dropped the -lpthread stripping for now ... might have to revert is someone reports issues with that change.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 16:01:29 2024 UTC