ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Universal Binaries for macOS/PHP
Posted by Will Koehler on Dec-26-2020 13:04
Are there plans to release universal binaries (or an ARM64 variant) for PHP on macOS?

Thanks,

-Will

  Re: Universal Binaries for macOS/PHP
Posted by Peter Kwan on Dec-28-2020 15:20
Hi Will,

Would you mind to inform me which PHP distribution you are using? Do you compile it by using, or using a pre-compiled distribution (eg. XAMPP, MAMP, ...)?

In recent versions of macOS, the PHP that comes with macOS is signed as a "platform binary". That means it will not accept any third party PHP extensions. The only extensions it can use are the ones signed by Apple. See:

https://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1581617064#N1581707887

The last time we checked, we found that there is no common pre-compiled PHP distribution that supports ARM64 on macOS. That means even if we compile an ARM64 release, there is nothing to test against.

(Of course, we can compile the PHP ourselves, but for a public release, we would like to test against some common pre-compiled PHP distributions. If there is nothing to test against, we cannot be sure if it works in actual usage.)

Regards
Peter Kwan

  Re: Universal Binaries for macOS/PHP
Posted by Will Koehler on Jan-03-2021 11:08
Hi Peter,

In MacOS Catalina, I used the PHP that came with MacOS and just loaded ChartDirector as I always have and it worked.

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; WCK-Currently this is hacked to point to the only extension we are using
; Which is the ChartDirectory lib directory
extension_dir = "/Users/Will/Working/WebLibraries/ChartDirector/lib"
; WCK - Load Chart Director manually
extension=phpchartdir720.so

This doesn't work on the M1 because phpchartdir720.so does not have an ARM64 binary.

I have successfully run ChartDirector on the M1 using the homebrew PHP and Apache running in Intel emulation.

brew install httpd
brew install php@7.2

Then load PHP from Apache

# httpd.conf
LoadModule php7_module /usr/local/opt/php@7.2/lib/httpd/modules/libphp7.so

But this means I have to use Intel emulated PHP and Apache for everything in order to work with ChartDirector.

I have also successfully run full ARM64 Apache and PHP on the M1 using the steps to setup "Homebrew on Apple Silicon" here https://soffes.blog/homebrew-on-apple-silicon. It works for everything, until I tried to use the ChartDirector extension.

I'm guessing you could follow the "Homebrew on Apple Silicon" steps and get Apache+PHP running and test the ChartDirector build that way.

I'm also to test in my setup if that would be helpful.

-Will

  Re: Universal Binaries for macOS/PHP
Posted by Peter Kwan on Jan-05-2021 02:15
Hi Will,

I tried myself to use ChartDirector with the Apache/PHP that comes with Catalina (10.15). To my surprise, it works.

In Mojave (10.14), Apple introduces the hardened runtime with GateKeeper and Library Validation feature. According to Apple, if the app is signed, then it cannot load any shared object except those "signed by Apple or signed with the same team ID as the app". That means the Apache/PHP that comes with macOS cannot support third party extensions. Any attempt to use third party extensions will result in Library Validation errors (in the httpd error log).

I checked the codesign entitiements of the /usr/sbin/httpd in Catalina. I found that it is signed with the com.apple.security.cs.disable-library-validation flag, which disables the Library Validation. That explains why the Apache/PHP in Catalina supports third party extensions.

Unluckily, the same flag does not appear in Big Sur (10.16), and it produces Library Validation errors when third party extensions are used.

For ordinary apps, we can unsign the app with root privileges. However, the Apache/PHP is treated as "platform binary" in macOS, and it cannot be modified.

For the homebrew for Apple Silicon, I cannot build the homebrew php@7.3 (which is the version included in Big Sur). The page below seems to suggest there are still problems building php 7.2/7.3, and it may never be fixed. I tried to just use "brew install php", and it builds the php 8.0.0 successfully.

https://github.com/Homebrew/brew/issues/7857

I compiled the ChartDirector for Apple Silicon for PHP 8, and it does work with the PHP 8 homebrew build.

As this stage, it may be premature for us to officially release ChartDirector for PHP for Apple Silicon (arm64), because there is common PHP builds that we can test against.

Internally, we have built the mac arm64 release for PHP 7.3, 7.4 and 8.0. As there is no mac arm64 PHP 7.3 and 7.4 to test against, the PHP 7.3 and 7.4 is never tested. The 8.0 is only tested against the homebrew version.

If you are interested in these builds, please let me know. I can send it to you for testing.

Regards
Peter Kwan