Skip to content

Commit e6a7d5f

Browse files
cmb69charmitro
authored andcommitted
Fix phpGH-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 phpGH-17857.
1 parent 6f0541c commit e6a7d5f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

NEWS

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

6262
- Windows:
6363
. Fixed phpize for Windows 11 (24H2). (bwoebi)
64+
. Fixed GH-17855 (CURL_STATICLIB flag set even if linked with shared lib).
65+
(cmb)
6466

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

ext/curl/config.w32

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,28 @@ 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") &&
18-
SETUP_OPENSSL("curl", PHP_CURL) >= 2 &&
19+
SETUP_OPENSSL("curl", PHP_CURL) > 0 &&
1920
CHECK_LIB("winmm.lib", "curl", PHP_CURL) &&
2021
CHECK_LIB("wldap32.lib", "curl", PHP_CURL) &&
2122
(((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib;zlib.lib", "curl", PHP_CURL))) ||
2223
(PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "curl", PHP_CURL)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED))) &&
2324
!isNaN(ver_num) &&
24-
(CHECK_LIB("normaliz.lib", "curl", PHP_CURL) &&
25-
CHECK_LIB("libssh2.lib", "curl", PHP_CURL) &&
26-
CHECK_LIB("nghttp2.lib", "curl", PHP_CURL))
25+
(ver_num <= parseInt("0x073b00") || ver_num > parseInt("0x073b00") &&
26+
CHECK_LIB("normaliz.lib", "curl", PHP_CURL) &&
27+
CHECK_LIB("libssh2.lib", "curl", PHP_CURL) &&
28+
CHECK_LIB("nghttp2.lib", "curl", PHP_CURL))
2729
) {
2830
EXTENSION("curl", "interface.c multi.c share.c curl_file.c");
29-
AC_DEFINE('HAVE_CURL', 1, "Define to 1 if the PHP extension 'curl' is available.");
30-
ADD_FLAG("CFLAGS_CURL", "/D CURL_STATICLIB /D PHP_CURL_EXPORTS=1");
31+
AC_DEFINE('HAVE_CURL', 1, 'Have cURL library');
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+
}
3136
PHP_INSTALL_HEADERS("ext/curl", "php_curl.h");
37+
// TODO: check for curl_version_info
3238
} else {
3339
WARNING("curl not enabled; libraries and headers not found");
3440
}

0 commit comments

Comments
 (0)