Skip to content

Commit 29c39a3

Browse files
committed
Fix GH-17855: CURL_STATICLIB flag set even if linked with shared lib
We must define `CURL_STATICLIB` only when building against a static libcurl. The detection relies on our usual naming conventions, what should be revised in the future (possibly using pkg-config, or switching to CMake). Closes GH-17857.
1 parent 260e0e9 commit 29c39a3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ PHP NEWS
5757

5858
- Windows:
5959
. Fixed phpize for Windows 11 (24H2). (bwoebi)
60+
. Fixed GH-17855 (CURL_STATICLIB flag set even if linked with shared lib).
61+
(cmb)
6062

6163
- Zlib:
6264
. Fixed bug GH-17745 (zlib extension incorrectly handles object arguments).

ext/curl/config.w32

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ if (PHP_CURL != "no") {
1313
}
1414
}
1515

16-
if (CHECK_LIB("libcurl_a.lib;libcurl.lib", "curl", PHP_CURL) &&
16+
var curl_location;
17+
if ((curl_location = CHECK_LIB("libcurl_a.lib;libcurl.lib", "curl", PHP_CURL)) &&
1718
CHECK_HEADER_ADD_INCLUDE("curl/easy.h", "CFLAGS_CURL") &&
1819
SETUP_OPENSSL("curl", PHP_CURL) > 0 &&
1920
CHECK_LIB("winmm.lib", "curl", PHP_CURL) &&
@@ -28,7 +29,10 @@ if (PHP_CURL != "no") {
2829
) {
2930
EXTENSION("curl", "interface.c multi.c share.c curl_file.c");
3031
AC_DEFINE('HAVE_CURL', 1, 'Have cURL library');
31-
ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB /D PHP_CURL_EXPORTS=1");
32+
ADD_FLAG("CFLAGS_CURL", "/D PHP_CURL_EXPORTS=1");
33+
if (curl_location.match(/libcurl_a\.lib$/)) {
34+
ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB");
35+
}
3236
PHP_INSTALL_HEADERS("ext/curl", "php_curl.h");
3337
// TODO: check for curl_version_info
3438
} else {

0 commit comments

Comments
 (0)