Skip to content
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

All latest versions fail to build/install on OSX 10.14 Mojave #90

Open
debo opened this issue Oct 10, 2018 · 59 comments
Open

All latest versions fail to build/install on OSX 10.14 Mojave #90

debo opened this issue Oct 10, 2018 · 59 comments
Assignees
Labels

Comments

@debo
Copy link
Member

debo commented Oct 10, 2018

I tried to install the latest versions available on php-build but without luck. I tried to install:

5.6.38
7.0.32
7.1.22
7.2.10

and they all come back with

-----------------
|  BUILD ERROR  |
-----------------

Here are the last 10 lines from the log:

-----------------------------------------
configure: error: Cannot find libz
-----------------------------------------

or

-----------------
|  BUILD ERROR  |
-----------------

Here are the last 10 lines from the log:

-----------------------------------------
configure: error: Cannot find zlib
-----------------------------------------

depending by the version.

Command Line Tools are installed and they are up to date, definitely something to investigate further.

@debo debo added the bug label Oct 10, 2018
@madumlao
Copy link
Member

sorry for the ignorance. Mojave?

@debo
Copy link
Member Author

debo commented Oct 10, 2018

It's the latest OSX version. I'm experimenting a bit as we speak to better understand what's going on.

@debo debo changed the title All latest versions fail to build/install on Mojave All latest versions fail to build/install on OSX 10.14 Mojave Oct 10, 2018
@debo
Copy link
Member Author

debo commented Oct 10, 2018

Ok for the time being I managed to get 7.2.10 to build and install with the following command line:

$ CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-iconv=$(brew --prefix libiconv) --with-readline=$(brew --prefix readline) --with-libedit=$(brew --prefix libedit) --with-tidy=$(brew --prefix tidy-html5)" phpenv install 7.2.10

and installing any missing package via homebrew.

@madumlao
Copy link
Member

Is this effectively a dup of #77?

@debo
Copy link
Member Author

debo commented Oct 11, 2018

No, I wouldn't say so. This to me sounds more like something completely messed up with the new OSX version, its command line tools and the path configuration. As far as I know we don't use homebrew to install php right?

@madumlao
Copy link
Member

I see.

On OSX I don't know the recommended way to install development dependencies though outside of using homebrew.

Does this work without arguments / options if you brew install zlib first?

@debo
Copy link
Member Author

debo commented Oct 11, 2018

I do think homebrew is pretty much the recommended way, or port for the old school people out there. I don't remember when was the last time I used something else than those two.

No it doesn't, I should have specified that the needed dependencies are already installed, it's just that the ./configure happening behind the scenes doesn't find it. I'll investigate further the issue and try to find the root cause.

@debo
Copy link
Member Author

debo commented Oct 11, 2018

By the log of 7.2.10 it looks like php-build needs custom configure options for the latest version.

@debo
Copy link
Member Author

debo commented Oct 11, 2018

Which also reminds me I should search and read before commenting. The changes are already on their way in this PR

@madumlao
Copy link
Member

The mcrypt thing is a non-issue although quite convenient. I can put in a php-build PR the zlib one though.

@madumlao
Copy link
Member

@debo, could you try the osx-zlib branch from my php-build

@debo
Copy link
Member Author

debo commented Oct 11, 2018

It goes on the right track but then it hits the next hurdle:

[Info]: Appending build output to /tmp/php-build.7.2.10.20181011142200.log
[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.2.10 into /Users/marco.debortoli/.phpenv/versions/7.2.10
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.2.10.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.2.10

-----------------
|  BUILD ERROR  |
-----------------

Here are the last 10 lines from the log:

-----------------------------------------
configure: WARNING: unrecognized options: --with-mcrypt
configure: error: Please reinstall the BZip2 distribution
-----------------------------------------

The full Log is available at '/tmp/php-build.7.2.10.20181011142200.log'.
[Warn]: Aborting build.

It really looks like the latest OSX version messed up path management and such. Also I checked your fix and I suppose it should be more specific and target OSX 10.13 and above. Your fork always worked find up until the previous version.

@madumlao
Copy link
Member

@debo, the osx detection code wasn't mine, all I added was zlib detection.

This worked on my friend's mac (I dont have one) immediately after a installing openssl and libxml2 on a nearly empty homebrew. I am guessing added other dependencies that php-build used. Is it possible that this works after you brew install openssl libxml2 ?

If not I basically have to add homebrew detection for each library it fails on to php-build.

@debo
Copy link
Member Author

debo commented Oct 11, 2018

@madumlao I know it's not your code, I know that part of php-build quite well because I stared at it all yesterday 😄

What version of OSX he is running? I definitely have all those dips installed; this is my brew list output:

brew list
adns			consul			glib			jsonlint		libtasn1		memcached		openssl@1.1		tbb
ansible			coreutils		gmp			kops			libtiff			mercurial		p11-kit			telnet
apr			cscope			gmp@4			kubernetes-cli		libtool			mhash			packer			terraform
apr-util		curl			gnupg			kubernetes-helm		libunistring		midnight-commander	pcre			terraform-inventory
augeas			dialog			gnutls			lame			libusb			mpfr			pcre2			tidy-html5
autoconf		dos2unix		go			lemon			libvo-aacenc		mycli			percona-toolkit		tmux
automake		eigen			graphicsmagick		libassuan		libvpx			mysql			perl			tree
aws-shell		exercism		graphviz		libedit			libxml2			mysql-client		pinentry		unixodbc
awscli			expat			hr			libevent		libxslt			neon			pkg-config		utf8proc
bash			ffmpeg			htop			libffi			libyaml			net-snmp		pth			vault
bison			figlet			hub			libgcrypt		libzip			nettle			python			watch
bison@2.7		fontconfig		icdiff			libgpg-error		libzzip			node			python3			webp
boost			freetds			icu4c			libiconv		lua			nomad			python@2		wget
bzip2			freetype		ilmbase			libidn2			luajit			npth			re2c			x264
cask-repair		gcc			imap-uw			libiodbc		lz4			nspr			readline		xvid
ccache			gd			innotop			libksba			lzip			nss			rust			xz
certbot			gdbm			isl			libmagic		lzlib			numpy			s-lang			zeromq
cfssl			geckodriver		isl@0.12		libmemcached		macvim			oniguruma		scons			zlib
chromedriver		gettext			jasper			libmpc			make			opencv			speedtest-cli		zsh
cloog			gist			jpeg			libpng			makedepend		openexr			sqlite			zsh-completions
cmake			git			jq			libssh2			mcrypt			openssl			subversion

Don't worry, leave this one to me, I have a mac and I can investigate better I guess. I only opened the issue to keep track of it in case other people have the same problem. I can work on this 😉

@madumlao
Copy link
Member

I'll keep posted on this as I'm looking into adding a homebrew recipe as well.

I'll also be using the osx-zlib branch to test some changes.

@mizunashi-mana
Copy link

mizunashi-mana commented Oct 14, 2018

I upgraded OSX and met same issues.

I think this is the Mojave's issue. Homebrew/homebrew-core#29176 and https://stackoverflow.com/questions/50780183/cannot-install-brew-on-mojave-with-xcode10 was described details. Perhaps, the reason is no appearance of any Command Line Tools updates for Mojave.

I resolved this issues by Homebrew/homebrew-core#29176 (comment) (or you can install manually. run xcode-select --install and open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg, then you can use GUI installer for CLT headers). In other words, I just run:

$ xcode-select --install
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
$ env "PATH=/usr/local/opt/bison/bin:$PATH" "PHP_BUILD_CONFIGURE_OPTS=--with-openssl=$(brew --prefix openssl) --with-libzip" phpenv install 7.2.9

We should share this problems to php-build.

@madumlao
Copy link
Member

madumlao commented Oct 14, 2018

@mizunashi-mana , does the above work if you skip adding PHP_BUILD_CONFIGURE_OPTS ?

AFAIK it's not necessar yon previous versions of osx as php-build itself should detect openssl

@mizunashi-mana
Copy link

@madumlao macOS uses libreSSL (which is older version). However, PHP requires OpenSSL. So, we should install openssl manually for php-build on macOS. In my case, I use Homebrew to install one.

More details, If I install PHP by php-build without any flags, I get below errors:

$ phpenv install 7.2.9           
...                                                                                                                                                      
[Info]: Appending build output to /tmp/php-build.7.2.9.20181014193936.log
[Info]: Loaded extension plugin
...
[Preparing]: /var/tmp/php-build/source/7.2.9

-----------------
|  BUILD ERROR  |
-----------------

Here are the last 10 lines from the log:

-----------------------------------------
configure: WARNING: unrecognized options: --with-mcrypt
configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: 2.3, min: 204, excluded: ).
configure: error: Cannot find OpenSSL's <evp.h>
-----------------------------------------

The full Log is available at '/tmp/php-build.7.2.9.20181014193936.log'.
[Warn]: Aborting build.

And with --with-openssl=$(brew --prefix openssl), success to install (other flags are not critical).

AFAIK it's not necessar yon previous versions of osx as php-build itself should detect openssl

I agree, but I think it is difficult to cover all platforms.

P.S.
I missed to understand Mojave's policy. I thought Apple's mistake caused this issues.
According to Homebrew/brew#4335, this is true behavior and we should use the CLT SDK layout for Mojave or higher macOS.

@madumlao
Copy link
Member

madumlao commented Oct 14, 2018

@madumlao macOS uses libreSSL (which is older version). However, PHP requires OpenSSL. So, we should install openssl manually for php-build on macOS. In my case, I use Homebrew to install one.

Yes, what I mean is, php-build itself will force the usage of homebrew openssl AFAIK. In addition, my current osx branch of php-build is being worked on to ensure that every such library that we need to force to use the homebrew version is also configured as such.

Here's the homebrew detection code in the original
https://github.com/php-build/php-build/blob/master/bin/php-build#L594

if is_osx && [ "$(osx_major)" -eq 10 ] && [ "$(osx_minor)" -ge 11 ] && [ -n "$(which brew)" ] && [ -e "$(brew --prefix openssl)" ] && [ -e "$(brew --prefix libxml2)" ]; then
        configure_option -R "--with-openssl" "$(brew --prefix openssl)"
        configure_option -R "--with-libxml-dir" "$(brew --prefix libxml2)"
fi

So basically it forces homebrew openssl if both openssl and libxml2 are installed.

Given that:

  • brew install openssl
  • brew install libxml2

are added, can you test the installation without the PHP_BUILD_CONFIGURE_OPTS that forces openssl? Your workaround basically puts homebrew on Mojave at parity with homebrew on previous versions of osx. I want to make sure at least just that part works in that case.

More details, If I install PHP by php-build without any flags, I get below errors:

If you encounter errors with the above (after ensuring openssl and libxml2 are installed), can you test on my current osx development branch madumlao/phpenv#osx-zlib ? I'm putting some improvements in the homebrew library detection code there.

Almost any other change needed for osx is just going to be of the same form as "do we have the homebrew version? if so add to configure..." so I want to make sure those parts work.

AFAIK it's not necessar yon previous versions of osx as php-build itself should detect openssl

I agree, but I think it is difficult to cover all platforms.

See above, the build script in php-build itself has special code for detecting the presence of osx and homebrew. I think you encountered a php-build bug, and I'm working on some PRs for that.

@mizunashi-mana
Copy link

mizunashi-mana commented Oct 14, 2018

@madumlao I see. I didn't know that homebrew detection codes already exists in php-build. However, https://github.com/madumlao/php-build/tree/osx-zlib seems to be too customized for me. I tests https://github.com/madumlao/php-build/tree/osx-zlib, when I have times.

By the way, we should create new issue for brew detection on php-build because I think https://github.com/madumlao/php-build/tree/osx-zlib is not related this issue. If there are some people meets Mojave issue, they get confusing when they see this thread. And, we should discuss to support Mojave without zlib/bzip2 of Homebrew on this issue.

@madumlao
Copy link
Member

@mizunashi-mana, I still need to know - does the compile work if you have both openssl and libxml2 installed via homebrew? I need to know to find out how deep this hits as I also need to line up some PRs for OSX.

@mizunashi-mana
Copy link

mizunashi-mana commented Oct 14, 2018

@madumlao I will report #90 (comment) on php-build/php-build#538, because I think this is not related Mojave's issues.

For @madumlao and all of phpenv/php-build users, I summarize my research:

  • Now, php-build is breaked on Mojave (latest macOS)

    Mojave provides Command Line Tools changes (https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624). The paragraph we should care most is:

    The command line tools will search the SDK for system headers by default. However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include. If you are the maintainer of such software, we encourage you to update your project to work with the SDK or file a bug report for issues that are preventing you from doing so. As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided.

    According to this policy, we cannot use /usr/include on macOS Mojave or higher now! And, macOS SDK use '.tbd' for library extensions which is not supported by PHP configure.

    Now, because PHP use zlib/bzip2/iconv/libedit bundled by macOS on /usr/include, anyone fails to build PHP on Mojave.
    Currently, PHP working for this changes on https://bugs.php.net/bug.php?id=76403.
    And, Homebrew php formula was done on php: update zlib detection on Mojave Homebrew/homebrew-core#31498.

  • How do we fix this issue?

    1. Wait PHP works (https://bugs.php.net/bug.php?id=76403), and search bundled packages by PHP configure.
    2. Insert fallback patch, such as: Mojave: use the CLT SDK where necessary Homebrew/brew#4335.
    3. Force to use Homebrew and Homebrew formulas.
  • For phpenv/php-build users:

    If you want to fix this issue without patches as soon, I suggest you run below command:

    sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

    This command creates /usr/include, and copy any headers from macOS bundled SDK.

@debo
Copy link
Member Author

debo commented Oct 15, 2018

@madumlao installing those library doesn't fix it, as I mentioned earlier they just don't get detected anymore, not even if you manually run a ./configure from within the php source folder.

@mizunashi-mana thanks for sharing all those links, I do still wonder why the homebrew libraries are not picked up though considering that in my system for example the brew path has precedence on all the others. Also it's curious to see that in my case I'm not having issues with openssl itself but other libs. Go figure.

@madumlao
Copy link
Member

@madumlao installing those library doesn't fix it, as I mentioned earlier they just don't get detected anymore, not even if you manually run a ./configure from within the php source folder.

@mizunashi-mana thanks for sharing all those links, I do still wonder why the homebrew libraries are not picked up though considering that in my system for example the brew path has precedence on all the others. Also it's curious to see that in my case I'm not having issues with openssl itself but other libs. Go figure.

@debo, this is actually why I'm clarifying it. ./configure cannot detect homebrew libraries unless you manually specify the homebrew location, which is why both upstream php-build and my current branch (and also ruby-build) specifically detect if the homebrew package is installed and use add the specific configure option.

Furthermore, from the looks of the Mojave policy, php-build / ruby-build will need to be updated with detection for libraries specifically used by php and ruby during the build process.

Again for clarity: homebrew libraries are not installed in a standard location and are unlikely to be picked up by the ./configure scripts in most packages unless tooling support is added for them, either in homebrew itself or in the build script (php-build). As php-build does building outside of homebrew tooling, it is likely that such tooling support also needs to be added to php-build eventually, hence the code that does the brew --prefix detection. All that seems to have changed with Mojave and future releases is that this homebrew detection code will have to be added to php-build for any other library that fails to be detected.

It's not really a herculean task as I basically have to search for all the --with-foo-dir options in the PHP configure script and match them to homebrew package names.

@debo
Copy link
Member Author

debo commented Oct 15, 2018

@madumlao I didn't have a look at the code itself yet, and with code I mean the php-build one or even the actual ./configure one, but I always, naively maybe, thought the inclusion of headers was based on the $PATH env var... if that's the case then it should have worked just fine on my machine because I include the homebrew path and I give it priority over the others.

Either ways if you think we should go about it by adding all the additional options in phpenv for the time being I'm more than happy to take up that task, so let me know please.

@mizunashi-mana
Copy link

Hi @hanachan1026 thanks for the report!

Could you try below line?

env LDFLAGS="-L$(xcrun --show-sdk-path)/usr/lib/system" phpenv install 7.2.9

And, could you give the content of /tmp/php-build.7.2.10.20181218014949.log to us for improvement?

Probably, this is the bug of PHP (not phpenv's), and it happens on all version but not only Mojave.

@hanachan1026
Copy link

Hi @mizunashi-mana thank you for your advice.

I tried that line and I got a log below

% cat /tmp/php-build.7.2.9.20181218182229.log configure: WARNING: FPM Trace - ptrace, pread, or mach: could not be found configure: WARNING: ======================================================== configure: WARNING: Use of bundled libzip is deprecated and will be removed. configure: WARNING: Some features such as encryption and bzip2 are not available. configure: WARNING: Use system library and --with-libzip is recommended. configure: WARNING: ======================================================== configure: error: off_t undefined; check your library configuration

So, maybe I should check out the php website. Thank you.

@mizunashi-mana
Copy link

@hanachan1026 Hmm...

I think https://bugs.php.net/bug.php?id=73943 is just one.

Probably, PHP cannot find the location of zip library bundled by XCode on your macOS.
My ideas to resolve it are:

  • Update XCode and install latest Command Line Tools
  • Install libzip via Homebrew
  • Search zipconf.h and specify the prefix by the zipconf.h location

If you update php-build plugin and rerun:

xcrun --show-sdk-version
xcrun --show-sdk-platform-version
env LDFLAGS="-L$(xcrun --show-sdk-path)/usr/lib/system -L$(xcrun --show-sdk-platform-path)/usr/lib/system" phpenv install -v 7.2.9

then paste the log on this issue, I may help more.

@mizunashi-mana
Copy link

mizunashi-mana commented Dec 19, 2018

@hanachan1026

If you have libzip of Homebrew, this may work.

env "CONFIGURE_OPTS=--with-libzip=$(brew --prefix libzip)" phpenv install 7.2.9

And, please check whether exists /usr/include/zconf.h or $(xcrun --show-sdk-path)/usr/include/zconf.h; zipconf.h is not correct name, that is my mistake, sorry.

  • If you have no /usr/include directory, the latest CLT update may be not installed.
  • If you have no $(xcrun --show-sdk-path)/usr/include/zconf.h, the part of libraries may be breaked or more sdks may be needed.
  • If you have these files, this issue may be a PHP bug.

But, because I am not professional for macOS, above comments perhaps include some wrong.

@hanachan1026
Copy link

@mizunashi-mana
env "CONFIGURE_OPTS=--with-libzip=$(brew --prefix libzip)" phpenv install 7.2.9
I got the same error as before, and both /usr/include/zconf.h and $(xcrun --show-sdk-path)/usr/include/zconf.h existed, so I think this is a PHP bug.
I'll try to dig into the php bug reports. Thank you.

@debo
Copy link
Member Author

debo commented Dec 20, 2018

@hanachan1026 next time I suggest you create a gist for logs that long. One thing that was previously mentioned and it's still relevant and needed is the fact Mojave moved its libraries headers to a different location, causing many tools that are depending on them to fail.

If you didn't already please make sure you execute the following commands:

$ xcode-select --install
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

And in case you want more context please scroll back in this thread and you will find additional infos.

Please let us know if that helps.

@hanachan1026
Copy link

@debo Sorry for tha late reply.
And the log was too long obviously, I'll use gist next time.

I still get the same error with those commands, and I read all this thread and php-build issue, so I think I'll wait for the php bug fix report for Mojave.

@debo
Copy link
Member Author

debo commented Dec 30, 2018

@hanachan1026 I'm afraid but I'm sort of bearer of bad news. 7.2.9 build fine for me as you can see from the following output:

[Info]: Loaded extension plugin
[Info]: Loaded apc Plugin.
[Info]: Loaded composer Plugin.
[Info]: Loaded github Plugin.
[Info]: Loaded uprofiler Plugin.
[Info]: Loaded xdebug Plugin.
[Info]: Loaded xhprof Plugin.
[Info]: Loaded zendopcache Plugin.
[Info]: php.ini-production gets used as php.ini
[Info]: Building 7.2.9 into /Users/debo/.phpenv/versions/7.2.9
[Skipping]: Already downloaded and extracted https://secure.php.net/distributions/php-7.2.9.tar.bz2
[Preparing]: /var/tmp/php-build/source/7.2.9
[Compiling]: /var/tmp/php-build/source/7.2.9
[xdebug]: Installing version 2.6.1
[Skipping]: Already downloaded http://xdebug.org/files/xdebug-2.6.1.tgz
[xdebug]: Compiling xdebug in /var/tmp/php-build/source/xdebug-2.6.1
[xdebug]: Installing xdebug configuration in /Users/debo/.phpenv/versions/7.2.9/etc/conf.d/xdebug.ini
[xdebug]: Cleaning up.
[Info]: Enabling Opcache...
[Info]: Done
[Info]: The Log File is not empty, but the Build did not fail. Maybe just warnings got logged. You can review the log in /tmp/php-build.7.2.9.20181230225107.log or rebuild with '--verbose' option
[Success]: Built 7.2.9 successfully.

I'm running the latest mojave and this is the output of my brew list for you to compare.

And the following is my actual export path:

export PATH="$HOME/bin:$GOPATH/bin:/usr/local/share/dotnet:/usr/local/bin:/usr/local/sbin:/usr/local/opt/ccache/libexec:/usr/local/opt/bison/bin:$PATH"

I hope it helps.

@madumlao
Copy link
Member

sup guys,
Apparently, I've been given a MacBook for a work laptop, with Mojave, as opposed to my previous situation of kinda feeling around on linuxbrew.

I may start active work on this soon if this hasn't yet been resolved.

@debo
Copy link
Member Author

debo commented Apr 15, 2019

@madumlao I don't know, we didn't hear back from @hanachan1026 so maybe resolved... let's see if they get back to us

@hanachan1026
Copy link

hanachan1026 commented Apr 15, 2019 via email

@debo
Copy link
Member Author

debo commented Apr 15, 2019

I see, that's a shame. Did you try to match your configuration to mine though? Do you have the same brew packages?

@mizunashi-mana
Copy link

See php-build/php-build#543 (comment) .

I'm trying to create patch, but that's difficult job and I'm busy recently, so my work is delayed. PR is welcome.

@madumlao
Copy link
Member

Parallel to @mizunashi-mana 's effort, I've put a little more into my previous php-build#osx-zlib branch branch and I've gotten at least 7.2.x and 7.1.x building on Mojave + XCode 10.2, however I haven't yet gotten libtidy to work and 7.0.x complains of gmp issues.

I'll need to integrate his patches into it to try as they go deeper into the heart of the problem which is PHP's build scripts.

@debo
Copy link
Member Author

debo commented Apr 22, 2019

At this point I am not sure what became different on my machine but I don't have these issues anymore... 😢

@naviapis
Copy link

naviapis commented Nov 6, 2019

macOS 10.15 Catalina

$ brew install autoconf bison bzip2 curl icu4c libedit libjpeg libiconv libpng libxml2 libzip openssl re2c tidy-html5 zlib

$ PATH="$(brew --prefix icu4c)/bin:$(brew --prefix icu4c)/sbin:$(brew --prefix libiconv)/bin:$(brew --prefix curl)/bin:$(brew --prefix libxml2)/bin:$(brew --prefix bzip2)/bin:$(brew --prefix bison)/bin:$PATH" \
PHP_BUILD_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-curl=$(brew --prefix curl) --with-iconv=$(brew --prefix libiconv) --with-libedit=$(brew --prefix libedit)" \
phpenv install 7.3.9

$ php -v
PHP 7.3.9 (cli) (built: Sep 10 2019 17:45:01) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies

@debo
Copy link
Member Author

debo commented Nov 7, 2019

Thanks @naviapis that worked a treat

@steinybot
Copy link

Someone already mentioned PHPBrew but here is their issue and their fix phpbrew/phpbrew#966

@mackensen
Copy link

To get PHP 7.1.32 to build on Mojave I needed this configuration:

env PATH="$(brew --prefix icu4c)/sbin:$(brew --prefix libiconv)/bin:$(brew --prefix curl)/bin:$(brew --prefix libxml2)/bin:$(brew --prefix bzip2)/bin:$(brew --prefix bison)/bin:$PATH" CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-curl=$(brew --prefix curl) --with-iconv=$(brew --prefix libiconv)" PHP_BUILD_CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl@1.1)" phpenv install 7.1.32

That's with openssl@1.1 installed and openssl@3 NOT installed. I also needed to patch configure, as described at https://bbs.archlinux.org/viewtopic.php?pid=1954966#p1954966, or the build failed:

/var/tmp/php-build/source/7.1.32/ext/intl/collator/collator_sort.c:543:26: error: use of undeclared identifier 'FALSE'
        collator_sort_internal( FALSE, INTERNAL_FUNCTION_PARAM_PASSTHRU );

This was the patch:

diff --git a/configure b/configure
index 78811fa..5a303a0 100755
--- a/configure
+++ b/configure
@@ -45864,7 +45864,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
     php_cxx_done=yes
   fi
 
-  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"
+  INTL_COMMON_FLAGS="$ICU_INCS -Wno-write-strings -D__STDC_LIMIT_MACROS -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -DU_DEFINE_FALSE_AND_TRUE=1"
   if test "$icu_version" -ge "4002"; then
     icu_spoof_src=" spoofchecker/spoofchecker_class.c \
     spoofchecker/spoofchecker.c\

@NoraGithub
Copy link

Thanks @naviapis that worked a treat

why not mention this configure options on documentations

@bensaufley
Copy link

On MacOS 13.4 Ventura this appears to still be an issue. I tried a number of the suggested solutions but ended up just uninstalling phpenv.

@debo
Copy link
Member Author

debo commented Jul 20, 2023

why not mention this configure options on documentations
You are definitely right @NoraGithub I'll add it as soon as I can

@debo
Copy link
Member Author

debo commented Jul 20, 2023

On MacOS 13.4 Ventura this appears to still be an issue. I tried a number of the suggested solutions but ended up just uninstalling phpenv.
@bensaufley I am on Ventura myself and I can compile them without issues now. It's also worth noticing that this specific issue is not actually related to phpenv itself but its dependency php-build

Do you remember what commands you were running and what error you were getting?

@bensaufley
Copy link

@debo phpenv install 8.2.8 gave me configure: error: Please reinstall the BZip2 distribution. Installing over the local MacOS version with Homebrew and replacing it in PATH had no effect. I also tried naviapis's solution and it also didn't work, but I don't remember if it was still the BZip2 error.

I see this issue over in php-build: php-build/php-build#543, with no movement since 2019 😞 is that where I should be looking?

@debo
Copy link
Member Author

debo commented Jul 20, 2023

@bensaufley yes the plain command definitely won't work, that's known.

In my case, given the listed brew packages are installed, the following commands work without issues for example:

PHP_BUILD_CONFIGURE_OPTS="--with-zlib-dir=$(brew --prefix zlib) --with-bz2=$(brew --prefix bzip2) --with-curl=$(brew --prefix curl) --with-iconv=$(brew --prefix libiconv) --with-libedit=$(brew --prefix libedit) --with-tidy=$(brew --prefix tidy-html5)" phpenv install 8.1.11

If you would be so kind to give it one more try, time permitting, I will be more than happy to try to find out the actual culprit.

As per the issue you linked, yes that's one but if you look there are few more on their GitHub, some more recent than that and we are not sure when and if it will addressed. The current state of things and the reason phpenv seems to not be working as expected is because of php-build falling a little bit behind what the other *env tools are doing to address the latest MacOS releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants