Skip to content

README: Fix non-existent iconv in macOS instruction #19475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ sudo dnf install re2c bison autoconf make libtool ccache libxml2-devel sqlite-de
On MacOS, you can install these using `brew`:

```shell
brew install autoconf bison re2c iconv libxml2 sqlite
brew install autoconf bison re2c libiconv libxml2 sqlite
```

or with `MacPorts`:
Expand Down
12 changes: 11 additions & 1 deletion build/php.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,17 @@ AC_DEFUN([PHP_SETUP_ICONV], [

dnl Check external libs for iconv funcs.
AS_VAR_IF([found_iconv], [no], [
for i in $PHP_ICONV /usr/local /usr; do

dnl Find /opt/homebrew/opt/libiconv on macOS
dnl See: https://github.com/php/php-src/pull/19475
php_brew_prefix=no
AC_CHECK_PROG([BREW], [brew], [brew])
if test -n "$BREW"; then
AC_MSG_CHECKING([for homebrew prefix])
php_brew_prefix=$($BREW --prefix 2> /dev/null)
fi

for i in $PHP_ICONV $php_brew_prefix/opt/libiconv /usr/local /usr; do
Copy link
Author

@Krinkle Krinkle Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't great, but I'm trying to keep the patch simple and follow existing patterns.

Usually PHP_ICONV=yes so it creates a dummy entry that is naturally skipped (by virtue of there being no yes/ subdirectory). Likewise, $php_brew_prefix will check either /opt/homebrew/opt/libiconv or /usr/local/opt/libiconv or no/opt/libiconv where the latter is naturally skipped.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, this now looks good to me, I'll plan to merge this in a day or two if there are no objections

if test -r $i/include/gnu-libiconv/iconv.h; then
ICONV_DIR=$i
ICONV_INCLUDE_DIR=$i/include/gnu-libiconv
Expand Down