1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Move iconv const check into autoconf (8.3) (#20247)

See GH-16847
This commit is contained in:
Calvin Buckley
2025-10-29 14:35:08 -03:00
committed by GitHub
parent 76e26c6c3c
commit d9bae1d1f5
2 changed files with 20 additions and 6 deletions

View File

@@ -113,6 +113,20 @@ int main(void) {
AC_MSG_RESULT(yes, cross-compiling)
])
dnl iconv on some platforms (NetBSD pre-10, Solaris) may have a non-standard
dnl const input parameter; libiconv may imitate this on those platforms.
AC_CACHE_CHECK([if iconv input parameter is const (non-standard)], [php_cv_iconv_const],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <iconv.h>
size_t iconv(iconv_t cd, const char **src, size_t *srcleft, char **dst, size_t *dstleft);
])],
[php_cv_iconv_const=const],
[php_cv_iconv_const=non-const])])
dnl non-const is just used for display, set it back
AS_VAR_IF([php_cv_iconv_const], [non-const],
[php_cv_iconv_const=])
AC_MSG_CHECKING([if iconv supports //IGNORE])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <iconv.h>
@@ -147,7 +161,7 @@ int main(void) {
LDFLAGS="$save_LDFLAGS"
CFLAGS="$save_CFLAGS"
PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_NEW_EXTENSION(iconv, iconv.c, $ext_shared,, [-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DICONV_CONST=$php_cv_iconv_const])
PHP_SUBST(ICONV_SHARED_LIBADD)
PHP_INSTALL_HEADERS([ext/iconv/])
else

View File

@@ -44,11 +44,11 @@
#undef iconv
#endif
#if defined(__NetBSD__)
// unfortunately, netbsd has still the old non posix conformant signature
// libiconv tends to match the eventual system's iconv too.
#define ICONV_CONST const
#else
/* iconv can have different constiness for src on some platforms;
* this is explained in config.m4. On Windows, it's always non-const,
* but it can be awkward to set that on the command line. Do it here.
*/
#ifndef ICONV_CONST
#define ICONV_CONST
#endif