Compiling php/php-src source on macOS BigSur

Compiling PHP source code (master) on macOS (BigSur) wasn’t very smooth because of mainly unavailable packages on my OS, and because of some Mac restriction on upgrading software or tools.

After cloning the php/php-src to my localhost, I had to run th…


This content originally appeared on DEV Community and was authored by

Compiling PHP source code (master) on macOS (BigSur) wasn't very smooth because of mainly unavailable packages on my OS, and because of some Mac restriction on upgrading software or tools.

After cloning the php/php-src to my localhost, I had to run the ./buildconf script, and then ./configure --enable-debug executable.

Like all software compile processes will be, I ran into some issues/blockers which I'll document about below.

  • bison (the GNU parser generator) was pinned to 2.3 on my system, and I couldn't upgrade and re-link with brew. I had to custom install bison (using brew upgrade bison) version > 3.0 which is what php-src needs for parsing PHP.

When I finished installing version 3.7.6 which is above the required version, on trying to link via brew, I get:

Alt Text

Since bison is key-only, we can't update the version shipped by macOS (a bit annoying) but I had to export (see image above) the libraries of the latest install of bison so compilers (in this case GCC) can find them, and then ran the ./configure --enable-debug script again.

This time, with the latest libraries from bison 3.7.6, it worked.

  • The next issue I ran into was a missing package called re2c (which is used to compile regex to code). This is similar to the issue encountered in bullet 1, so I just installed the package brew install re2c.

Once I did the above, I ran the ./configure --enable-debug script again and it worked.

NOTE: re2c is not key-only, so, after installation, the necessary libraries are exported by brew.

Alt Text

  • Well, that's not all, I met another issue with libiconv which is a conversion library to convert from/to Unicode.

I installed libiconv using brew as such: brew install libiconv, and notice in the Caveats info that it's key-only.

Alt Text

After installing, I had to export executables to PATH & libraries so compilers could see these.

On trying to re-run ./configure again, I got hit with another issue which is related to libiconv ??

Alt Text

So, this time, I needed to use an option to run the configurations with: --with-config=<DIR>, and the command: ./configure --enable-debug --with-iconv=/usr/local/opt/libiconv/.

This worked smoothly, and I made progress

Alt Text

Now I had to compile PHP using make -j8 (as my computer has 8 cores), wish me luck! ☺️ Hey, it compiled successfully:

Alt Text

NOTE: I first of all ran make which was using by default only 1 core and this was already taking more than 2 mins. I had to change it to make -j8 which was using all my CPU's 8 cores at once, and the compile process took less than 40sec.

Now I just have to run make TEST_PHP_ARGS=-j8 test which ran really fast was it was using all 8 cores at once

Alt Text

All tests ran, and I'm ready to start contributing code to PHP core. Hope this helps you configure, and compile PHP on your macOS.

Thank you!


This content originally appeared on DEV Community and was authored by


Print Share Comment Cite Upload Translate Updates
APA

| Sciencx (2021-05-27T09:47:07+00:00) Compiling php/php-src source on macOS BigSur. Retrieved from https://www.scien.cx/2021/05/27/compiling-php-php-src-source-on-macos-bigsur/

MLA
" » Compiling php/php-src source on macOS BigSur." | Sciencx - Thursday May 27, 2021, https://www.scien.cx/2021/05/27/compiling-php-php-src-source-on-macos-bigsur/
HARVARD
| Sciencx Thursday May 27, 2021 » Compiling php/php-src source on macOS BigSur., viewed ,<https://www.scien.cx/2021/05/27/compiling-php-php-src-source-on-macos-bigsur/>
VANCOUVER
| Sciencx - » Compiling php/php-src source on macOS BigSur. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/27/compiling-php-php-src-source-on-macos-bigsur/
CHICAGO
" » Compiling php/php-src source on macOS BigSur." | Sciencx - Accessed . https://www.scien.cx/2021/05/27/compiling-php-php-src-source-on-macos-bigsur/
IEEE
" » Compiling php/php-src source on macOS BigSur." | Sciencx [Online]. Available: https://www.scien.cx/2021/05/27/compiling-php-php-src-source-on-macos-bigsur/. [Accessed: ]
rf:citation
» Compiling php/php-src source on macOS BigSur | | Sciencx | https://www.scien.cx/2021/05/27/compiling-php-php-src-source-on-macos-bigsur/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.